Go to Post And if you are unhappy about me using "robot", let me break your heart over what we've done to the word "cheesecake". - Foster [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 18-11-2014, 16:12
jman4747's Avatar
jman4747 jman4747 is offline
Just building robots
AKA: Josh
FRC #4080 (Team Reboot)
Team Role: CAD
 
Join Date: Apr 2013
Rookie Year: 2011
Location: Atlanta GA
Posts: 422
jman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond repute
Swerve VI based on the 2011 paper & excel by Ether

So I wanted to do the math in this paper/spreadsheet: http://www.chiefdelphi.com/media/papers/2426 in LabVIEW but some of the output values don't match up to the spreadsheet, and only when I try to add in a non-zero clockwise rotation input. I based the calculations on the paper: http://www.chiefdelphi.com/media/papers/download/3028.
Attached Thumbnails
Click image for larger version

Name:	Swerve VI FP #1.JPG
Views:	101
Size:	77.8 KB
ID:	17477  Click image for larger version

Name:	Swerve excel #1.JPG
Views:	66
Size:	66.6 KB
ID:	17478  Click image for larger version

Name:	Swervw VI FP#2.JPG
Views:	54
Size:	82.7 KB
ID:	17479  Click image for larger version

Name:	Swerve excel #2.JPG
Views:	40
Size:	60.9 KB
ID:	17480  Click image for larger version

Name:	Swerve VI BD.JPG
Views:	59
Size:	204.4 KB
ID:	17481  

__________________
---------------------
Alumni, CAD Designer, machinist, and Mentor: FRC Team #4080

Mentor: Rookie FTC Team "EVE" #10458, FRC Team "Drewbotics" #5812

#banthebag
#RIBMEATS
#1620
  #2   Spotlight this post!  
Unread 18-11-2014, 18:19
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Swerve VI based on the 2011 paper & excel by Ether

Quote:
Originally Posted by jman4747 View Post
So I wanted to do the math in this paper/spreadsheet: http://www.chiefdelphi.com/media/papers/2426 in LabVIEW but some of the output values don't match up to the spreadsheet, and only when I try to add in a non-zero clockwise rotation input. I based the calculations on the paper: http://www.chiefdelphi.com/media/papers/download/3028.
You clipped your wheel speeds instead of normalizing them.

Clipping the wheel speeds makes them no longer kinematically correct.

See the discussion of normalization on page 2 of this doc.


  #3   Spotlight this post!  
Unread 19-11-2014, 14:00
Tom Line's Avatar
Tom Line Tom Line is offline
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,554
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: Swerve VI based on the 2011 paper & excel by Ether

You are running a lot of calculations in parallel. Some rely on others. You may want to double check that.
  #4   Spotlight this post!  
Unread 19-11-2014, 14:14
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Swerve VI based on the 2011 paper & excel by Ether

Quote:
Originally Posted by Tom Line View Post
You are running a lot of calculations in parallel. Some rely on others. You may want to double check that.
Maybe so, I'm not a LabVIEW guru. But his immediate problem (as shown in his third attachment Swervw VI FP#2.JPG), is that he is clipping the wheel speeds instead of normalizing them.


Attached Thumbnails
Click image for larger version

Name:	clipping.png
Views:	70
Size:	90.9 KB
ID:	17484  Click image for larger version

Name:	normalize.png
Views:	38
Size:	17.3 KB
ID:	17485  
  #5   Spotlight this post!  
Unread 19-11-2014, 14:48
jman4747's Avatar
jman4747 jman4747 is offline
Just building robots
AKA: Josh
FRC #4080 (Team Reboot)
Team Role: CAD
 
Join Date: Apr 2013
Rookie Year: 2011
Location: Atlanta GA
Posts: 422
jman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond repute
Re: Swerve VI based on the 2011 paper & excel by Ether

Thank you Ether. I updated it as shown. It's outputs are concurrent with those of the spreadsheet. However now adding a gyro angle seems to produce incorrect values. I would expect gyro angle 180 and FWD +1 (STR and RCW are 0) to produce a wheel angle of 180 not 126.76. I would also expect gyro angle of 179 to produce something close to that instead of -175.94 for wheel angles if this LabVIEW implementation were correct.

Also the values are computed in order, that is to say that if D is equal to C*Pi and C = A*B it will wait to get A & B compute C, compute C*Pi then give D. Nothing happens with D until everything it is dependant on happens. Or that's what I observed at least.
Attached Thumbnails
Click image for larger version

Name:	Swerve VI BD #2.JPG
Views:	30
Size:	226.5 KB
ID:	17486  
__________________
---------------------
Alumni, CAD Designer, machinist, and Mentor: FRC Team #4080

