Unexpected Avatar lookAt() behavior when using yield statements
Hi,
I have an encountered some unexpected behavior in my Vizard application which I cannot work out. I should stress that I am relatively new to Python and the use of Yield statements. My problem may or may not be directly caused by the use of them. The application I am creating uses two differing scenarios; the first scenario requires the user to follow an avatar and the second scenario requires the user to retrace the route that they went on when they followed the avatar. I have created two classes (one for each scenario). Within the main.py file, I call a main functionbusing viztask.schedule(). I have used an (rather un-elegant) if statement that queries the state of the program which determines which scenario to run. At the end of following the avatar, the visibility of the avatar is disabled. The scenario returns and the next scenario is played out where the user retraces the route. When this has finished, we re-initialise the following avatar scenario which includes placing the avatar back in the start position and setting the orientation to what ever direction it needs to go. However, I call the lookAt() function to do this but it doesn't seem to take any effect. I used debug statements everywhere to try and find out why this wasn't working and found that actually, lookAt() was doing what it was supposed to do but at some other point, the avatar orientation was put back to where it was facing before calling the lookAt() function. I am going to put some code down now. Sorry for the long explanation (finding this difficult to word!) Code:
def runExperiment(): Code:
if(programState.isInitExperiment()): The next line prints out the avatar euler to the console. I've also identified this with a number so you can clearly see the output. When I first return the euler, it is not how I set it within the method. The euler has returned to (not how it was when first loaded in to Vizard at the very beginning) but how it was before I called the .lookAt() function. So I then call a method to reset this. This method does nothing but call the lookAt() function on the avatar from within the same class. Then, returning the euler, I can see it is correct. Where it gets really puzzling for me, I then set the state of application (sounds simple enough). If I put a yield statement in front of this line, I see the same behavior. The avatar oritentation returns to how it was in the previous experiment (ignoring the last two times I called .lookAt(). If I take out the yield statement, as shown in the code example, I do not see this behavior. To try and show you what I mean, here is what I see in the output window with and without the yield statement before the line: "programState.setTrainingInstructions()" With Yield Statement 1a: [-89.52449798583984, -0.0, 0.0] 1b: [0.0, 0.0, 0.0] 2a: [-89.52449798583984, -0.0, 0.0] 2b: [0.0, 0.0, 0.0] Without Yield Statement 1a: [-89.53038787841797, -0.0, 0.0] 1b: [0.0, 0.0, 0.0] 2a: [0.0, 0.0, 0.0] 2b: [0.0, 0.0, 0.0] None of this really matters anyway because when I move down the code to call a function that displays the message I want, I must use a yield statement else Vizard gets blocked and the the avatar orientation goes back to [-89.53038787841797, -0.0, 0.0]. I am very sorry for the long-winded post. I had trouble describing the problem I am seeing. Hopefully someone can help me out. Please ask if there is something I have missed out. Thanks |
As promised, the class code for followAvatarTask:
Code:
import viz |
Okay, so I have managed to fix this and perhaps my question could have been asked in a much simpler manner! Forgive me as I was obviously struggling to communicate and operate yesterday (through lack of coffee or whatever!)
So, the problem I was seeing was that I was setting the euler or calling lookAt on the avatar but when I called another function, using yield, the avatar would simply go back to the direction is was facing before. By running an action and getting the avatar to turn to the direction, I was able to solve this problem. I am guessing that within the main vizard update loop, the avatar actions were still running, and were therefore turning the avatar to the old position. This meant every time I reset the euler and returned control back to Vizard, the updated was "lost". The reason I did not suspect this initially was because when I wanted to "get rid of the avatar" I was only turning the visibility of the avatar to False, setting the state to standing (and it had already reached it's goal location so was no longer travelling). What I wasn't doing was stopping the actions from being run so the turn() function was constantly being called. Complete oversight on my part but at least now solved. Sorry for not explaining it properly! |
All times are GMT -7. The time now is 05:44 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC