LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Queue State Machine on autopilot system

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 advanceSmiley Sad

0 Kudos
Message 1 of 10
(2,948 Views)

the problem now is that I don't know how to change the enum to the subvi that I want. Anyone ?Robot SadRobot Sad

0 Kudos
Message 2 of 10
(2,925 Views)

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.

0 Kudos
Message 3 of 10
(2,915 Views)

Can you post your current version of the approach?

 

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 4 of 10
(2,913 Views)

Here is what i had done so farCat Embarassed

0 Kudos
Message 5 of 10
(2,889 Views)

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

Message 6 of 10
(2,880 Views)

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.

0 Kudos
Message 7 of 10
(2,875 Views)

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".

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 8 of 10
(2,848 Views)

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

0 Kudos
Message 9 of 10
(2,804 Views)

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.

Message 10 of 10
(2,797 Views)