Mentor: Rookie FTC Team "EVE" #10458, FRC Team "Drewbotics" #5812

#banthebag
#RIBMEATS
#1620
  #6   Spotlight this post!  
Unread 19-11-2014, 15:07
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Swerve VI based on the 2011 paper & excel by Ether

Ether's worry about clipping vs. normalization is valid, and you do need to correct your code to handle it properly, but I don't think the input values you're testing would cause an issue in this particular case.

Quote:
Originally Posted by jman4747 View Post
Also the values are computed in order, that is to say that if D is equal to C*Pi and C = A*B it will wait to get A & B compute C, compute C*Pi then give D. Nothing happens with D until everything it is dependant on happens. Or that's what I observed at least.
Because you have separated the processing steps into disconnected parts, they will not necessarly run in the order you expect. The output-clipping section will use whatever values are in the local variables, whether or not the speed-mixing section has completed and updated the variables first.

Your first task in correcting the VI is to eliminate all local variables. Let LabVIEW do what it does best. Instead of storing a value in "A" somewhere and reading "A" elsewhere, just run a wire from the source to the destination. You can -- and should -- wire a single source to multiple destinations.

Then you can implement the necessary normalization. It's a lot easier than you're making it look, and it's even easier in LabVIEW than the C code implies.

Finally, you can do some serious optimization of the math. There's no need to have four copies each of "180" and "π" when converting from radians to degrees. You can just do the 180/π division once and multiply each angle by that result.
  #7   Spotlight this post!  
Unread 19-11-2014, 15:35
Jared's Avatar
Jared Jared is offline
Registered User
no team
Team Role: Programmer
 
Join Date: Aug 2013
Rookie Year: 2012
Location: Connecticut
Posts: 602
Jared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond repute
Re: Swerve VI based on the 2011 paper & excel by Ether

From my knowledge of LabVIEW, I think it's pretty much impossible to be sure of the order of the calculations will happen.

You should try to do it without the variables.
  #8   Spotlight this post!  
Unread 19-11-2014, 16:22
jman4747's Avatar
jman4747 jman4747 is offline
Just building robots
AKA: Josh
FRC #4080 (Team Reboot)
Team Role: CAD
 
Join Date: Apr 2013
Rookie Year: 2011
Location: Atlanta GA
Posts: 422
jman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond repute
Re: Swerve VI based on the 2011 paper & excel by Ether

I admit the locals were mainly to help me understand it better while I was writing it the first time and are clearly slower than wiring it. I also think it looked a tad cleaner. As for the execution, I get the same values either way. That said I thought things waited for their dependencies after watching it run while "Highlight Execution" was on and all the values looked like they updated after their dependencies did. Though I shouldn't have assumed.
__________________
---------------------
Alumni, CAD Designer, machinist, and Mentor: FRC Team #4080

Mentor: Rookie FTC Team "EVE" #10458, FRC Team "Drewbotics" #5812

#banthebag
#RIBMEATS
#1620

Last edited by jman4747 : 19-11-2014 at 16:25.
  #9   Spotlight this post!  
Unread 19-11-2014, 16:44
Tom Line's Avatar
Tom Line Tom Line is offline
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,554
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: Swerve VI based on the 2011 paper & excel by Ether

Quote:
Originally Posted by Jared View Post
From my knowledge of LabVIEW, I think it's pretty much impossible to be sure of the order of the calculations will happen.

You should try to do it without the variables.
The way that he has his code structured, that is correct. To sequentially compute his solutions, he needs the different structures connected in some way. There are many ways to do that. He can put the dependent calculations in a flat sequence structure. Or he could 'cheat' and throw them in while loops that are connected by wires, with each while loop only executing once. Or he could enclose each 'group' in a descriptive VI, and wire them together using the error wire so they execute in sequence.
  #10   Spotlight this post!  
Unread 19-11-2014, 17:16
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,756
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Swerve VI based on the 2011 paper & excel by Ether

Just a quick comment on the difference between variables and wires.

A wire transfers a data value with sequencing. Variables transfer a data value without sequencing.

Another way to think of this is that wires do not have a value until they are written to. Once written to, the wire will propagate the value to all consumers, retaining it as long as necessary for the consumer to begin execution -- at which point it no longer has a value. Variables, global and local alike, have a value at all times. Before being written to, they have a default value. There is no waiting or sequencing. They always return their current value.

Another difference is that a wire can have only one writer and all other connections must be readers. Variables may have many writers, many readers.


Multiple writers and lack of expected sequencing are the cause of race conditions in parallel programming. Wires have neither of these issues.

