Go to Post However, because they're programmers they just redid the interpolation tables for our motors as opposed to actually fixing the bent shooter. - Nuwanda [more]
Home
Go Back   Chief Delphi > Other > Math and Science
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 25-10-2013, 14:46
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,994
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
Geometry & Trig Quiz



Let XY be a standard (right-handed) Cartesian coordinate system fixed with respect to the field surface.

The center-of-geometry[1] of a 4-wheel crab-drive[2] robot is sitting at coordinates (X0,Y0) and its orientation (longitudinal axis) is "alpha" radians clockwise from the +Y axis.

All 4 wheels are turned to a steering angle "beta" radians clockwise from the longitudal axis of the robot.

The trackwidth of the robot is "W" and the wheelbase is "L".

Find the new steering angle "sigma" necessary to drive the robot in a straight line so that its center-of-geometry is located at point (X1,Y1).


Notes:

[1] "center of geometry" in this context means the center of the rectangle formed by the locations of the 4 wheels

[2] "crab drive" in this context means all 4 wheels are steered to the same angle and are driven at the same speed





Last edited by Ether : 25-10-2013 at 16:36.
Reply With Quote
  #2   Spotlight this post!  
Unread 25-10-2013, 16:55
Aaron.Graeve Aaron.Graeve is offline
Registered User
FRC #1477 (Texas Torque)
Team Role: Alumni
 
Join Date: Jan 2012
Rookie Year: 2012
Location: College Station, Texas
Posts: 103
Aaron.Graeve is a name known to allAaron.Graeve is a name known to allAaron.Graeve is a name known to allAaron.Graeve is a name known to allAaron.Graeve is a name known to allAaron.Graeve is a name known to all
Re: Geometry & Trig Quiz

Given I tried solving this in between lectures, I am not certain of my solution.

First, let us define an angle Phi that is the angle in radians from the +y axis to the vector of intended motion <x1-x0,y1-y0>. Phi is equal to the sum of the two angles Alpha (The angle from +y to the front of the robot) and Sigma (The angle from the front of the robot to the direction of the wheels).

Since both angles are measured clockwise from their respective reference lines, the angles are added together.

Constructing a right triangle with <x1-x0,y1-y0> as the hypotenuse and the legs parallel to the Cartesian axes, we find the Angle from +y to the vector of intended motion to be arctan((x1-x0)/(y1-y0)). This may look odd at first, but the use of the change in x and y terms in the arctangent function is due to measuring the angle with respect to the y axis instead of the x axis.

Phi = arctan((x1-x0)/(y1-y0))
Phi = Alpha + Sigma
Alpha + Sigma = arctan((x1-x0)/(y1-y0))
Sigma = arctan((x1-x0)/(y1-y0)) - Alpha

Additionally, the wheels must be turned Sigma - Beta from their initial configuration. (not that the problem asked for it.)

I disregarded the width and length of the wheelbase because the initial and final coordinates were already based on the center of geometry, meaning I could treat this as an omnidirectional unicycle bot (I challenge someone to make it).

This is my solution for the posted problem; I trust it has errors, but I am not certain where they are, so any critiques or suggestions are welcome.

I have included a somewhat mediocre drawing of what this looks like.
Attached Thumbnails
Click image for larger version

Name:	Trig_challenge.png
Views:	37
Size:	8.1 KB
ID:	15361  
__________________

2016:
Alamo, Bayou, and Lone Star Regional FTAA
2015:
Dallas, Alamo, Bayou, and Lone Star Regional FTAA
2014:
Alamo, Dallas, and Lone Star Regional FTAA
Alamo Regional Robot Inspector
2013:
Einstein Champion and 2013 World Champion (Thanks 1241 & 610), Galileo Division Champion, Razorback Regional Winner, Alamo Regional Semifinalist, Bayou Regional Semifinalist, Lone Star Regional Quarterfinialist
2012:
Curie Division Semifinalist, Lone Star Regional Finalist, Bayou Regional Winner, Alamo Regional Winner
Reply With Quote
  #3   Spotlight this post!  
Unread 26-10-2013, 12:03
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,994
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: Geometry & Trig Quiz

Quote:
Originally Posted by Aaron.Graeve View Post
I disregarded the width and length of the wheelbase because the initial and final coordinates were already based on the center of geometry, meaning I could treat this as an omnidirectional unicycle bot
Good move. I put that in there as a distraction.

Actually, since the bot as described does not rotate, any point on the bot could have been used (as long as it was the same point for both the initial and final coords).


Quote:
Phi = arctan((x1-x0)/(y1-y0))
Phi = Alpha + Sigma
Alpha + Sigma = arctan((x1-x0)/(y1-y0))
Sigma = arctan((x1-x0)/(y1-y0)) - Alpha


This is my solution for the posted problem; I trust it has errors, but I am not certain where they are, so any critiques or suggestions are welcome.
Nice work. Reps to you. You're 95% there...

The formula you gave gives the "correct" angle if y1>y0, but gives the "reverse" angle (180 degrees off) if y1<y0. If y1=y0, it crashes.

For example:

1) if x0=0, y0=0, x1=10, y1=-1, and alpha=90 degrees, the formula gives sigma= -174.3 degrees instead of +5.7 degrees.

2) if x0=0, y0=0, x1=10, y1=0, and alpha=60 degrees, the formula crashes instead of sigma=30 degrees.

There's a simple way fix the formula that does not involve any conditional logic in your code.


Quote:
Additionally, the wheels must be turned Sigma - Beta from their initial configuration
Let's call that angle "delta". Is there a simple formula (not involving conditional logic) that will compute the shortest value for delta? (For example if delta is 270 degrees the formula should give -90 degrees).


