Log in

View Full Version : Unique ways of controlling your robot (driving)


AmoryG
03-04-2008, 18:23
The 2008 competition is mine and my team's rookie year. This year I was the sole student programmer with about no experience with programming. I received tons of help from my mentors and I was able to help program the robot with their assistence. Because of this a lot of the time I was doing things on my own and I did a lot of experimenting.

With my mentors, we came up with quite a few ways of driving the bot. I won't share the code right away (I need to get it first), but would anyone like to share and explain their methods of controlling the driving of the robot? I'm really curious what you guys did.

These are the things we tried (I'll share the code when I get it)...

1. Double Joystick: very hard to control. We tried a lot to make it more controlable, but it never worked out well.

2. Single Joystick 1: One speed, 4 ways of moving robot. Push the joystick up and it moves forward. Push it down it moves backwards. Left it turns a bit left and right it turns a bit right.

3. Other single joystick controlls: We made a few other single joystick control systems. One we used in the competition.

I apologize in advance if broke some sort of rule :o

EricH
03-04-2008, 18:28
The 2008 competition is mine and my team's rookie year. This year I was the sole student programmer with about no experience with programming. I received tons of help from my mentors and I was able to help program the robot with their assistence. Because of this a lot of the time I was doing things on my own and I did a lot of experimenting.

With my mentors, we came up with quite a few ways of driving the bot. I won't share the code right away (I need to get it first), but would anyone like to share and explain their methods of controlling the driving of the robot? I'm really curious what you guys did.

These are the things we tried (I'll share the code when I get it)...

1. Double Joystick: very hard to control. We tried a lot to make it more controlable, but it never worked out well.

2. Single Joystick 1: One speed, 4 ways of moving robot. Push the joystick up and it moves forward. Push it down it moves backwards. Left it turns a bit left and right it turns a bit right.

3. Other single joystick controlls: We made a few other single joystick control systems. One we used in the competition.

I apologize in advance if broke some sort of rule :oThese are all acceptable in competition and here.

Most teams use the double-stick method. Some use single. Others have been known to use the following:

DDR pad
Steering wheel
R/C controller
Game controller of some form

Herodotus
03-04-2008, 18:30
My favorite form of driving the base of the robot so far has been double joysticks, because it gives a great deal of control, in my opinion. This year, however, we went with a single joystick with the idea that it would leave my other hand free for some push button semi-automatic controls such as u-turns and lane shifting. That hasn't panned out (yet) but with a little bit of work we've gotten our controls working decently well, the single joystick needs a little more tweaking than dual joysticks.

Our joystick itself was fairly unique though(one of a kind as far as I know), what with being a weighted companion cube.

Grant Cox
03-04-2008, 18:53
My personal favorite is a PS2 controller with the USB chicklet. The two analog sticks act the same as joysticks, but it just feels a lot more natural and allows you to have more control than sticks (imo).

fimmel
03-04-2008, 19:48
we attempted a mechanum drive this year but never got the strafing to work right. but we had forward backward on the left y axis and left / right steering on the right x axis (along with strafing on the left x axis but that didn't work like i said) and it made it very easy to drive strait since you could tweak the direction with your right hand and just keep ur left at the speed you like.

i recommend people try this cause its nice and very intuitive

...forest

lukevanoort
03-04-2008, 19:51
We do it like one-stick but we split the x and y axis out onto different joysticks (kind of like Halo). This makes it really easy to drive dead straight (just let go of the turning joystick), gives a bit finer "feel" to the controls than one-stick, and is much more intuitive than tank drive. We have tried other methods, and some of our members prefer to drive tank-style; however, myself and last year's driver both found Halo-style to be the best compromise, so that is what we've used.

AmoryG
03-04-2008, 20:59
Well, one of the reasons why I as the driver (and I think most of my team) didn't like the tank control/duel joystick was partially because our robot was so powerful. The gearing ratio made it so actually stearing the it was one thing, but making it turn gradually and not suddenly turn around in a great circle was another thing. We tried all different things with the programming, but it never worked as well as we hoped. I eventually came up with a system that I used in the competition. The results were the best I could hope for. When you turned the joystick to the top left hand corner, it made a nice curve and just by turning it a bit, I could change the turning direction so if there were robots in the way I could easily menuver around them.

When we first entered the competition we only used 1/4th the power our robot was capable of. Because the rug made it so the robot was slower but a lot more controllable we upped it to 1/2 the power and added a turbo trigger. If the joystick is in a certain area the robot will automatically go straight at max speed. I think I could bring up the code, I have it on my computer somewhere....

mluckham
03-04-2008, 21:52
We do it like one-stick but we split the x and y axis out onto different joysticks (kind of like Halo)

Nice! Like Mode 1 in Radio Control airplane transmitters (one stick rudder, one stick elevator), versus Mode 2 (single-stick). I'm gonna have the guys try that, next year.

Battering_Ram
03-04-2008, 22:11
I have been driving two years (171) and we have had tank drive both years. I really like this because it isolates the two sides of bot. But I will admit that I want to try the halo style so i will email my programmer right away. In my opinion I believe the one joystick is cramming to much onto one contoller, I'd rather isolate and have more precision(imo). But variety is the spice of life so I think its great how everyone does something different.

Racer26
04-04-2008, 11:16
I suspect you had trouble with twin stick control because you did not map the values to a cubic curve to desensitize it.

Jimmy Cao
04-04-2008, 11:42
We do something rather unique to our drive system.

There are two joysticks. On one of them, we use both axis. The X axis translates the robot left and right, and the Y axis translates the robot forwards and backwards.

We only use one axis on the other joystick. This joystick is responsible for the rotation of the robot. By using both sticks together, the software places an imaginary point in space that the robot "rotates" around. However, this control system only works on an omni directional drive system.

BigJ
04-04-2008, 11:43
For our mecanum setup, we used one stick for all translation (sliding while facing same way, includes forwards/backwards) and another stick for the rotation on the X-axis.

The drivers had different preferences as to which side they were on so they were interchangeable.

jester_assault
04-04-2008, 11:46
For our Mecanum drive system, 357 uses a 3-axis joystick. The X axis and the Y axis are used for forward/backward/ and translation motions, while the Z axis is used for spin. In the past we used a 2 axis joystick and isolated translational movement to only occur when the drive held the trigger of the joystick.

E. Wood
04-04-2008, 12:00
Team 1629 has always used a single joy stick to drive and an array of buttons and switch sto control the functions until this year. This year, while the buttons and switchs are still there, we used a steering wheel to drive. We figured "hey its a race right, race cars already work well, so we will drive it just like a race car." (If you havent checked out our drive train check it out at http://www.team1629.com Its pretty cool.)

JesseK
04-04-2008, 12:23
I like that halo idea. Things seem more intuitive and less pressure if you can train each hand to do a different task.

Here are some arguments to try single-joystick driving instead of classical tank drive. Keep in mind this is just my opinion. I also have a control systems background so I feel it's easier and more advantageous to do a system rather than leave some things up to driver control.

Personally, I think classical "tank" drive puts too much of the drive processing on the driver, and agree with the OP that it's harder to control. Movements aren't as smooth as they could be and it's hard to process inputs for improvements in the code. Driving backwards and driving while the bot is pointed at the driver also becomes harder without alot of practice. Think about a bunch of cones setup on the track and you have to slalom through them while also making the left-hand turns around the track. Without alot of practice, tank drives will usually make it through such a course slower/quirkier than the single-joystick setup. This year, the slalom consists of 5 other dynamically placed bots and 3 other trackballs on the field, so I believe this comparison is valid.

With a single joystick, in code I can create a system that has some variables (aka coefficients). Based upon the variables I can determine different integral-based rotational neutral zones, scale within certain regions of joystick movement, how the robot reacts based upon its direction, and can eliminate jerky joystick movements that translate to jerky bot movements for both rotation and lateral at the same time. For tank drive, doing all of these things requires at least twice the code so you can determine a rotation vector, where as single-joystick drive rotation is a direct input. Some of this stuff isn't easy to do, and sometimes isn't even necessary depending on the way the driver naturally drives.

Some drivers can intuitively drive without all of the fancy code. Yet imagine how much more they could concentrate on game strategy if they didn't have to focus so much on the drive itself. Just my .02.

Shadow503
04-04-2008, 12:24
I love our steering wheel:
http://www.chiefdelphi.com/media/img/c12/c127102b49897c6a0de2bf4f1821ea0f_m.jpg

Alan Anderson
04-04-2008, 13:07
With a single joystick, in code I can create a system that has some variables (aka coefficients). Based upon the variables I can determine different integral-based rotational neutral zones, scale within certain regions of joystick movement, how the robot reacts based upon its direction, and can eliminate jerky joystick movements that translate to jerky bot movements for both rotation and lateral at the same time. For tank drive, doing all of these things requires at least twice the code so you can determine a rotation vector, where as single-joystick drive rotation is a direct input.

To convert dual-joystick tank-style control to single-joystick arcade-style control is two lines of code.


speed = left + right;
turn = left - right;


I have left off scaling and offset, because some people like to keep the 0-254 range and others like +/- 127 instead (the TechnoKats Overdrive code this year actually uses +/- 100 for all internal computations).

Qbranch
04-04-2008, 17:35
Really, and this is the programmer side of me talking, you have to taylor-make the controls to the driver/operator. Everybody's brain is wired different, so there isn't any one great answer.

In 2006 (I think) I saw a team that had a mechanum drivetrain that used a single joystick drive with a twist (:rolleyes: pun)... they added a twisting handle to one of the white joysticks to control the spin motion that a mechanum drive is capable of. Cool idea.

As a driver (hopefully I'm not alone on this and someone has a similar experience) some people just 'get' a tank (2 joystick/differential) drive system. Our driver we had through the 2006 season wouldn't take anything else really... he could feel the way the robot drove and found it simplest to do tank drive.

Personally, I agree. Our robot runs most efficiently if we run down our homestretch going forwards, grab the ball, and use the bounce of the ball running into the opposite wall of the field to speed up our acceleration comming back on the other side of the track. This requires me to be able to drive the robot backwards, something that I think would be much more difficult with any other kind of input system I can think of.

-q

thefro526
04-04-2008, 17:41
I'm my experience, I've grown to love a two Joystick Tank system. Usually the programmer will set the maxes so that max forward is always perfectly straight. I've used a lot of different controls with my vex robot's and the only time I don't use a tank is when I'm using my custom mecanums.

s_forbes
04-04-2008, 18:02
We used the normal tank drive system in 2006 and 2007. To make it a little easier to control, we hacked off the long joystick arms. It worked alright, but it was still pretty difficult to conrol when trying to manipulate turns. Going in a gradual in high gear was also near impossible!

This year we decided to go with a controller used for racing remote control cars, and it worked amazingly well (photo here (http://photos.project1726.org/albums/userpics/10009/normal_IMG_5691.JPG)). The guts of the controller were removed, and it was programed to work with feedback from gear tooth sensors in the transmission.

The steering wheel allows for fine control during high speed maneuvers, something that is very useful for this years game. Turning the wheel without throttling makes the bot turn in place, and reversing the throttle makes it behave like a car driving backwards. I think everyone on the team who tried our new drive system agreed that it was much easier to control than the tank style.

Protronie
04-04-2008, 18:37
Really, and this is the programmer side of me talking, you have to taylor-make the controls to the driver/operator. Everybody's brain is wired different, so there isn't any one great answer.

In 2006 (I think) I saw a team that had a mechanum drivetrain that used a single joystick drive with a twist (:rolleyes: pun)... they added a twisting handle to one of the white joysticks to control the spin motion that a mechanum drive is capable of. Cool idea.

As a driver (hopefully I'm not alone on this and someone has a similar experience) some people just 'get' a tank (2 joystick/differential) drive system. Our driver we had through the 2006 season wouldn't take anything else really... he could feel the way the robot drove and found it simplest to do tank drive.

Personally, I agree. Our robot runs most efficiently if we run down our homestretch going forwards, grab the ball, and use the bounce of the ball running into the opposite wall of the field to speed up our acceleration comming back on the other side of the track. This requires me to be able to drive the robot backwards, something that I think would be much more difficult with any other kind of input system I can think of.

-q

I'm, guessing it really helps if the driver and programmer just happen to be the same person.
Only one question... when something goes south and your bot slams the wall on turn three... who do you blame? :p

Kev
04-04-2008, 21:37
...

DDR pad


is there a video of this?

BHS_STopping
04-04-2008, 21:53
We used the normal tank drive system in 2006 and 2007. To make it a little easier to control, we hacked off the long joystick arms. It worked alright, but it was still pretty difficult to conrol when trying to manipulate turns. Going in a gradual in high gear was also near impossible!

This year we decided to go with a controller used for racing remote control cars, and it worked amazingly well (photo here (http://photos.project1726.org/albums/userpics/10009/normal_IMG_5691.JPG)). The guts of the controller were removed, and it was programed to work with feedback from gear tooth sensors in the transmission.

The steering wheel allows for fine control during high speed maneuvers, something that is very useful for this years game. Turning the wheel without throttling makes the bot turn in place, and reversing the throttle makes it behave like a car driving backwards. I think everyone on the team who tried our new drive system agreed that it was much easier to control than the tank style.

As the main driver of Team 1726 this year, I can vouch for this system. It is, without a doubt, so much easier to operate than a standard 2-joystick tank drive system. I urge other teams immensely to consider this type of controller to test out. I found it so much easier to use than a standard tank drive system (which I have become accustomed to over the past few years), and the switch to a new system was incredibly easy to get used to.

With a bit of programming, you can make a 6WD system drive perfectly straight and steer like an ackermann type drive train, while still retaining the maneuverability and on-the-spot turning of a tank drive system. A picture of our setup can be found here. (http://photos.project1726.org/displayimage.php?album=28&pos=41)

Again, I urge all teams to give it a shot! I can guarantee that it will improve the performance of your robot and reduce the strain on your driver.

AmoryG
05-04-2008, 14:16
Here is code for the system I used. I created this system and I used it in the competition. I apologize that it might be hard to read and understand.

-One joystick control
-Uses a function that changes turning rate

You can view the code by opening the attachment below. I didn't want to copy+paste the text directly in the post, it's too long. Also, note this is old code. In the actual competition we made some minor adjustments, but besides that it's almost identical to the newer version.

Curt_Bagne
05-04-2008, 14:59
I am really happy with 2 stick tank drive. It gives me lots of control and allows me to do things with the robot that I'm not sure I could do with other control systems.

This may be a bad metaphor but think of tank drive as a car with a manual transmission and some other trick control system as a car with an automatic. An automatic is easy to use and a new driver can do very well with it but it takes control away and gives it to a computer that in most cases doesn't know when you are approaching a turn or anything else. A manual transmission takes longer to get used to but once it is mastered, it is faster in most racing situations. Once you master the basics of tank steer(going straight, smooth turns, inverting inputs when the robot is going towards the driver) it can be made to do some amazing things.

I could be completely wrong as I don't have any experience driving a robot with anything other than tank steer but I think what I said is true.

Greg Peshek
05-04-2008, 15:31
As the main driver of Team 1726 this year, I can vouch for this system. It is, without a doubt, so much easier to operate than a standard 2-joystick tank drive system. I urge other teams immensely to consider this type of controller to test out. I found it so much easier to use than a standard tank drive system (which I have become accustomed to over the past few years), and the switch to a new system was incredibly easy to get used to.

With a bit of programming, you can make a 6WD system drive perfectly straight and steer like an ackermann type drive train, while still retaining the maneuverability and on-the-spot turning of a tank drive system. A picture of our setup can be found here. (http://photos.project1726.org/displayimage.php?album=28&pos=41)

Again, I urge all teams to give it a shot! I can guarantee that it will improve the performance of your robot and reduce the strain on your driver.

We built an Ackermann steering system this year, and as driver of the robot and a RC Car racer, your system is something I wanted to try out (I actually have that same pistol grip TX for my recreational driving cars). Unfortunately none of us knew how to setup the "guts" of the controller. Would your team be willing to create a white paper, or a general how-to for the setup of this system (although it's likely that we'll have a new control system, it's something I would like to look into). I'm sure many teams would be in debt to your team if you were to do this. Thanks.

-Greg P.

James Tonthat
06-04-2008, 15:53
We use one joystick.

Having mechanums, we can move in any direction. Being of the video game generation, I had it programmed like a helicopter. Forward is forward, back is back, left is a left straife, right is a right straife, twist left is a left rotation, twist right is a right rotation. It makes a bunch of intuitive sense. You can think of it as a helicoper or think of it as a first person shooter. We use a Saitek Avaitor USB joystick, attached to a USB chicklet. The top buttons are for the launch, arm pick up, and arm drop.

More techie description:
+Y = Forwards
-Y = Backwards
+X = Right Straife
-X = Left Straife
+Z = Right twist (right turn)
-Z = Left twist

Shadow503
06-04-2008, 17:46
We use one joystick.

Having mechanums, we can move in any direction. Being of the video game generation, I had it programmed like a helicopter. Forward is forward, back is back, left is a left straife, right is a right straife, twist left is a left rotation, twist right is a right rotation. It makes a bunch of intuitive sense. You can think of it as a helicoper or think of it as a first person shooter. We use a Saitek Avaitor USB joystick, attached to a USB chicklet. The top buttons are for the launch, arm pick up, and arm drop.

More techie description:
+Y = Forwards
-Y = Backwards
+X = Right Straife
-X = Left Straife
+Z = Right twist (right turn)
-Z = Left twist
That's a sweet control scheme. How long did it take your drive team to adjust? Do you have any videos of your robot in action?

James Tonthat
06-04-2008, 22:13
Err, too bad I don't have any cool video of it but it didn't take that long to adapt to, probably 1 or 2 minutes to stop running into walls and another 3 or so minutes to drive it pretty well. You learn to drift your turns to smooth them out, just a thing you naturally develop with time.

Edit: Actually, you'll see us at us at the Championships so maybe you can check it out there.

usbcd36
06-04-2008, 23:31
We do it like one-stick but we split the x and y axis out onto different joysticks (kind of like Halo). This makes it really easy to drive dead straight (just let go of the turning joystick), gives a bit finer "feel" to the controls than one-stick, and is much more intuitive than tank drive. We have tried other methods, and some of our members prefer to drive tank-style; however, myself and last year's driver both found Halo-style to be the best compromise, so that is what we've used.

That's what we did this year too. A lot of the potential drivers hated the system, but they didn't show up to most of the driving practices, so I never changed it, and drove myself. The other nice thing about using this system was that I could use the Y-axis joystick with my left hand and grab it near the bottom (since it's a right-handed stick anyway), then use my left hand for the buttons and the desensitized X-axis (since we didn't need the power spin).

Jared Russell
06-04-2008, 23:44
We use one joystick.

Having mechanums, we can move in any direction. Being of the video game generation, I had it programmed like a helicopter. Forward is forward, back is back, left is a left straife, right is a right straife, twist left is a left rotation, twist right is a right rotation. It makes a bunch of intuitive sense. You can think of it as a helicoper or think of it as a first person shooter. We use a Saitek Avaitor USB joystick, attached to a USB chicklet. The top buttons are for the launch, arm pick up, and arm drop.

More techie description:
+Y = Forwards
-Y = Backwards
+X = Right Straife
-X = Left Straife
+Z = Right twist (right turn)
-Z = Left twist

We played around with this configuration the past two years with our omni-drive, but our drivers felt that it was "too much" for one hand. You would be trying to strafe when you inadvertently would twist the stick.

Stiffer springs in the joystick would have helped, but we moved onto a different control system that has helped our omni-drive bots win regionals in back-to-back years.

Left stick:
Y axis is forward/backward
X axis is turning (e.g. single stick drive with a skid-steer bot)

Right stick:
Y axis does nothing
X axis strafes

It seems unintuitive on paper, but if you have experience driving skid-steer bots with a single stick, it lets you transfer that knowledge while allowing you to strafe when needed.

BigJ
06-04-2008, 23:59
We played around with this configuration the past two years with our omni-drive, but our drivers felt that it was "too much" for one hand. You would be trying to strafe when you inadvertently would twist the stick.

Stiffer springs in the joystick would have helped, but we moved onto a different control system that has helped our omni-drive bots win regionals in back-to-back years.

Left stick:
Y axis is forward/backward
X axis is turning (e.g. single stick drive with a skid-steer bot)

Right stick:
Y axis does nothing
X axis strafes

It seems unintuitive on paper, but if you have experience driving skid-steer bots with a single stick, it lets you transfer that knowledge while allowing you to strafe when needed.

So, do you translate at angles by mixing forward/backward and strafing then?

Jared Russell
07-04-2008, 00:02
So, do you translate at angles by mixing forward/backward and strafing then?

Yes.

We don't translate at angles very often anyhow - the nature of our drive geometry is designed to strongly favor the cardinal directions.

AmoryG
07-04-2008, 12:48
Part of training drivers is giving them multiple options to steer the bot. We programmed our controller so if you hit a button, it switches between different drive modes. This made it so anyone could practice any mode they wanted to just by hitting a button, not by reprogramming the robot.

One reason why I made this thread was also show off their actual programming for controlling their bots. I'm very interested in what other programmers decided to do. I've always liked unique ways of doing things, not for the sake of being different, but being inovative. Inovation means something new and because I'm new to programming new is all I know. If anyone is willing to explain or share their code so I can study it and learn from what other people do, that would be great.

The drive mode my team uses in the competition was developped from an algorithm. When I was thinking of better ways of controlling the bot, I thought a single joystick mode would be definately better than the 2 joystick tank control. I like algoritms better than plotting points on the joystick. It's more clean in my opinion and easier to reprogram.

I thought of how the robot should moving according to the position the joystick is in. If I push it forward, it goes farward. The more I push farward the faster it should go. What if I push the joystick diagnal so it's in the top left corner? I think the robot should turn gradually left in a wide arc.

So, I looked at motor speeds and plotted them onto a graph.

forwards (255, 255)
backwards (0,0)
arc left (127, 255)
arc right (255, 127)

255 the motors will be spinning full clockwise. 127 the motors will not be spinning. 0 the motors will be spinning full counterclockwise.

And so on...

I eventually discovered a cool way of doing this based on this...

On the joystick y-axis would run from bottom to top where bottom is 0 and top is 255. On the joystick x-axis would run from left to right where left is 0 and right is 255.

leftMotors = -127 + (y-axis + x-axis)
rightMotors = -127 + (y-axis + oposite of the x-axis (x-axis mirrored))

oposite of the x-axis means that if on the x axis it were really 255, it would count as 0 in the code.

matt.winkler
07-04-2008, 12:59
I have been driving two years (171) and we have had tank drive both years. I really like this because it isolates the two sides of bot. But I will admit that I want to try the halo style so i will email my programmer right away. In my opinion I believe the one joystick is cramming to much onto one contoller, I'd rather isolate and have more precision(imo). But variety is the spice of life so I think its great how everyone does something different.

I have been involved on team 171 since the 1998 build season and to my knowledge, we have always done two independent joysticks with skid steer/tank style control. We have always had 2 operators. One operator is in sole control of driving and the second operator is in control of nearly all motor functions of the robot. I know that this can be tougher for some teams, but if your operators are in tune with each other, this can prove to be very efficient. It allows each of the operators to focus on a specific area of the competition and it removes some delays that may happen with other control styles.

Please keep in mind that I am not intending to bash any single joystick control system or any other very innovative control systems. I am only stating how we have done our robots in the past and the reasons behind our choices.

Alan Anderson
07-04-2008, 13:33
Part of training drivers is giving them multiple options to steer the bot. We programmed our controller so if you hit a button, it switches between different drive modes. This made it so anyone could practice any mode they wanted to just by hitting a button, not by reprogramming the robot.

That was one of the things I did with our programming team pre-season. Our drivebase software for the past few years uses a "speed" and "turn" value, mixing them to derive the motor control PWM outputs. The values are traditionally derived from tank-style joystick input, with speed being the average of the sticks' y-axes and turn being the difference. I showed them how to derive them instead from a single joystick, driving in arcade mode. Then we split the direct speed and turn inputs to get them from different joysticks, driving like an RC airplane with separate throttle and rudder.

I preferred the airplane mode. Everyone else liked tank mode best.

I eventually discovered a cool way of doing this based on this...

On the joystick y-axis would run from bottom to top where bottom is 0 and top is 255. On the joystick x-axis would run from left to right where left is 0 and right is 255.

leftMotors = -127 + (y-axis + x-axis)
rightMotors = -127 + (y-axis + oposite of the x-axis (x-axis mirrored))

oposite of the x-axis means that if on the x axis it were really 255, it would count as 0 in the code.

That "cool way" is exactly what the default code does for single-joystick control. Take a look at its use of the LimitMix() function.

AmoryG
07-04-2008, 14:18
Is it really? I understood what it did, just not the logic behind it. How did they get those numbers? And by cool, I meant neat 8} not cool like "that's not what coool people do". Actually, I think we did try that code, but for some reason the controls were a bit different.

AustinSchuh
07-04-2008, 14:40
My favorite control setup is where you have a wheel and a throttle stick. The wheel controls turn radius not difference in power or something like that. The throttle stick is used to give the bot forward velocity. To deal with the fact that you can't do an in place turn that way, we have a button that you press to turn in place.

We currently implement this with motor power only, but I would like to implement it in using a PID controller. I just haven't been able to put good enough sensors on our bot to achieve that. Not enough resolution on the quadrature encoders.

Alan Anderson
07-04-2008, 14:44
How did they get those numbers?

Are you asking about the inputs to the Limit_Mix() function in the default code?


pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);


The 2000 is just to force the compiler to use 16-bit arithmetic. Otherwise it would decide that because p1_y, p1_x, and 127 each fit in eight bits, the addition and subtraction should be done with eight bits, and there could be overflows and unexpected results. Limit_Mix() itself subtracts 2000 when it returns the value.

The first line adds the x and y values, correcting the offset so that when both inputs are neutral (127) the sum is also neutral.

The second line does the same thing as the first, but it "mirrors" the x value by subtracting it from 254 first. Then it obscures that step by combining the new +254 and the -127 from the first line into a single +127.

AmoryG
07-04-2008, 15:14
Weird, it's mine exact. Wonder why it didn't seem the same when I was controlling it.... I guess I feel a bit stupid recreating the code that was right infront of me. What I don't understand is where is the code that says if(x-axis + y-axis < 0) motors = 0 or there the other way around if it's more than 255?

Alan Anderson
07-04-2008, 15:24
What I don't understand is where is the code that says if(x-axis + y-axis < 0) motors = 0 or there the other way around if it's more than 255?

Look at the Limit_Mix() function. Doing that is the whole reason it exists. It limits the result of mixing the x and y axes of the joystick. The extra 2000 can be a little confusing, but I expect that you now understand why it is there.

AmoryG
07-04-2008, 15:43
I don't have the code infront of me, and I don't remember its full content, but yes I understand what it does.

BigJ
07-04-2008, 18:48
One reason why I made this thread was also show off their actual programming for controlling their bots. I'm very interested in what other programmers decided to do. I've always liked unique ways of doing things, not for the sake of being different, but being inovative. Inovation means something new and because I'm new to programming new is all I know. If anyone is willing to explain or share their code so I can study it and learn from what other people do, that would be great.


Team 1675 developed their own Mecanum algorithm this year, based off an article explaining a drive system for 3+ wheel Omni systems. The main premise is that it calculates all angles using "b-rads", a measure of an angle using 8-bit numbers instead of degrees or radians.

It has worked pretty well for us, barring some mechanical problems. Here is some example code because Our forum is going through overhaul and I REALLY don't like the code blocks there. too hard to read.

/*!
* \file omniTest.c
* \author Jon C. Anderson <jon.c.anderson@gmail.com>
*
* \note This code is for educational use only.
*
* Controlling an holonomic drive is not very difficult. The force that can be
* exerted by omni-wheels correlate directly with a sine function that is phase
* shifted based on the desired heading. The angular velocity of the wheels is
* basically the magnitude of resulting sine function at the angle of the wheel
* to the "front" of the holonomic drive scaled by the desired fraction of the
* maximum speed.
*
* This file shows how to control an omni-directional robot with 4 wheels
* evenly spaced 90 degrees from each other. This also approximates a robot
* that uses Mecanum wheels with a pitch of 45 degrees in the diamond setup.
*
* This code is based on "Holonomic Drive Platforms: How to Drive a Robot That
* Has No Front" by Jack Buffington published in SERVO Magazine for April 2005
*/

#define WORD unsigned short int
#define BYTE unsigned char
#define INT16 short int
#define INT8 char

#include <stdio.h> /* for printf */

BYTE calcMotorVelocity( BYTE Speed, BYTE Heading, BYTE MotorAngle, INT8 Rotation );

BYTE mySin( BYTE Angle );

const BYTE sinTable[] = {
128, 131, 134, 137, 140, 143, 146, 149, 153, 156, 159, 162, 165, 168, 171,
174, 177, 180, 182, 185, 188, 191, 194, 196, 199, 201, 204, 207, 209, 211,
214, 216, 218, 220, 223, 225, 227, 229, 231, 232, 234, 236, 238, 239, 241,
242, 243, 245, 246, 247, 248, 249, 250, 251, 252, 253, 253, 254, 254, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 254, 253, 253, 252, 251,
251, 250, 249, 248, 247, 245, 244, 243, 241, 240, 238, 237, 235, 233, 232,
230, 228, 226, 224, 222, 219, 217, 215, 213, 210, 208, 205, 203, 200, 198,
195, 192, 189, 187, 184, 181, 178, 175, 172, 169, 166, 163, 160, 157, 154,
151, 148, 145, 142, 139, 135, 132, 129, 126, 123, 120, 116, 113, 110, 107,
104, 101, 98, 95, 92, 89, 86, 83, 80, 77, 74, 71, 68, 66, 63, 60, 57, 55,
52, 50, 47, 45, 42, 40, 38, 36, 33, 31, 29, 27, 25, 23, 22, 20, 18, 17, 15,
14, 12, 11, 10, 8, 7, 6, 5, 4, 4, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 16, 17, 19, 21, 23, 24,
26, 28, 30, 32, 35, 37, 39, 41, 44, 46, 48, 51, 54, 56, 59, 61, 64, 67, 70,
73, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 106, 109, 112, 115, 118, 121,
124, 128 };

int main( void )
{
/* This "Omni" bot has 4 wheels located 90 degrees from each other with
* forward being at North
*/

/* PWM Position Position Motor *
* Output (Compass) (b-rads) Orientation *
* ------ --------- -------- ----------- */
BYTE pwm01; /* NW 224 reverse */
BYTE pwm02; /* NE 31 forward */
BYTE pwm03; /* SW 159 reverse */
BYTE pwm04; /* SE 96 forward */

BYTE mySpeed = 254; /* Velocity scalar (0->stop, 255->full speed) */
BYTE myHeading = 0;
BYTE myTwist = 0;

pwm01 = calcMotorVelocity( mySpeed, myHeading, 224, myTwist );
pwm02 = calcMotorVelocity( mySpeed, myHeading, 31, myTwist );
pwm03 = calcMotorVelocity( mySpeed, myHeading, 159, myTwist );
pwm04 = calcMotorVelocity( mySpeed, myHeading, 96, myTwist );

printf( "m1:%i\tm2:%i\r\n\r\nm3:%i\tm4:%i\r\n", pwm01, pwm02, pwm03, pwm04 );

return( 0 );
}

BYTE calcMotorVelocity( BYTE Speed, BYTE Heading, BYTE MotorAngle, INT8 Rotation )
{
INT16 MotorOutput;

Heading = MotorAngle + Heading;
/* If your Mecanum drive is in the X configuration phase shift your heading
* by 63 brads */

/* MotorOutput = V * (scaler/divisor) + (zeroOffset - scaler)/2 *
* MotorOutput = V * (Speed/256) + (256-Speed)/2 */
MotorOutput = (((WORD)mySin( Heading ) * (WORD)Speed) >> 8) + ((256 - Speed) >> 1);

MotorOutput += Rotation;

/* Make sure that rotation has not caused an overflow */
if( MotorOutput < 0 )
{
MotorOutput = 0;
}
else if( MotorOutput > 255 )
{
MotorOutput = 255;
}

return( (BYTE)MotorOutput );
}

BYTE mySin( BYTE Angle )
{
/* This sin function is not very accurate, but should be good enough */
return( sinTable[ Angle ] );
}

Our actual files all have a little more stuff in them, and we worked at making our code object-oriented this year, but nothing very very different from this.


You can check it out more here:

http://team1675.org/forum/viewtopic.php?f=6&t=151&sid=ed248deaca7de7c833c6a9d4645edb9c&start=15#p1352

(Out website is in overhaul so it may be a little funky.) Feel free to ask me any questions!

AdamC
07-04-2008, 19:15
I started driving 395's 'bot at the end of the Florida regional. We used to run a single joystick for our tank drive (Y did forward and backwards, X did pivots). I wasn't too fond of the very limited maneuverability the system provided though, so now we've gone dual joystick (using only Y axis to control the forward and backwards of each tread.) It's much more effective in my opinion. Although I always wanted to try a game controller, since I'm an avid Xbox player, and I think it would make the transition from racing game to robot racing easier.

Nate Edwards
07-04-2008, 19:16
We have switched between 1 and 2 several times:

2002 - 1
2003 - 2
2004 - 1
2005 - 1
2006 - 2
2007 - 2
2008 - 2 and Steering Wheel

We really liked the way it worked this year, we tried 1 with steering wheel, but you have more control we feel with 2 joysticks, so one driver had the steering wheel and other had the 2 joysticks. They really had to communicate well, which they did. The steering wheel was used mainly to help get out tight places and to turn left sharper, in both cases it proved to be the best solution for our particular bot as we consistently would get 5-7+ laps after the auto period.

AmoryG
07-04-2008, 19:34
We didn't have too many practice sessions with the robot really. We also had to make an adjustment or two because of LACK of communication. Our robot has an arm to herd and a poker which pops up and pushes the ball off. Now, when we were practicing sometimes for some reason some how whoever was controlling the poker popped it up and instead of going under the rack and then popping it off, we rammed into it and we sent the plastic rack crashing down. Unfortunately, the rack or w/e you want to call it in the competition isn't made of plastic.

In the practice matches the day before our regional competition we did exactly that. We rammed into the rack with our poker up. Because our robot has a very low center of gravity and because it ways 117 pounds, we didn't tip over. We crashed into it full force and for the entire practice match we were tipped diagnal and couldn't get the robot to move. This wasn't neccessarily bad, but other robots kept ramming into ours and by the end of the two minutes our robot's arm was bent and it completely jammed. We got a new arm easily enough, but we had to change the code so that you could not use the poker if we were driving.

I have a question which I hope is relevent enough to the thread topic.
Has anyone heard of a robot or would know if it's possible to get some sort of electronic compass onto the robot so it would know which way points north?

Cooley744
07-04-2008, 20:03
i really liked 233's set up. the way if unfolded was just really cool