View Full Version : Move Robot a set angle
smarthimandrew
01-02-2013, 14:24
Hi,
In order to align my team's robot to the target, we need to move the robot a certain number of degrees.
We have 4 Motor Drive with encoders on a cimple gearbox. We have already written the code to figure out how many degrees to move, but we cannot figure out how that corresponds to wheel movement. I would assume that it is dependent on wheel size and robot size.
Wheels:
8" Diameter, 25.1327412" circumference
http://www.andymark.com/product-p/am-0569.htm
Robot:
I am unsure as to how wide the robot is, because I don't have it in front of me right now, but an explanation of how to use the width (If necessary) would be helpful.
My question is, How do I figure out how much to move the wheels?
You'd need to know the behavior of the wheels while your robot turns, then use that model to determine the amount of turns, then use that to count the number of ticks while driving in a turning motion.
It might be easier to use a gyro sensor.
Wheels:
8" Diameter, 25.1327412" circumference
http://www.andymark.com/product-p/am-0569.htm
My question is, How do I figure out how much to move the wheels?
It's a skid-steer vehicle, so it depends on the phase of the moon and yesterday's lottery numbers.
But seriously, you could use a gyro (as the previous poster suggested), or you could do some simple experiments and measure how much vehicle rotation you get vs how much the wheels turned. Do that under various conditions (like turning speed) and either fit a model to the data or prepare a lookup table. Make sure you use the same carpet as competition when running these tests, and with the competition weight.
sloteera
01-02-2013, 14:42
Man,
If you turn your robot using just one side of your drive train, you can calculate the arc of the circle by counting the enconder pulses.
The radius will be the distance between both side of drive train.
Man,
If you turn your robot using just one side of your drive train, you can calculate the arc of the circle by counting the enconder pulses.
The radius will be the distance between both side of drive train.
Ya think? Have you actually tried this?
sloteera
01-02-2013, 14:47
Never lol.
But I guess that could be an solution.
The arc perimeter is 2*3,1415*R / angle
You can measure your linear distance (perimeter circle) with an encoder.
smarthimandrew
01-02-2013, 14:52
Man,
If you turn your robot using just one side of your drive train, you can calculate the arc of the circle by counting the enconder pulses.
The radius will be the distance between both side of drive train.
Thanks, I'll try this
sloteera
01-02-2013, 14:53
Please, give us an feedback if this works after you finish!!
The arc perimeter is 2*3,1415*R / angle
No, it's angle*R ... (where "angle" is in radians)
You can measure your linear distance (perimeter circle) with an encoder.
It's a skid-steer vehicle, so the wheel is slipping when turning. It's also not perpendicular to the direction of travel. Thus my semi-humorous remark in my earlier post.
theawesome1730
01-02-2013, 16:09
Like many others have said, a gyro would be the best bet. You can use them for more than just positioning too. We use them to keep us driving in straight lines since doing that based on encoders alone is near impossible. You also may consider a range finder in addition to help your robot know where it is in relation to the field for greater accuracy. Just remember to have your gyro automatically recalibrate itself at the begging of autonomous for best results as they tend to wander over a course of time.
sloteera
01-02-2013, 16:14
2*3,1415 = 2*PI = 360 radians = angle ( in radians )
So
360 radians * R = angle (entire circle)*R
360 radians = Full Perimeter
x radians = arc Perimeter
So
Arc Perimeter= 2*Pi*R / angle wished ( in radians )
And, When I say "arc perimeter" I mean about the linear distance of This segment, so the encoder could return this measurement
I guess...
Hugh Meyer
01-02-2013, 16:22
http://www-personal.umich.edu/~johannb/Papers/pos96rep.pdf
This link points to a document that explains how to do localization. The PDF pages 19 & 20 show the formula to convert wheel movement into position. For this to work your robot would need to pivot about the center wheels. If they are dropped some this often happens.
This isn't the total solution you are looking for but I think it will get you moving in the right direction.
If you have a gyro there is some default code that does all of this for you. Look in the targeting example code.
-Hugh
...
Two things:
1) There are not 360 radians in a full perimeter.
2) Look at your formula. It says that as the angle_wished gets larger, the arc_perimeter gets smaller.
For this to work your robot would need to pivot about the center wheels. If they are dropped some this often happens.
Yeah, if it's a dropped-center 6WD with sufficient drop and with most of the weight over the center wheels it might work. The OP didn't mention 6WD though.
virtuald
02-02-2013, 00:43
We had a lot of success a few years ago with a gyro, I'd recommend it.
bvisness
02-02-2013, 16:09
I'd recommend the gyro as well. We found the provided gyro sensors to be very responsive and accurate. Easy to program too!
Using a gyro, it would be pretty easy to set up a PID loop like in the attached image.
Using a gyro, it would be pretty easy to set up a PID loop like in the attached image.
Unless the 2013 LabVIEW PID now has support for "continuous" process variables (2011 didn't), your diagram won't work.
bvisness
02-02-2013, 18:11
What do you mean by "continuous" process variables? This should get the current gyro heading every time the loop runs and compare that to the setpoint. (And this is just a 2-minute example anyhow...)
What do you mean by "continuous" process variables? This should get the current gyro heading every time the loop runs and compare that to the setpoint. (And this is just a 2-minute example anyhow...)
What do you think that PID in your diagram will do if the gyro is reading 359 degrees and your driver is commanding zero degrees ?
bvisness
02-02-2013, 18:22
Ah, I see what you mean. I didn't say this was a perfect example, I just wanted to quickly demonstrate how one could zero in on an angle using a gyro and PID.
Ah, I see what you mean. I didn't say this was a perfect example, I just wanted to quickly demonstrate how one could zero in on an angle using a gyro and PID.
If you had to make this work, how would you go about fixing this problem?
bvisness
02-02-2013, 18:32
If you had to make this work, how would you go about fixing this problem?
Well, for the thread-starter's situation, I would initialize the setpoint as current heading + desired change. Then it wouldn't matter if the variable was continuous or not. (Assuming I'm remembering correctly that the gyro heading does not reset to 0 when it makes a full rotation.)
On the other hand, if I wanted to turn the robot to an absolute heading, I would probably...you know what, I'm not sure. All my ideas thus far would eliminate the problem of whirling in circles when going from, say, 2520 degrees to 45. But all my ideas would not fix the problem of going from 359 to 0.
thephpdev
02-02-2013, 19:05
You could use a PID loop with the x-offset in pixels as the input of the image, and have the output move the wheels.
You could use a PID loop with the x-offset in pixels as the input of the image, and have the output move the wheels.
How fast can your vision processing compute that image pixel offset ?
Greg McKaskle
03-02-2013, 09:53
On the other hand, if I wanted to turn the robot to an absolute heading, I would probably...you know what, I'm not sure. All my ideas thus far would eliminate the problem of whirling in circles when going from, say, 2520 degrees to 45. But all my ideas would not fix the problem of going from 359 to 0.
Circular coordinate systems have many values that encode the same angle.
Mod or Quotient and Remainder will collapse them into those represented in a single circle. As you noted, there are still two useful solutions to your 359 move to 0. You can move 359 degrees one direction or 1 degree the other.
You usually want to select the movement with the smaller absolute value. So you need mod, and you need to consider both the positive movement and negative movement. For crab systems or turrets, there is usually a further restriction that may invalidate one of the solutions -- cables only stretch and twist by so much.
I'd highly recommend you develop your input filter as a separate VI and test it for the full range of values it is to deal with. Often it is useful to plot the output versus input and sweep across the range of values at some resolution.
Greg McKaskle
bvisness
03-02-2013, 16:31
Thanks for the advice! Granted, I'm not the one who started the thread, but I hope the info is useful to people who are attempting to do this.
bvisness
03-02-2013, 18:16
Well, compwiztobe (http://www.chiefdelphi.com/forums/member.php?u=26035) saves the day again with this awesome VI. I worked with him to get this written up; it takes a "continuous" gyro input and computes the appropriate setpoint to use in a PID loop. I've attached the VI and an example image.
Well, compwiztobe (http://www.chiefdelphi.com/forums/member.php?u=26035) saves the day again with this awesome VI. I worked with him to get this written up; it takes a "continuous" gyro input and computes the appropriate setpoint to use in a PID loop. I've attached the VI and an example image.
Please post a PNG or GIF screenshot of the vi, for those of us who don't have LabVIEW installed (yet). Thanks.
To add to Ether's recommendation.
I was teaching how to use encoders and applying geometry and trigonometry. One of the tasks I had them figure out is to make the robot turn a certain angle using left and right encoders.
They were successful, but due to the slip-n-slide nature of your drive train, it really is by chance (aka lottery and moon phase). It was within about 10˚ of where it should have been.
Of course, a better solution (as also mentioned) would be to use the included gyro. It's easy to wire (have a spare PWM Cable?), easy to program (They have an example on how to use it), and easy to use (output is already in degrees).
sloteera
04-02-2013, 05:38
It's a skid-steer vehicle, so it depends on the phase of the moon and yesterday's lottery numbers.
But seriously, you could use a gyro (as the previous poster suggested), or you could do some simple experiments and measure how much vehicle rotation you get vs how much the wheels turned. Do that under various conditions (like turning speed) and either fit a model to the data or prepare a lookup table. Make sure you use the same carpet as competition when running these tests, and with the competition weight.
You right Ether, I need to agree with you.
I've got little confused before. Now I understood why what I proposed wouldn't work.
Sorry.
Jcbconway
04-02-2013, 21:32
We came up with an algorithm to get heading based of of 2 wheels (encoders) by using an arc tangent. basically, you integrate the encoder to get your left and righ distance. subract the greater distance from the lesser distance and that is your arc length. then knwong the space between the wheels you can calculate the inverse arc tangent of your arc/wheel spacing. I however cannot confirm the acuracy of this system since it has not been fully tested and will not be fully tested as we no longer need to do this.
nighterfighter
04-02-2013, 21:48
We came up with an algorithm to get heading based of of 2 wheels (encoders) by using an arc tangent. basically, you integrate the encoder to get your left and righ distance. subract the greater distance from the lesser distance and that is your arc length. then knwong the space between the wheels you can calculate the inverse arc tangent of your arc/wheel spacing. I however cannot confirm the acuracy of this system since it has not been fully tested and will not be fully tested as we no longer need to do this.
In theory reading the distance of the encoders can help you derive (Or in your case, integrate :p ) the angle turned.
The problem arises in the fact that one "tick" of the encoder doesn't necessarily equate to the wheel turning any distance, because the wheel will slip.
It might give you a good estimate though, and that is definitely a good exercise to have students do, it teaches programming. math, and realistic robot behaviors.
bvisness
05-02-2013, 19:44
Here's the screenshot of our VI:
http://i.imgur.com/s8hRKga.png
jacob9706
05-02-2013, 19:53
Hi,
In order to align my team's robot to the target, we need to move the robot a certain number of degrees.
We have 4 Motor Drive with encoders on a cimple gearbox. We have already written the code to figure out how many degrees to move, but we cannot figure out how that corresponds to wheel movement. I would assume that it is dependent on wheel size and robot size.
Wheels:
8" Diameter, 25.1327412" circumference
http://www.andymark.com/product-p/am-0569.htm
Robot:
I am unsure as to how wide the robot is, because I don't have it in front of me right now, but an explanation of how to use the width (If necessary) would be helpful.
My question is, How do I figure out how much to move the wheels?
I did something similar last year but took it to a whole new level. If you can interpret my code, feel free to use it.
The heading is the angular offset relative to the starting position.
https://github.com/jacob9706/HighTekerz2012/blob/master/Util/DeadReckoner.cpp
Here's the screenshot of our VI:
http://i.imgur.com/s8hRKga.png
Deja Vu
http://www.chiefdelphi.com/forums/showpost.php?p=1021821&postcount=8
bvisness
05-02-2013, 20:01
Deja Vu
http://www.chiefdelphi.com/forums/showpost.php?p=1021821&postcount=8
It's interesting that our solution is so close, but maybe that's because it's so simple. :P
I can personally guarantee that this VI was written as follows: Mentor's brain->messy whiteboard->VI. It's original!
It's interesting that our solution is so close, but maybe that's because it's so simple.
It's simple once you figure it out:)
bvisness
05-02-2013, 20:04
It's simple once you figure it out:)
Right! My first attempt at this took over my screen so quickly that I forgot how it worked as soon as I started testing it.
jacob9706
05-02-2013, 20:57
Deja Vu
http://www.chiefdelphi.com/forums/showpost.php?p=1021821&postcount=8
I have never learned LabView. Sorry, I just saw that and thought it was jibberish :P
Now there is a solution for those who like labview and those who like a typed language!
Also it looks like your link was for a gyro. Mine was for an encoder on each drive wheel. (http://www.chiefdelphi.com/forums/showpost.php?p=1021821&postcount=8)
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.