Skip to main content
Skip to Main Content
Skip to main content
Navigation

The Mathematics of Driving and Turning A Robot

In this session, Lauren dives into the mathematics of driving and turning using individual motor commands. Using the scenario of a competition robot with a custom drivetrain as an organizer, she breaks down the math used to determine how to code each motor to drive in a straight line so that it could move around the Field. She then uncovers the formulas needed to code the robot to turn, demonstrating both point and swing turns. This session offers insight into the mathematics behind drivetrain commands, and offers practical applications for abstract concepts like circumference, that can be interesting ways to incorporate robotics into a math class, or vice versa.

(upbeat music)

Hello, and welcome to the Math and Robotics Live Session. My name is Lauren, and today, we're gonna be covering a lot of fun math concepts that I can't wait to share with you. However, before we dive into that, I just wanna talk about how Live Sessions are structured, specifically how this session is going to be structured.

Everything that you see here is going to be recorded, so please don't feel like you need to write anything down frantically or things like that. You can watch it later if you want to. Other things, as well. Some of the projects that I'm gonna show you here tonight, and also the slides that I'm going to be using, will be available after the session. I will post them in our PD+ Community thread. So again, please feel free, you do not have to frantically write anything down or remember anything. All of the resources that I will be having here tonight, I will send you after the session.

Now, if you have any questions during the session or after the session, we will be covering a lot of material tonight, you can ask in the chat, in the Zoom chat that we have here. We do have another education team member in that chat monitoring questions. If, again, you develop any questions later, or more lengthy questions, you can put those in our PD+ Community thread for this particular Live Session and I will be more than happy to address those questions or continue further discussions past tonight in there, as well.

Alright, let's actually take a look at the concepts that I'm gonna be covering tonight in our session. Here is our session agenda. First things first, we're gonna talk about a scenario. More specifically, I wanna talk about a V5 or VRC competition scenario that will contextualize what we're going to talk about. The overarching concept tonight, what we're discussing, is coding my robot for autonomous movements using individual motor commands instead of drivetrain commands.

Now, that being said, while we look at the math concepts that we can use to code these individual motor commands, it will also explain the math behind the scenes of how the drivetrain commands actually work in VEXcode. So, we have a twofold different scenario here. Again, understanding how and why I would use individual motor commands and the math associated with those commands. That also will then expose the math behind the drivetrain commands in VEXcode.

We will be looking at three different scenarios here at the bottom. So, we're gonna look at how do I calculate the number of wheel turns needed to drive and turn specific distances and degrees? We're gonna be looking at three different things. Driving forward, so just a straight distance, and then two non-linear distances, or circular distances, with turning, a point turn and a swing turn. So, that's what we're gonna be going through tonight, but ultimately, we are going to try to answer that first question, there. Why would I code my robot to move using individual motor commands?

Let's start off with this competition scenario. So, this picture that I have here on the right is actually the top-down view of this year's VRC game, Over Under. Now, I'm just using this as an example so that you can see what it looks like in context. The exact measurements that I will be using here, in this video, in this session, are not 100% accurate. It's just a proof of concept, which means if you take these ideas and go try them on a field with your robot, you may not get the exact same results, because I'm just using all of this information here tonight as an example to show you these different mathematical concepts and why they are so helpful to use, particularly in a competition setting.

So, as you can see down here on the bottom right, this is where my robot is going to start.

Thank you for joining us for this session. I hope you find the information useful and engaging. If you have any further questions, feel free to reach out through our community thread. Enjoy the rest of your day!

I want my robot to turn to the right 90 degrees and then drive forward approximately 24 inches. One of those field tiles is about two feet, so about 24 inches, to locate this triball over here. Again, probably not exact distances, but we're gonna use those numbers for simplicity.

Now, I could just use, depending on my robot design, my drivetrain commands to turn right 90 degrees and drive forward for 24 inches. However, certain custom drivetrains cannot be programmed in VEXcode. What would I do then? Well, in that case, we're gonna talk about coding individual motor commands. Again, going into this a little bit more depth.

