|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||||
|
||||||
|
Re: Simulate robot drive
I just realized something this morning: the original autonomous simulator only worked if you were using Autonomous Iterative, which is not supported this year. Doh! I'm sure that caused some confusion.
If you go to the link I posted above, you can download the updated simulator which works with like the Autonomous Independent framework. Here's how to use it: 1) Unzip the zip file into a new folder. 2) Double click "autonSim2.vi" to launch LabVIEW and open the simulator. 3) Push the Play button (NOTE: you will get an error the first time you push play, just press "Continue" when the error comes up. NI Reps: I'm not a LabVIEW expert so I have no idea why this error occurs or how to get rid of it - I'd appreciate some help with that). 4) Select auton0.csv when the File Open dialog pops up (Note: the file is ignored - The reason it does this is to give people an example for opening files in LabVIEW so you can control your autonomous routines with data files - but if you don't want to do that, I'm sorry about the inconvenience). 5) The simulation will start running and the robot will drive around in a big circle. Once it's finished, a "Save File" dialog will pop up. Name your output file whatever you want and press Save. If you want, you can open this file up in Excel or Matlab to make plots of the robot path data. Most of the time, the plot on the front panel of autonSim2.vi works just fine. If you can do the above 5 steps, you're in business. Now, here's how to develop autonomous code: 1) In the autonSim2.vi block diagram, double click on the vi reference "SIM AUTON INDEP". 2) Go to the block diagram of SimAutonIndep.vi and drop your autonomous code into this block diagram. NOTE: the autonomous simulator does not use the WPI library (the simulator is running on a PC - not the cRIO). Wire your motor commands to the the Global Variables that are provided. 3) Press play on the front panel of autonSim2.vi I HIGHLY recommend you put your autonomous software in a vi, just like I did in the example with the "BLANK AUTON" vi. This way you can use the same vi in your robot code AND the simulator. On the robot, wire the outputs of your vi into the WPI motor control blocks; in the simulation wire the outputs of your vi into the global variables. Finally, if there are ANY questions or problems, PLEASE let me know. I'm trying to make this as useful as possible for everyone. If you are having a problem, chances are there are others having the same problem. If I can sort through everyone's issues and start fixing them, I can try and make this work better for everyone. Thanks for your help in advance. Last edited by Chris Hibner : 29-03-2011 at 09:05. |
|
#2
|
|||
|
|||
|
Re: Simulate robot drive
I'm trying to improve upon a program i wrote that will make the robot go whatever direction you press the joystick regardless what way it is facing. I'm trying to simulate a robot driving depending on what the PWM values are for a regular 4-wheel 2-motor robot. My mentor wrote a program that looked like it was using the draw rectangle vi then rotating/moving it on a blank picture but i will not see him until next season.
I have very little experience simulating tho so this is a little big for me being a first year programmer P: |
|
#3
|
||||
|
||||
|
Re: Simulate robot drive
If you devote your time to it, that's definitely doable in one summer.
When I was making a simple robot movement simulator, I often used the "Re/Im to Polar" and "Polar to Re/Im", for converting between Cartesian and polar coordinates. (They're found in the "complex" subpallette of Numeric) If you're not already familiar with Sine, Cosine, and Tangent, you should become so. As for actually creating the code, make sure to start with your definition. What do you want to accomplish? What are your inputs (controls)? What are your outputs (indicators)? You can create the front panel of your main VI first, and that will help define your code later. (For example, you can have a VI that has the inputs of speed, direction, acceleration, rate of turn, and elapsed time, and the output of change in position. You know that every one of those inputs makes a difference in the value of the output. Now you just need to figure out WHAT the relationship is, and how you would describe that in a formula.)] I have a brief overview of the process of software development here: http://kamocat.com/programming/development.php It's simple enough to not get lost in, but if you have any questions or need further detail, please ask. |
|
#4
|
|||
|
|||
|
Re: Simulate robot drive
How do you make your code work? both the default and final picture are blank.
|
|
#5
|
||||
|
||||
|
Re: Simulate robot drive
I made this when I was first learning LabVIEW, so I apologize that it's not very intuitive.
First set your initial position. (300,300) is a good place to start. Start the VI with "continuous run". Now click "initialize". This will clear the image, and reset the robot position. Click it again to commence the movement. To move, use the "speeds" sliders. It appears that the left and right are mixed up, so you may want to fix this. One thing to note: At this point in time, I would not consider this an example of impeccable code. It works, and it's readable, but it's not intuitive, and the way it plots points on the picture is inefficient. If it would help to have a better example, I will fix this up for you. |
|
#6
|
|||
|
|||
|
Re: Simulate robot drive
If you could fix up the code I think that would help tremendously. Also would you mind describing what is happening in the relative movement vi? I really appreciate this, I feel like I'm really good at programming hardware in intuitive ways but terrible at creating virtual simulations of what it should do.
But yes I understand sin, cosine, and tangent. But not well enough to fully figure out the swerve drive quite yet (That can wait for awhile since we don't even have a swerve drive built yet). |
|
#7
|
||||
|
||||
|
Re: Simulate robot drive
Okay, here's an improved version.
I made an some options for it to be controlled via Joysticks, but I haven't implemented that yet. (The appropriate VIs are in the HID pallette. Make sure you're targeted to your computer; Human Interface Device drivers aren't available for the cRIO, and so that palette will be hidden.) EDIT: It's still not impeccably documented, but it should be clear what each section does, if not why it works. Last edited by kamocat : 01-04-2011 at 02:34. |
|
#8
|
|||
|
|||
|
Re: Simulate robot drive
Well I now feel stupid w/e seems like a very useful tool. Thanks for all of the hard work that was put into this hopefully I'll get to using it.
|
|
#9
|
||||
|
||||
|
Re: Simulate robot drive
I'm not sure how much it will help with autonomous; anything it can show can be calculated using a drawing.
However, it might be useful as a little code debugger. Run "autonomous independent" while targeted to your computer, and it runs through this? That might be fun. Remember: a simulation is only as realistic as you make it. Don't forget to "check your work" and make sure it describes what is actually happening with the robot on the field. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|