Go to Post the truth is that a 'bot is only as complicated as you make it. - RogerR [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 26-03-2011, 15:16
siggy2xc siggy2xc is offline
Registered User
AKA: Tyler Siegrist
FRC #1756 (Argos)
Team Role: Programmer
 
Join Date: Mar 2010
Rookie Year: 2009
Location: peoria
Posts: 70
siggy2xc is an unknown quantity at this point
Simulate robot drive

My robotics team will not be meeting too often but I would still like to work on writing various VIs that we could use next year. Since I wont have a robot to test my code on I need to make a simulator to test my code on. Is there a VI already made that can simulate a robot moving on a 2D plane? If not could I have some help getting started?
Reply With Quote
  #2   Spotlight this post!  
Unread 27-03-2011, 21:32
j.cole j.cole is offline
Registered User
FRC #0379
 
Join Date: Jan 2010
Location: Girard
Posts: 159
j.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud of
Re: Simulate robot drive

there sadly isn't a code out there to do this. What your asking isn't technically possible to what I understand.

1 You couldn't possibly get accurate values to move the robot on that 2d plane at an accurate speed. There are so many variables present that it would be to ridiculous to do accurately.

2 You couldn't use the WPI Library because you would have to be connected to a cRIO (correct me if I'm wrong)

I've been wanting to do this since I started using labview. It would make autonomous incredibly easy if it were possible.
__________________

It's not normally a good idea to give a programmer a drill but rules are made to be broken.
Reply With Quote
  #3   Spotlight this post!  
Unread 27-03-2011, 22:26
Fletch1373's Avatar
Fletch1373 Fletch1373 is offline
Registered User
AKA: Fletch
FRC #3181 (Panthers)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2004
Location: Rochester, NY
Posts: 248
Fletch1373 has much to be proud ofFletch1373 has much to be proud ofFletch1373 has much to be proud ofFletch1373 has much to be proud ofFletch1373 has much to be proud ofFletch1373 has much to be proud ofFletch1373 has much to be proud ofFletch1373 has much to be proud ofFletch1373 has much to be proud ofFletch1373 has much to be proud of
Re: Simulate robot drive

It's not that it's not possible. It's VERY possible, just difficult to implement. Such a project has been mentioned in a few different threads here since last year but to my knowledge hasn't gained much ground.

1) You are mostly correct in that the values you retrieve from virtual sensors wouldn't be nearly as accurate, but simple driving and controlling of motors should be simple enough once the simulator is properly built.

2) You would be able to use the WPI library(but it would have to be rewritten to control the virtual robot instead of the actual cRio).
__________________
Student:
<04: FRC0213> <05-08: FRC1373>
Mentor:
<09-10: FRC0809> <11-12: FRC3555> <12-14: FRC0073> <15-??: FRC3181>
Volunteer:
<FTAA> <CSA> <Defense Coordinator> <Scorekeeper> <Robot Inspector> <Official Scorer>
2016 Tour:
CTWAT [DefCoord] > Pittsburgh[Mentor/DefCoord] > TVR[FTAA] > FLR[CSA] > NE DCMP[CSA] > CMP[CSA]
Reply With Quote
  #4   Spotlight this post!  
Unread 28-03-2011, 07:23
siggy2xc siggy2xc is offline
Registered User
AKA: Tyler Siegrist
FRC #1756 (Argos)
Team Role: Programmer
 
Join Date: Mar 2010
Rookie Year: 2009
Location: peoria
Posts: 70
siggy2xc is an unknown quantity at this point
Re: Simulate robot drive

Ok, my mentor built a simulator of a robot to test my auto-orient code but sadly I never got a copy of that code. He doesn't help with robotics in the off season so hopefully I will be able to learn this next year.
Reply With Quote
  #5   Spotlight this post!  
Unread 28-03-2011, 08:07
Chris Hibner's Avatar Unsung FIRST Hero
Chris Hibner Chris Hibner is offline
Eschewing Obfuscation Since 1990
AKA: Lars Kamen's Roadie
FRC #0051 (Wings of Fire)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1997
Location: Canton, MI
Posts: 1,488
Chris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond repute
Re: Simulate robot drive

Quote:
Originally Posted by j.cole View Post
there sadly isn't a code out there to do this.
Happily, there actually is. See the following link:

http://www.chiefdelphi.com/media/papers/2331 The search button is your friend

I'm actually doing a presentation at the FIRST Robotics Conference in St. Louis on this topic.
__________________
-
An ounce of perception is worth a pound of obscure.
Reply With Quote
  #6   Spotlight this post!  
Unread 28-03-2011, 21:55
coollint's Avatar
coollint coollint is offline
Registered User
AKA: Ryan Keller
FRC #0075 (Roboraiders)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2006
Location: Hillsborough, NJ
Posts: 20
coollint is an unknown quantity at this point
Re: Simulate robot drive

Can someone here help me with using this program, because it seems like no matter how hard i try i can successfully use it correctly. The problem i am having is switching each pwms power over a specific amount of time; it seems like i have tried everything, so if someone could help me that would be great
__________________