What, exactly, is the problem? Well, competition robots particularly, there are multiple ways in order to design these robots, and you have to keep a lot of things in mind. You have size limit restrictions, motor restrictions, and a bunch of things that you need to keep in mind when designing your robot. Now, there may be different drivetrain designs, such as the Mecanum wheels, the X-Drive, or Holonomic design, all these different types of drivetrain designs that are not supported in the robot configuration in VEXcode.

So, again, I may want to actually have these particular drivetrain designs, but that means that I'll need to code the individual motors of those drivetrains instead of using one of the default drivetrain configurations in VEXcode. Now, another thing that I would like to note is that, for many programs in competition, you want to create a custom driver control code, which means I'm coding the controller to drive my robot or manipulate the individual motors of the drivetrain. You can use individual motor commands for that, as well.

Now, those are more so used with different values on the joysticks and things like that, so that's a little bit of a different coding experience, but I did want to highlight that it's another way for you to actually use individual motor commands. Now, in this video, what we're studying here tonight, we are going to be using set distances with individual motor commands, which means I'm not using joystick values or different axes of the joysticks and things like that. I'm just going to use the math to figure out how I can drive and turn specific distances and degrees, or, more so, autonomous movements with individual motor commands.

So, I just wanted to note there are two different types of scenarios in which you would actually use those. And again, tonight, we're just focusing on the set distances, driving and turning. Okay, let's go a little bit further into this.

Individual motor commands in general. Each V5 smart motor has an internal encoder. What does that mean? Why is that helpful to me? Well, these encoders measure the amount of rotation of a shaft. So, I can measure the number of degrees and turns of a shaft, and it can be reported. But not only is it reported, that means that I can also set that specific degree measure or turn. So, again, I can set that particular distance using degree measures or a certain number of turns.

At the bottom right here, you can see what this actually looks like in VEXcode. We'll explore this a little bit as we continue, but I'm spinning each motor, left and right, forward for a specific number of turns. I also wanted to include a top-down, or uncovered, picture of the V5 smart motor to actually highlight for you where the encoder actually is, which is this bottom left-hand, there. So, that's actually where the encoder is in the V5 motor. If you want to learn more information about that, I do have that hyperlinked here in the slides that I will share after this Live Session.

All right. Let's get into the fun of this. Why would I use math? Why is math important? More specifically, why do I need to use math in order to calculate how far my robot can move a set distance?

Now, I mentioned before, what is the goal we're trying to reach? I'm trying to turn 90 degrees to the right and then drive forward for 24 inches. So, I need to figure out how to actually code my robot to travel that distance. In order to code a robot to move a certain distance or turn a specific degree angle autonomously using these individual motor commands, I need to calculate the number of wheel turns required.

Again, why is this important? Mathematical calculations allow for precise movements. Now, I wanna show you something right here, top down, as soon as I explain this equation. To calculate the number of wheel turns that I need, we can use this formula:

Distance equals the circumference times the number of turns.

I'm also gonna write it on the board as we continue, here. Let's explain each three of these things. Distance is the total distance we want the robot to travel. Circumference is the distance traveled of one wheel turn, or the total distance around the outside of a wheel, and, more specifically, any circle. And turns is the number of wheel turns needed to travel that specific distance.

All of this that I'm explaining right now, the math behind this is also the math behind how the drivetrain commands in VEXcode work. So, when you plug in a particular distance in VEXcode, drive forward for 24 inches, this is what's being calculated in the background.

Alright, so let's take a look at a couple of things, here. I mentioned before, circumference. I'm gonna write our formula at the top, here, that distance equals circumference times the number of turns.

(marker scraping)

Okay? I abbreviated a little, there. Okay, distance equals the circumference times the number of turns. Circumference of the wheel is basically going to be from a start location all the way around the wheel. Now, if you can imagine I had a piece of string around this wheel and it went all the way around, if I picked that string up and flattened it, that is essentially the linear distance of the circumference, or how far one wheel turn is.