As for determining the order of execution of code such as this. Since these are simple expressions, the LV clumping algorithm will turn each section of code into a series of instructions, there is no need for data flow scheduling for simple operations. Likewise, there are no loops, no asynchronous operations that would benefit from multiple cores. So the compiler will arbitrarily determine an order and the end result will be the same each time ... until the code is regenerated. Since you didn't specify any preference, the compiler is free to reorder the code according to memory optimizations, cache alignment, order that the code was written in, or phase of the moon.

Hope this helps.
Greg McKaskle
  #11   Spotlight this post!  
Unread 19-11-2014, 17:43
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Swerve VI based on the 2011 paper & excel by Ether

Quote:
Originally Posted by jman4747 View Post
Thank you Ether. I updated it as shown. It's outputs are concurrent with those of the spreadsheet. However now adding a gyro angle seems to produce incorrect values. I would expect gyro angle 180 and FWD +1 (STR and RCW are 0) to produce a wheel angle of 180 not 126.76.
Are you still having this issue with your code, after making the sequencing changes that other posters have recommended?

If so, here are the intermediate values you should be getting. This may help you track down where the error is:

Code:
L=24 W=24

FWDfc=1 STRfc=0

Q=180

FWDrc=-1 STRrc=1.02068e-011

RCW=0

A=1.02068e-011 B=1.02068e-011 C=-1 D=-1

wa1=180 wa2=180 wa3=180 wa4=180

ws1=1 ws2=1 ws3=1 ws4=1

ws1n=1 ws2n=1 ws3n=1 ws4n=1
Quote:
I would also expect gyro angle of 179 to produce something close to that instead of -175.94 for wheel angles if this LabVIEW implementation were correct.
For FWDfc=1 STRfc=0 RCW=0, a gyro angle of +179 results in wheel angles of -179* (both gyro and wheel angles begin measured clockwise):

Code:
L=24 W=24

FWDfc=1 STRfc=0

Q=179

FWDrc=-0.999848 STRrc=-0.0174524

RCW=0

A=-0.0174524 B=-0.0174524 C=-0.999848 D=-0.999848

wa1=-179 wa2=-179 wa3=-179 wa4=-179

ws1=1 ws2=1 ws3=1 ws4=1

ws1n=1 ws2n=1 ws3n=1 ws4n=1

* note the last paragraph in the paper where reversing wheel speeds is discussed

Last edited by Ether : 19-11-2014 at 17:47.
  #12   Spotlight this post!  
Unread 19-11-2014, 18:00
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,600
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Swerve VI based on the 2011 paper & excel by Ether

If you posted your code as VIs or VI Snippets, it would be much easier for people to help. Code (of any type) is hard to debug visually.
  #13   Spotlight this post!  
Unread 19-11-2014, 18:47
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Swerve VI based on the 2011 paper & excel by Ether

Quote:
Originally Posted by Joe Ross View Post
If you posted your code as VIs or VI Snippets, it would be much easier for people to help. Code (of any type) is hard to debug visually.
VI Snippets: Yes.

VIs: No. Cannot view them without LabVIEW installed.


  #14   Spotlight this post!  
Unread 20-11-2014, 08:05
jman4747's Avatar
jman4747 jman4747 is offline
Just building robots
AKA: Josh
FRC #4080 (Team Reboot)
Team Role: CAD
 
Join Date: Apr 2013
Rookie Year: 2011
Location: Atlanta GA
Posts: 422
jman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond reputejman4747 has a reputation beyond repute
Re: Swerve VI based on the 2011 paper & excel by Ether

Quote:
Originally Posted by Ether View Post
Are you still having this issue with your code, after making the sequencing changes that other posters have recommended?

If so, here are the intermediate values you should be getting. This may help you track down where the error is
Thank you for the numbers I was able to see the error was in the gyro correction of the joystick inputs. The gyro angle input is supposed to be in radians. I looked at the WPI holonomic VI and realized this. The sequencing changes (going to all wires) didn't change any output values which is why I was confused.

Also do formula nodes execute faster than the equivalent code on the block diagram?
__________________
---------------------
Alumni, CAD Designer, machinist, and Mentor: FRC Team #4080

Mentor: Rookie FTC Team "EVE" #10458, FRC Team "Drewbotics" #5812

#banthebag
#RIBMEATS
#1620
  #15   Spotlight this post!  
Unread 20-11-2014, 08:25
Gdeaver Gdeaver is offline
Registered User
FRC #1640
Team Role: Mentor
 
Join Date: Mar 2004
Rookie Year: 2001
Location: West Chester, Pa.
Posts: 1,370
Gdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond repute
Re: Swerve VI based on the 2011 paper & excel by Ether

When you get this working the next step is to determine the shortest path to turn including a change of drive rotation. You will need a working prototype to Do the steering pids. We have so far not closed the loop for drive velocity.
Closed Thread


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 02:50.

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