11-05-2012 09:47 PM
hi guys, I am trying to interface an autopilot system into a queue state machine. I looked into the examples but I still could not get my program to work. I wanted it to be something like the AR.drone will takeoff first, then yaw one round to the right then pitch up then yaw left one round then it will land. I really need you guys' helps and tips. Thanks in advance
11-06-2012 02:06 AM - edited 11-06-2012 02:07 AM
the problem now is that I don't know how to change the enum to the subvi that I want. Anyone ?
11-06-2012 03:45 AM
okok sorry for bothering. Currently the problem is that the state 1 can't escape to state 2. I am trying to make the AR.Drone to yaw right and then yaw left then yaw right and yaw left.
11-06-2012 03:47 AM
Can you post your current version of the approach?
Norbert
11-06-2012 07:27 PM
Here is what i had done so far
11-06-2012 09:16 PM
What makes you think it is not working?
The only way it would not run is for one of the yaw subVIs to hang up or fail to complete. The UDP functions are set with a 25 second timeout. Have you waited long enough to see if they generate a timeout error? You might not notice since you have no error handlers or indicators.
When I run it it goes through the sequence: Idle, State 1, State 2, State 3, State 4, State 5, Idle, Idle. I need to click on Stop twice because the first click sets Stop False and the second click sets it True. Somehow you have made the un-pressed default condition True. It takes about 408 ms to run through the states with State in their names.
Try it with Execution Highlighting (the light bulb on the BD toolbar) turned on.
Lynn
11-06-2012 09:46 PM
Thanks for the tips. However, the problem is that I need to press down the 'start' button twice. Then the flying will be activated. After that , i need to press down the start button each time in order to activate the state changes.
11-07-2012 12:49 PM - edited 11-07-2012 12:51 PM
You are using the mouse up event. Is there any specific reason?
I ask because it's the reason for your misbahvior:
Clicking on the mouse button 1 (leftclick) over "start" and (while mouse button is still pressed) accidently leaving the area of the start button will result in "weird behavior" as such that
a) The sequence does not start "playing"
b) The stop button has to be pressed twice before actually getting honored.
hope this helps,
Norbert
PS: You should go for "value change".
EDIT: And sure you have to press "start" again to re-start the sequence. That is what your code tells LV to do. It would be different if your last state either enqueued "state1" instead of "idle" or your idle state would enqueue "state1".
11-08-2012 08:50 PM - edited 11-08-2012 08:57 PM
I ran the highlight execution. For the first time when i press the start button, the state will goes like this idle,1,1, 2,2 ,3,3,4,4,5,5,idle. However, from the second time i press the start button onwards, the state will goes like 1,2,1,2,3,2,3,2,4,3,4,3,5,4,5,4,idle. It will go back to the previous. I want the states to go like idle,1,2,3,4,5,idle. Why does it react like this. I upload the program with minor changes. The program is based on the queue machine 2 loop http://forums.ni.com/t5/LabVIEW/Queued-State-Machine/td-p/1104479
11-08-2012 10:10 PM - edited 11-08-2012 10:11 PM
Change your mechanical action of your switch. For some reason you have it as Switch until released. What happens is it detects a value change even when you press it down, and then again when you release it. So you wind up getting 2 items into the queue and have effectively started 2 state machines in operation interleaving each other. The apparent order of execution is all dependent on a race condition on how many states have executed through the machine from the first event of the button between pressed down, and how long you wait before the 2nd event of the button being released.
If your switch was Latch when released, you'll only get one value change event.
(Note if you run your existing code, hold down the button and don't release it, you'll see it probably behaves more like you were hoping for.) Change the mechanical action like I said, and the code will execute properly.