Why does that equate to distance? Well, distance equals the circumference times the number of turns. So, if this is the entire circumference, you can imagine, the number of turns, let's say one, one full turn would get me that linear distance. Okay? So, I'm trying to figure out, I know the circumference, because it's the wheel. How many turns do I need to actually go this distance? So, these two values are known. This is the value I'm trying to calculate.

Now, as you can see here, we have a lot of different V5 wheels, so let's take a look at those. Many different sized V5 wheels. As you can see, there's a bunch of them on the screen there. There's also a link, if you wanna check out those different types of wheels. But essentially, there are three sizes. 2.75, I'm gonna write these down, so that when I go back to the overhead, you'll be able to see. 2.75 inches, or the smallest wheel. The next is 3.25, or the medium-sized wheel. And then four inches, or the largest wheel.

Now, you can see, there, there are different types of the wheels. So, I have two different types of the 3.25-inch wheels. I have an omni wheel and also a traction wheel in the same, four inches, the omni wheel and the traction wheel. Why does this matter? Because we just looked at that formula, the circumference, or the distance around the wheel, that's important to know, and that changes depending on the size of the wheel. Again, this makes sense intuitively. The smaller the wheel, the more times it needs to turn in order to travel a distance. The larger the wheel, the less times it needs to turn to travel that same distance.

As I just mentioned here, wheel size truly does matter.

Thank you for your attention and interest in this topic. I hope this explanation helps you in your robotics projects. If you have any questions, feel free to reach out.

When you configure a drivetrain in VEXcode, it's crucial to identify the wheel size. This is because when you input a distance into the drivetrain block, the underlying math calculates the wheel's circumference and determines how many turns are needed to travel that distance. The circumference of the wheel is essentially dependent on the wheel size. As you can see, you can select between different wheel sizes. This highlights the importance of setting these parameters in the drivetrain configuration and understanding how they are used in the drivetrain blocks.

To determine how far one wheel turn is, we need to calculate the distance. For instance, if I need to travel 24 inches, I must first calculate the circumference of each wheel, which is the distance of one wheel turn, not the 24-inch distance, but the distance that one wheel travels. To find this, I can take a part of the wheel, place it on a ruler, and roll it one full revolution to see how far the wheel actually turns.

I have a V5 ruler here, and I've already done this with a small wheel. I marked a red line on the wheel, started at the top of my ruler, and rolled it one full revolution until the red mark hit the ruler again. Although it's a bit hard to see from the top camera, it's around 220 millimeters, or just over 8 1/2 inches. I'll show both representations in inches and millimeters, but for simplicity, I'll keep everything in inches. So, the circumference is a little more than 8 1/2 inches, or approximately 220 millimeters, for the small wheel. With a 3.25-inch wheel, one full revolution travels much farther, as expected, because the wheel is bigger.

I did all these calculations ahead of time for reference. I'll keep the circumference noted and write it down on the table for later use. It's important to note that the physical measurement we did, where we measured the wheel's circumference, can also be done mathematically. The circumference is pi times the diameter, so multiplying the diameter of each wheel by pi gives the circumference. When I rotated the wheel all the way around, it was just over 8 1/2 inches. The calculation confirms this at 8.64 inches, validating our measurement.

I'll write the circumference for each wheel: approximately 8.64 inches for the small one, 10.21 inches for the medium one, and 12.57 inches for the bigger, four-inch wheel. We need this information because the wheel's circumference is part of our formula: distance equals circumference times the number of turns.

Let's take a look at the math for the first wheel. I have it referenced on this slide for later review, but I want to do this math physically here on the table. I'll use blue for the smaller wheels. The distance I want to travel is 24 inches. Always use units in mathematics, as mixing inches and millimeters would lead to incorrect calculations. The circumference of the wheel, in this case, is for the small 2.75-inch wheel.

Thank you for your attention, and I hope this explanation helps clarify the importance of wheel size in configuring a drivetrain in VEXcode. If you have any questions or need further assistance, feel free to reach out.