2013:
Mount Olive Semi-Finalists with 1367 and 3929 and Chairmans Award Winner
Reply With Quote
  #7   Spotlight this post!  
Unread 29-03-2011, 00:13
siggy2xc siggy2xc is offline
Registered User
AKA: Tyler Siegrist
FRC #1756 (Argos)
Team Role: Programmer
 
Join Date: Mar 2010
Rookie Year: 2009
Location: peoria
Posts: 70
siggy2xc is an unknown quantity at this point
Re: Simulate robot drive

That program isn't quite what I wanted, but it definitely will help me on getting started. I'll try making it a simple vi where you just put in pwm values for some motors and post it if/when that happens. Thanks for the help!!!
Reply With Quote
  #8   Spotlight this post!  
Unread 29-03-2011, 07:40
Chris Hibner's Avatar Unsung FIRST Hero
Chris Hibner Chris Hibner is offline
Eschewing Obfuscation Since 1990
AKA: Lars Kamen's Roadie
FRC #0051 (Wings of Fire)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1997
Location: Canton, MI
Posts: 1,488
Chris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond repute
Re: Simulate robot drive

Quote:
Originally Posted by coollint View Post
Can someone here help me with using this program, because it seems like no matter how hard i try i can successfully use it correctly. The problem i am having is switching each pwms power over a specific amount of time; it seems like i have tried everything, so if someone could help me that would be great
Post what you are trying to do, or send me a PM and I'll give you an e-mail address that you can send it to. I'll help you get it going.
__________________
-
An ounce of perception is worth a pound of obscure.
Reply With Quote
  #9   Spotlight this post!  
Unread 29-03-2011, 09:01
Chris Hibner's Avatar Unsung FIRST Hero
Chris Hibner Chris Hibner is offline
Eschewing Obfuscation Since 1990
AKA: Lars Kamen's Roadie
FRC #0051 (Wings of Fire)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1997
Location: Canton, MI
Posts: 1,488
Chris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond repute
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.
__________________
-
An ounce of perception is worth a pound of obscure.

Last edited by Chris Hibner : 29-03-2011 at 09:05.
Reply With Quote
  #10   Spotlight this post!  
Unread 29-03-2011, 15:16
siggy2xc siggy2xc is offline
Registered User
AKA: Tyler Siegrist
FRC #1756 (Argos)
Team Role: Programmer
 
Join Date: Mar 2010
Rookie Year: 2009
Location: peoria
Posts: 70
siggy2xc is an unknown quantity at this point
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:
Attached Thumbnails
Click image for larger version

Name:	Robot sim.png
Views:	6
Size:	3.2 KB
ID:	10506  
Reply With Quote
  #11   Spotlight this post!  
Unread 31-03-2011, 19:41
kamocat's Avatar
kamocat kamocat is offline
Test Engineer
AKA: Marshal Horn
FRC #3213 (Thunder Tech)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 2008
Location: Tacoma
Posts: 894
kamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nice
Send a message via AIM to kamocat Send a message via MSN to kamocat
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.
__________________
-- Marshal Horn
Reply With Quote
  #12   Spotlight this post!  
Unread 31-03-2011, 21:54
siggy2xc siggy2xc is offline
Registered User
AKA: Tyler Siegrist
FRC #1756 (Argos)
Team Role: Programmer
 
Join Date: Mar 2010
Rookie Year: 2009
Location: peoria
Posts: 70
siggy2xc is an unknown quantity at this point
Re: Simulate robot drive

How do you make your code work? both the default and final picture are blank.
Reply With Quote
  #13   Spotlight this post!  
Unread 31-03-2011, 23:37
kamocat's Avatar
kamocat kamocat is offline
Test Engineer
AKA: Marshal Horn
FRC #3213 (Thunder Tech)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 2008
Location: Tacoma
Posts: 894
kamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nice
Send a message via AIM to kamocat Send a message via MSN to kamocat
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.
__________________
-- Marshal Horn
Reply With Quote
  #14   Spotlight this post!  
Unread 01-04-2011, 00:09
siggy2xc siggy2xc is offline
Registered User
AKA: Tyler Siegrist
FRC #1756 (Argos)
Team Role: Programmer
 
Join Date: Mar 2010
Rookie Year: 2009
Location: peoria
Posts: 70
siggy2xc is an unknown quantity at this point
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).
Reply With Quote
  #15   Spotlight this post!  
Unread 01-04-2011, 02:32
kamocat's Avatar
kamocat kamocat is offline
Test Engineer
AKA: Marshal Horn
FRC #3213 (Thunder Tech)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 2008
Location: Tacoma
Posts: 894
kamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nice
Send a message via AIM to kamocat Send a message via MSN to kamocat
Re: Simulate robot drive

Okay, here's an improved version.
  • Front panel is more intuitive
  • VI works with default values
  • no longer runs at full blast (which means less points are plotted)
  • distance calculation is time-based

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.
Attached Files
File Type: zip simulate robot drive.zip (45.7 KB, 12 views)
__________________
-- Marshal Horn

Last edited by kamocat : 01-04-2011 at 02:34.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 04:33.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi