Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
[SOLVED] First attempt to integrate ARkit and first questions...
-
I'm trying to debug this problem using the xcode template in order to create an application from this script.
Then, I hope I can have some informations with the debug tools of xcode... -
@Brun0oO said:
ARSCNDebugOptionShowWorldOrigin = 1 << 0
ARSCNDebugOptionShowFeaturePoints = 1 << 1I'm not sure about these values. I've reviewed the Apple documentation
https://developer.apple.com/documentation/arkit/arscndebugoptions?language=objc
https://developer.apple.com/documentation/scenekit/scndebugoptions?language=objc
and I decided to test these values :ARSCNDebugOptionShowWorldOrigin = 1 << 10 ARSCNDebugOptionShowFeaturePoints = 1 << 11
but I got no result :o(
I inspected the debug console with xcode and I didn't find any valuable message.I don't know :
- if my arkit classes are correctly configured,
- if I need to call a kind of super init (and how can I do this with create_objc_class),
- if my delegates are well configured...
I'm open to any suggestion :o)
-
@Brun0oO, I am probably not able to help you directly, but still super-interested in how far you manage to take this. Did you make any progress since your last post?
Printing the configuration in viewWillAppear looks like the options get applied allright:
<ARWorldTrackingConfiguration: 0x1c0499000 planeDetection=Horizontal worldAlignment=GravityAndHeading lightEstimation=Enabled>
-
Adding the scene below gives me a floating cube, which hoverever is not fully ”connected” to the surroundings but keeps slipping away as I try to walk around it.
def createSampleScene(): # an empty scene scene = SCNScene.scene() root_node = scene.rootNode() cube_geometry = SCNBox.boxWithWidth_height_length_chamferRadius_(1, 1, 1, 0) cube_node = SCNNode.nodeWithGeometry_(cube_geometry) cube_node.setPosition((0, 0, -5)) light = SCNLight.light() light.setType_('omni') light_node = SCNNode.node() light_node.setLight_(light) light_node.setPosition((1.5, 1.5, 1.5)) root_node.addChildNode_(light_node) root_node.addChildNode_(cube_node) return scene
-
@mikael : thanks for your support. I continue to seek a solution to this 'arkit' challenge ;o)
As a roadmap, my first step is to be able to see the feature points (I need it because I don't know if the arkit framework is correctly set), then, I will try to use the plane detection and then, I will try to add a 3D object to this plane...my dream...
I'm still thinking the major problem lies in the fact that my custom view controller is badly added to the main hierarchy. It's not normal that I need to call manually 'cvc.viewWillAppear_(False)'. So I think some callbacks are not called because my hierarchy is badly "mounted". If someone can check this, I would be grateful...
Another part of the jigsaw : I've noticed if I use 'setDebugOptions_' with a value, this value is clamped to (1<<11)-1 (1<<10 is the last bit flag you can use without any ARkit stuff). It's like my ARWorldTrackingConfiguration was not taken into account...
Moreover, if I inspect the "session" variable in the "CustomViewController_viewWillAppear_" function, "configuration" is actually null :o(Caution : the following sentence contains Beatles lyrics inside :
"help!, i need somebody... help..." ;o) -
Have you tried on_main_thread in
__init__
? I think things like adding subviews are supposed to be on the main thread. -
@JonB, is it not already on main thread, since the call to main is decorated?
-
good point, yes
-
Sorry, a side note guys. Has anyone written anything either in a gist or in the forum that really explains @on_main_thread as it applies specifically to Pythonista and some simple logic to know wether you need to be using it. Or is it safe to say if you are not using objC or your own threads that you can safley say you dont need to be concerned with it?
-
According to Ole's reply in one issue. @on_main_thread is there for objc_util only. Every other module should handle this internally. If not and main thread is required, it's a bug.
See https://github.com/omz/Pythonista-Issues/issues/461 for more info.
-
-
@zrzka , ok thanks thats very clear! Just good to know
-
Back to the original problem:
per apple docs, you have to add the child view controller first:[self addChildViewController:childVC];
[self.view addSubview:childVC.view];
[childVC didMoveToParentViewController:self];The problem i think is that ui.Views don't have a viewcontroller until they are presented
-
@JonB, allright! So, by changing the
MyARView
__init__
toinitialize
and only calling it afterpresent
:v = MyARView() v.present('full_screen', hide_title_bar=True) v.initialize()
... we can follow the right order, using the "forbidden"
nextResponder
trick:self_objc.nextResponder().addChildViewController_(cvc) self_objc.addSubview_(sceneview) cvc.didMoveToParentViewController_(self_objc)
... after which
CustomViewController_viewWillAppear_
no longer needs to be called manually, i.e. things work as they should.(Here's a gist with this version of the code.)
But still, debug info does not appear, nor does the cube stay anchored to the surroundings.
-
@omz, just checking: for ARKit to really work in Pythonista, would Pythonista need to include the
arkit
key inplist
or somesuch? -
Nope, the key is not required. See https://developer.apple.com/documentation/arkit (Important section at the beginning). You only need device with >= A9 chip. Use isSupported to check if your device is supported.
-
@zrzka, thanks.
Again, just to be sure, I checked the property and got
True
on my 6S+.Would be nice if someone could run the gist from the previous post, maybe on a newer device, just to check that the results are similar.
-
@mikael and @JonB, many thanks. It's better, now, the custom view controller is correctly "mounted".
I'm investigating the ARSession problem and i'm trying to understand why its configuration stays null after a "runWithConfiguration_" call (I'm going to use some delegate methods in order to spy the initialization process...).
I will update my github ASAP.Stay tuned...
-
I'm rewriting the Apple demo (candles, ...) into Python(ista). Will share it when finished.
-
@zrzka, just curious, did you progress with this? And if not, was it due to some problems or just other more important things taking up your bandwidth?