The circumference is approximately 8.64 inches. I'm trying to calculate the number of turns. I'm gonna represent that by capital T, here, for simplicity. Okay. I'm trying to figure out, or calculate, the number of turns. So, in order for me to do that, I need to isolate T, which means I'm gonna divide both sides by 8.64 inches.

(marker scraping)

Okay? On the right side of the equation, my 8.64 inches cancels, my multiplication and division also cancels, leaving me with just turns. On the left side, my inches cancel. 24 divided by 8.64 is approximately 2.78. Now, I'm rounding a lot here with a lot of the math that I'm doing. If you want extremely precise movements, you obviously don't want to round as much. Every time we round, we lose a little bit of precision. So, again, if you're trying to be extremely precise, I would recommend not rounding as often, but I'm doing all this here just for simplicity and to understand the concepts we're trying to learn.

What does this mean? This means, for this particular wheel size, the small wheels, in order for me to travel 24 inches with this wheel size, I need to code each of these powered wheels to travel 2.78 turns. So, almost three full revolutions. Let's take a look at what this looks like in VEXcode.

Here's the project. Now, something else I wanted to note was that, when we are coding individual motors in VEXcode, you need to have individual motors actually configured in VEXcode as opposed to a drivetrain. That's how you get these motion blocks on the side, here. So, I just wanted to note that. All of the projects that you see here, that I will include after this session, already have all of that configured.

So, I put some extra information here. I actually, with these purple blocks, I'm printing information to the brain so that we can see it. I am printing the actual position in turns of each motor that's being reported from the motor encoders. So, I'm printing that to the screen when the project is complete to verify that the motors actually traveled their distance. Now, here, I'm setting the speed of the motors slowly so that we get more accurate and precise movements. The robot's not going to be as jerky when it's moving more slowly.

And these two blocks right here are really what I'm most concerned with. I'm spinning both motors forward for 2.78 turns. Now, I have to have a "and don't wait" enabled on that first block because I need both of these blocks to start spinning at the same time. If this was not enabled, that means the left motor would spin for 2.78 turns, then the right motor would spin for 2.78 turns. And obviously, I know that my robot is not going to travel straight if they travel, both wheels are going forward not at the same time. So, that's why we have this "and don't wait," so that both motors will spin at the same time.

Okay, let's test this. I have my lovely yardstick, here, and I'm gonna measure out for us 24 inches, so that we can see. Here's going to be approximately our starting line, and approximately our end line, here. Try to get everything as straight as I can. Okay? Okay. Let me put my wheel back on here so that we actually have four wheels. Now, I'm using a training bot, here, from builds.VEX. The only thing I changed was I took off the metal shaft collars and just switched the wheels, in case you were wondering what robot build this is.

Okay. I'm lining up the axles of my wheels, here, with the starting line, because that's where the power actually starts from, right here, my axle. So, we're going from powered wheel axle to axle. That's how we're measuring the distance. Okay, I already have the project downloaded on my robot, so let's test it.

(wheels creaking)

Okay. As you can see, it's almost perfect, which is great. And I wanna show you here, on the brain, you can see both the left and right motor are reporting 2.78 turns, which is exactly what we coded them to move.

All right, great.

We can verify that our math was actually correct because I could physically see the robot traveled that distance. All right. Now that we looked at a straight distance, or linear distance, it is quite easy to actually measure and code robots to go straight distances. It's a little more difficult when those distances aren't straight, particularly turning.

Let's talk about two types of turns. There are different turns, many different turns that you can actually think of with different wheels and things like that. I only want to focus on two. The first is going to be a point turn. A point turn is where one wheel of the robot travels forward and the other wheel of the robot travels in reverse, basically spinning in its current position. I'll show what this looks like on the actual robot here in one second.

A swing turn is where one side or wheel of the robot remains still while the other side of the robot turns. So, let's take a look at what this actually looks like. A point turn, as you can see here, basically, my robot would turn in place. I have one wheel spinning forward, the other's spinning backward, and it's called a point turn, 'cause it's basically turning around one specific point there in the center of the robot.