Reply With Quote
  #4   Spotlight this post!  
Unread 26-10-2013, 18:51
Aaron.Graeve Aaron.Graeve is offline
Registered User
FRC #1477 (Texas Torque)
Team Role: Alumni
 
Join Date: Jan 2012
Rookie Year: 2012
Location: College Station, Texas
Posts: 103
Aaron.Graeve is a name known to allAaron.Graeve is a name known to allAaron.Graeve is a name known to allAaron.Graeve is a name known to allAaron.Graeve is a name known to allAaron.Graeve is a name known to all
Re: Geometry & Trig Quiz

From my reasoning, the code only crashes due to a division by zero in the arctangent function. This could be fixed by using arcsin ((x1-x0)/sqrt ((x1-x0)^2+(y1-y0)^2)). This crashes if the inital and final positions are the same, but the problem is meaningless if you are already at yor final position.

Regarding the smallest Delta, either a conditional check on the absolute value of Delta being larger than 180 degrees or running the delta through arcsin(sin(Delta)) could do the trick. I know the second suggestion is implemetation dependent and not the ideal method but it is a method that I think will work in most cases.
__________________

2016:
Alamo, Bayou, and Lone Star Regional FTAA
2015:
Dallas, Alamo, Bayou, and Lone Star Regional FTAA
2014:
Alamo, Dallas, and Lone Star Regional FTAA
Alamo Regional Robot Inspector
2013:
Einstein Champion and 2013 World Champion (Thanks 1241 & 610), Galileo Division Champion, Razorback Regional Winner, Alamo Regional Semifinalist, Bayou Regional Semifinalist, Lone Star Regional Quarterfinialist
2012:
Curie Division Semifinalist, Lone Star Regional Finalist, Bayou Regional Winner, Alamo Regional Winner

Last edited by Aaron.Graeve : 26-10-2013 at 19:40.
Reply With Quote
  #5   Spotlight this post!  
Unread 26-10-2013, 21:26
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,994
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: Geometry & Trig Quiz

Quote:
Originally Posted by Aaron.Graeve View Post
This could be fixed by using arcsin ((x1-x0)/sqrt ((x1-x0)^2+(y1-y0)^2)).
That actually made the problem worse. It gives the wrong answer if y1<y0.

For example: If x0=0, y0=0, x1=10, y1=-1, and alpha=90 degrees, that formula gives sigma= -5.7 degrees instead of the correct +5.7 degrees.

There's a simple alternative to arctan(dx/dy) that gives the correct angle for all values of dx and dy except when they are both zero.


Quote:
Regarding the smallest Delta, either a conditional check on the absolute value of Delta being larger than 180 degrees or running the delta through arcsin(sin(Delta)) could do the trick. I know the second suggestion is implemetation dependent and not the ideal method but it is a method that I think will work in most cases.
There's a calculation that produces the smallest angle without conditional logic or trig functions.


Reply With Quote
  #6   Spotlight this post!  
Unread 27-10-2013, 00:41
Aaron.Graeve Aaron.Graeve is offline
Registered User
FRC #1477 (Texas Torque)
Team Role: Alumni
 
Join Date: Jan 2012
Rookie Year: 2012
Location: College Station, Texas
Posts: 103
Aaron.Graeve is a name known to allAaron.Graeve is a name known to allAaron.Graeve is a name known to allAaron.Graeve is a name known to allAaron.Graeve is a name known to allAaron.Graeve is a name known to all
Re: Geometry & Trig Quiz

The simple alternative to atan(dy/dx) wouldn't happen to be atan2(dy, dx), would it? I am unsure if the problem permits us to use computer functions that happen to wrap up the conditonal logic nicely.

Edit: I just saw the thread with StangPS and the video. I see you did live up to your comments about disecting the math. Well played. I feel foolish for reinventing the wheel now.
__________________

2016:
Alamo, Bayou, and Lone Star Regional FTAA
2015:
Dallas, Alamo, Bayou, and Lone Star Regional FTAA
2014:
Alamo, Dallas, and Lone Star Regional FTAA
Alamo Regional Robot Inspector
2013:
Einstein Champion and 2013 World Champion (Thanks 1241 & 610), Galileo Division Champion, Razorback Regional Winner, Alamo Regional Semifinalist, Bayou Regional Semifinalist, Lone Star Regional Quarterfinialist
2012:
Curie Division Semifinalist, Lone Star Regional Finalist, Bayou Regional Winner, Alamo Regional Winner

Last edited by Aaron.Graeve : 27-10-2013 at 02:24.
Reply With Quote
  #7   Spotlight this post!  
Unread 27-10-2013, 10:06
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,994
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: Geometry & Trig Quiz

Quote:
Originally Posted by Aaron.Graeve View Post
The simple alternative to atan(dy/dx) wouldn't happen to be atan2(dy, dx), would it?
Yes it would. atan and atan2 have different behaviors.

atan's range is limited to -90 < atan < +90. So if the problem involves an angle like 95.7 degrees (as in the previously posted example), atan cannot return that value.

atan2's range is -180 <= atan2 <= +180 and it handles the quadrantal angles without crashing. Also, in many implementations (Octave is an example) atan2 handles the arguments (0,0) and returns 0.

You can wrap conditional logic around atan in your own code to produce your own version of atan2, but it's better to use the library version if it's available. Pages 152 thru 158 of P J Plauger's classic 1992 book The Standard C Library shows a reference implementation of atan and atan2.

I don't think you re-invented the wheel. Your diagram and accompanying explanation stated the simplifying assumptions explicitly, used a consistent reference coordinate system, and were very clear and easy to understand.


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 09:32.

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