03-25-2013 07:16 AM
Hello. I am trying to create a control VI for a quad-copter. Right now I've managed to build a basic program that gets input from some sliders and transforms and sends it to the quad-copter motors through I2C and virtual serial port.
The problem that I'm having is that I want to be able to control the engines either individually or in pairs, so I can achieve motion in all directions. But since I can't have multiple inputs at the same time for each engine, I think I might need a case structure. What I would like to do is have a scenario where depending on whether an input changes and how (either for an individual motor or a group), the case structure switches to that case and takes the inputs specified for that particular case. What I'm thinking is having 10 or so sliders, 1 for each engine, and then 1 each for groups like 1 & 2, 3 & 4 and 1 for all, and depending on whether they change and how, switch to the case where only those particular engines change speed.
Can you please help me out with that? Thank you.
03-25-2013 08:54 AM - edited 03-25-2013 08:54 AM
03-25-2013 12:16 PM
Hi GerdW,
Thanks for the reply. Your solution is good, but I want it to have a slider for each individual motor and also for each group of motors, and when one of them changes, for the case structure to be selected appropriately so it sends the same output to only one motor or more.
Basically, what I want to do as a final step is to integrate the Kinect Development Kit into the program and control the quad-copter using a manipulation of the coordinates of a selected joint or skeleton point. This bit with the sliders is sort-of an intermediate point for me to see if I can reliably do this motor grouping control.
Constantin
03-25-2013 12:23 PM
I want it to determine on its own which case it is, 'cause me having to select it is not good. I was thinking about using some shift registers in a loop to determine whether there's a change from one iteriation to the other in each slider and if there is, then switch to the case that involves that one. How does that sound?
03-25-2013 12:36 PM
03-25-2013 12:45 PM
Cool. I'll have a go and see what happens. Thanks a lot again.
03-25-2013 12:52 PM
If you are just looking for when the values change you can use the event structure with a value change event for each control.
03-25-2013 02:04 PM
I've managed to do it, just the way I want. What do you guys think. Is there a more elegant way of achieving this?
@Mark: I'm not too familiar with the event structure.
03-25-2013 02:11 PM - edited 03-25-2013 02:15 PM
That is one way to accomplish it. I would probably use the event structure. It is not that difficult to use. It is very similar to the case structure.
I would also caution you on comparing two floating point numbers. Due to rounding it is possible that you will subtract two values which are essentially equal but return a non-zero result. You should use the "In Range" VI and set some tolerance value which indicates the numbers are equal.
One last item, do you want your shift registers to be unitialized? If they are unitialized they will retain the values from the last execution of this VI. You may not want that since I assume you would want your motors to be off in the initial state.
03-25-2013 02:51 PM
Alright, so this is the final version that I'm going to test tomorrow in the lab, see if it actually works. I know it's not too elegant, but for now it does the job, I think.