A swing turn is going to be, let's say this wheel remains stationary. I'm not moving. This wheel is powered. That's where I'm going to start to get the swing, if you will. Now, obviously, this circle that the swing turn makes is bigger, twice the diameter of this, actually. So, you could imagine, well, Lauren, when would I want to use different types of turns? Great question.

Let's say I'm somewhere on my competition field and there are a lot of field elements around me, or obstacles that I don't want to touch. Obviously, a point turn allows me to turn with little area around me, or basically it's a very compact turn. Now, that would be the advantage. Let's say I want to turn and actually collect an object that might be over here. Well, a point turn just has me turn in place, so I can't really do that. But if I wanted to turn and grab an object on my way over, then a swing turn would be a great option. So, again, one turn is not necessarily better than another. They're used in different scenarios for different outcomes.

Let's talk about the math, though, behind these turns. As I just mentioned in the previous slide, when the robot turns all the way around, as you saw, it makes a circle. Now, the size of that circle differs depending on the type of turn that I actually make. But in general, when I turn the robot all the way around, regardless of the turn, it makes a 360-degree circle. Any other type of turn, 90 degrees, for example, 33 degrees, seven degrees, it's just a portion of the 360 degrees.

So, we're going to look at the diameter of the robot and the diameters of the circles that they make and see what actually happens here. So, I'm gonna take my purple pen. This is going to be a not-so-great circle, so anyone that's a big circle fan, I apologize in advance. We are going to turn here. Now, if you can imagine, I have one wheel here and one wheel here. So, when I start to turn, you can see it's making this circle. And if I keep turning, if I had a marker attached to each of these wheels, you could see that it starts formulating this particular circle as I keep going. So, keep turning, keep turning in place, my circle's still forming, et cetera, et cetera.

Now, again, sad circle that we have here, but you get the idea. So, this is approximately what my circle, the imprint of the circle being made from this robot. Now, if I put all of my wheels there, where they're supposed to be, what do you notice? You'll notice that the diameter of this circle is actually the center point of one wheel, the powered wheel, to the center point of the other powered wheel. Now, that actually has a name.

Thank you for your attention and interest in this topic. I hope this explanation helps you understand the mechanics and mathematics behind robot turns. If you have any questions or need further clarification, please feel free to reach out.

The center point of one wheel to the center point of the other wheel, or the powered wheels, essentially, is called the track width. So, the diameter of the point turn circle is the track width of the robot. Okay, great. What am I trying to actually calculate here with a 360-degree turn? I'm trying to figure out, what is the distance around this wheel?

Well, if you're wondering, Lauren, I can't actually measure that with my yardstick, you are correct, because it's a circle. I can't actually bend it, and if I did, it wouldn't be as accurate. If I took this circle, and it was a piece of string, and I picked it up and I laid it flat, this is the distance, again, that the track width of the diameter makes when I travel 360 degrees. This is still distance, so we're gonna be using the same formula. Distance is distance, whether it's linear or circular. 'Cause again, I could take this, I could pick this up, and I could lay it flat, and it would be the same distance. Distance is distance, as I like to say.

Okay. Why am I mentioning track width? I'm mentioning track width because it's the diameter of this circle. I'm trying to travel 360 degrees, which means I need to know this distance. Well, if I know the diameter, I can calculate the distance around this circle, because that's circumference. So, the circumference of this circle is the diameter times pi. Well, the diameter, as I just mentioned, is the track width. So, let's get the track width, multiply it by pi, and that is now the distance that I need to be calculating.

So, you can see there, that red line, that's the track width. Now, on this robot, again, this is a training bot, the track width is approximately 11.75 inches. It's not perfect, but again, I'm just using these numbers for simplicity of calculations, here. So, I'm gonna write that up here. Track width, 11.75 inches. I'm just writing it on the table for later. Okay? That means that, for the point turn, I put the track width up here, now, for a point turn, when I'm doing that, if I had a marker attached to this wheel, you can see that turn is much, much bigger.

Okay? So, the diameter for that circle is actually twice the track width. So, the track width times two. So, track width, and if I multiplied that by two, I would get 23.5, about, inches. Okay? This is the diameter for the point turn circle. This is the diameter for the swing turn circle. Okay. I do have these calculations here, again, on the slides, so you can reference them later, but I am gonna do this one live on the table for us.

Okay. I'm gonna do this one in green. Actually, black. We haven't done that yet. This is how I do all my math. It's kind of, it's a little chaotic and there's a lot of squiggles. Lots of brain power happening there. Okay. So, I'm trying to calculate this distance. Again, this is the robot distance. This is the entire distance around this circle. I know that that is going to be the circumference. Circumference equals pi times diameter, which was 11.75, which is about 36.91 inches. So, this distance, 36.91 inches. Again, I'm rounding for simplicity, here. Circumference of my wheel.

Now, I want to switch wheels for this particular one. I want to use my 3.25-inch wheels, or my medium-sized wheels. So, all I have on here is some shaft collars. I'm going to put, swap these wheels out really quick so that, I wanna show you what it looks like when we actually change these, change the wheel sizes, and how it affects everything. So, I'm gonna put traction wheels on the front, the powered wheels, and omni wheels on the back, so that it turns a little bit easier. Some drivetrains have omni wheels on all four wheels. Now, you just have to be careful with that, because omni wheels are fantastic for turning, but if they're being powered, there's obviously going to be some slippage. So, just depends on what you're trying to do.

If you are trying to get your robot to move side to side horizontally, then obviously you can use omni wheels for that. But again, it's a give and take. You will have a little bit more slippage if you decide to do that. So, because I'm not trying to have as much slippage here with my turns, I'm putting traction wheels on the powered, or on the front.

Okay. Now, ideally, you'd hold those on with metal shaft collars, but we are just using this here to spin in a circle. Okay. Circumference of the medium-sized wheels, or the 3.25 inches, is 10.21, as we calculated earlier, and I'm trying to calculate the number of wheel turns needed. This is the exact same formula that we just did. I'm gonna divide both sides by 10.21 inches.

(marker scraping)

That's gonna cancel my 10.21 inches on the right side. Also, the multiplication and division cancel out, leaving me with turns. On the left side, my inches is gonna cancel out. 36.91 divided by 10.21 is approximately 3.62.

(marker scraping)

So, again, I'm rounding here. About 3.62 turns will get my robot to travel 360 degrees. Okay?

All right. Let's look at the code, here, before we test this out. You can see the code is essentially the same, except I'm spinning my left motor forward and my right motor in reverse. That's how I'm gonna get the point turn. And I'm traveling for 3.62 turns. So, again, the code looks almost the same, except I have my left wheel going forward and my right wheel going in reverse for it to actually turn.

So, let's test this. Now, I'm gonna face my robot to the front here, or up that way. So, it's gonna travel all the way around. Now, some things to keep in mind as this robot is turning. Friction comes into play, the types of the wheels also come into play, and I also rounded quite a lot in my calculations. That means, if I don't travel precisely 360 degrees, there could be a lot of variations. It could have been in my rounding, could have been in the type of surface that I'm on, et cetera.

So, let's test this out.

(wheels creaking)

Okay, as you can see, pretty close to exactly 360 degrees. Obviously, I was a little bit off. That would've been perfect. But again, I rounded a little bit, so there'll be a small margin of error. I also might have had a little bit of slippage, here. These wheels are a little slippery on this surface. So, again, some different things to consider as you're testing this out.

Now, I wanna show you on the screen, you can see, sorry, that came in a little hot, there. My left motor, 3.62 positive, right motor, 3.62 negative. Why? Because the right motor traveled in reverse. Okay?

Okay. Now, what would happen if I wanted to travel 90 degrees instead of 360 degrees? Well, 90 degrees is just a portion of a 360-degree circle. More specifically, it's 1/4. So, if this is how many turns I need to go 360 degrees, and 90 degrees is 1/4 of 360, I can just divide this number by four, and that gets me 0.91, about. I also did these math calculations ahead of time, I did not just do that in my head. I really can't take credit for that.

(marker scraping)

Okay, 0.91 turns. I do have this. Point turn, 90 degrees. Okay, I already had this programmed on my robot, so the code for this would look exactly the same, except I'm going 0.91 turns instead of the 3.62. Again, all of these calculations are on the slide, so you don't have to worry about it.

Okay, let's try this out. We can see how accurate we are. 90 degrees to the right.

(wheels creaking)

Pretty close, almost exactly 90 degrees. Little bit, that would've been perfect. But again, as for the mentions that I talked about earlier, obviously, we rounded quite a lot, and there may be a little bit of slippage. Looking at the motor encoders, you can see, left motor positive 0.91, right motor negative 0.91.

Thank you for following along with this demonstration. I hope you found it helpful and informative. If you have any questions or need further clarification, please feel free to reach out.

Thank you once again, and happy coding!

I'm just gonna show you the math on here instead of doing it on the table, mostly because the equation is exactly the same, and also I'm running out of writing space on my table, here. So, this one, which is the last turn that we're going to look at, the distance this time, now, as we talked about earlier, my circle is much bigger for the swing turn than the point turn. So, obviously, the distance that I need to travel with that circle is much bigger. I'm also going to be using my four-inch wheels.

As I'm explaining this formula, I'm gonna be swapping out the wheels here on the table. So, that 12.57 that you see there, that is the circumference of the four-inch wheels instead of the other two sized wheels that we saw earlier. Obviously, these wheels are a little bit bigger, so the circumference of them, or basically the distance of one wheel turn, should be a little bit bigger, okay? But again, everything is pretty much a little bit bigger in this equation. I'm traveling a bigger distance, my circumference of the wheels is a little bit more.

Okay. So, I have the robot distance that I need to travel for the swing turn, 73.83 inches. How did I get that? Well, the diameter of the circle is two of the robot's track width, which we talked about earlier. So, I multiplied 11.75, which is the track width, times two, and I multiplied that by pi to get the circumference of that circle. The circumference is the total distance around the circle, which is the actual distance that each wheel will need to, or, sorry, one wheel will need to travel for the swing turn. And then dividing both sides by 12.57, which is the circumference of that particular four-inch wheel. That leaves me with turns on the right side and approximately 5.87 on the left side. That means, in order for me to travel that swing turn, one wheel, particularly the left one, will travel 5.87 times. Again, for the swing turn, my right wheel will not be moving. The left wheel will be turning.

Let's test this. I'm gonna give myself just a little bit of room here, 'cause it's a pretty big circle. Okay. Again, one thing I wanna note before we test this, it is a little bit larger of a circle. I may have some slippage here, and I also rounded. So, let's see how accurate we actually are.

(wheels creaking)

Oh, that was almost perfect, actually. So, as you can see what the swing turn looked like, this wheel stayed still, this wheel turned all the way around for 360 degrees. Let's take a look at our motor encoders. Left wheel 5.87, right is reporting 0.02. So, it tried to hold it in place as much as it can, but with friction, it moved slightly.

Okay. What does this show us? Why does this matter that we're actually testing this? Well, this matters because it's showing that all of the math calculations that we did are accurate, and they actually code our robot to go the specific distances and degree measures in turns.

Okay, I do wanna show you the code for that particular swing turn. As you can see, I only have the left motor going forward, there, for 5.87 turns. Because, for a swing turn, the one wheel does not move. Now, if I wanted to turn right instead, I would make the right wheel turn, but I did a, I'm sorry, if I wanted to make a left turn, I would have the right wheel turn. Basically, the direction that you're turning in is the opposite wheel that's powered.

Okay, putting it all together. Coming full circle. What did I ask you in the very beginning? I asked, if I had this competition scenario where I had to autonomously turn 90 degrees and then drive forward for 24 inches using individual motors, what would the code look like? Well, we basically have been building this code throughout this entire Live Session. We're just now putting it all together. So, I did decrease the velocity of the motors here so that we can get some more precision. I'm gonna turn 90 degrees, specifically to the right.

So, as we saw before, we had that 0.91, my left motor going forward, my right motor going in reverse, and then driving forward after I make that turn for 24 inches. We also calculated earlier that that was the 2.78, there. But again, these are different depending on the wheel size, as I mentioned before.

When we were doing the 10.21 wheel size, where we got the 0.91 turns, that was using the medium-sized wheels. And when we did the 2.78 going forward, that was the smaller-sized wheels. So, really, in this scenario, what I did here was the turning 90 degrees was with the medium-sized wheels and the driving forward was with the small-sized wheels. Obviously, that's not going to happen in a real project. So, I would change one of those. But I am going to show you what this looks like, and I'm gonna test it with the medium-sized wheels, just so you can see what actually happens here.

So, again, this is putting it all together, but I do need to adjust that project to account for the correct size wheels, but I am gonna put these on for us, and then we can test them. Putting everything together that we have tested so far. So, I'm putting the medium-sized wheels back on. Again, my calculation for the smaller-sized wheels, the 2.78, needs to change slightly.

Okay. Again, having the traction wheels here on the front. This is also, if you are in a classroom setting, testing all these different calculations with different sized wheels is really interesting to show students. It also gives them an opportunity to test their math calculations. A lot of times, when I was teaching math in a classroom setting, kids would do calculations and had absolutely no way to check if their math was right or not other than me saying, "Yes, that's correct." Being able to use robots is a way for them to get an answer pretty immediately if their calculations were correct.

All right. So, my driving forward, oh, I'm sorry, my turning, no, my driving forward may be a little off, but, 'cause of the wheel size, but let's give this a go.

(wheels creaking)

It started a little bit back there. Okay, a couple things. One, it started about a little over an inch and a half back. And also, I did the wrong size wheel calculations for the 2.78. This is with the smaller wheels, which means they would have to travel farther, because the wheels are smaller, which you are now seeing coming into play, here.

So, again, what did we do? We took our turn calculation and our drive forward calculation and we actually had our robot complete those movements autonomously using individual motor commands.

Now, let's wrap everything up. You can do these math calculations and distances using any size wheel throughout the VEX Continuum. GO wheels, IQ wheels, V5 wheels, EXP wheels, so many different sizes. You can see there, I hyperlinked, there are two different videos in a VEX GO STEM lab where I actually do these exact calculations with 200-millimeter wheels. They're a little bit smaller, so you can see how that affects the drive distance. This also explains all of the math behind both the drive for and turn for blocks that I mentioned earlier to you.

And then, thirdly, one thing that I would suggest that you test yourself, or a very cool application that you can try with your students, is what type of turns would be made if each wheel traveled at a different speed. Would it make a circle, would it make an arc? All of those different types of things. So, if you're wondering exactly what I'm talking about, that's me saying, instead of this remaining still, this travels really slowly and this travels faster. So, if they're traveling at two different speeds, what shape is made? So, definitely something really cool to explore, especially with different sized wheels.

If you have any questions, we can discuss them further in the PD+ Community.

I do want to ask, Audra, I'll ask you very quickly, were there any questions in the chat?

Nope, not yet. Okay. No questions in the chat. So, if you do have questions after this video, or you want to continue the discussion, or maybe you're going to even try the question that I posed, where you set two different-powered wheels to travel at different speeds, and what happens? If you do that, please let me know in our community thread, and maybe even post a video. It's a really, really cool thing to explore, and again, talking about different math calculations and how you can use them.

That being said, I hope that all of this information was helpful, and I can't wait to see you in our next session and also continue to talk to you in our community thread.

I'll see you next time.

(upbeat music)

Share

Like this video? Share it with others!

Additional Resources

Want to join in on a Live Session? Register for upcoming Live Sessions here.

You can also join the conversation about this session in the VEX PD+ Community!