Drivetrain
Last updated
Last updated
Drivetrain
Drivetrains are the first steps in every engineer’s journey. They refer to any system that allows a robot to move around the field. Learning to control these systems both autonomously and manually is a crucial first step. When building a robot, the two most common types of drivetrains used are 2 motor and 4 motor drives.
2 motor drives come in a variety of forms. They use 2 motors, typically one to power each side of the robot, for locomotion.
They have several advantages:
Simplicity: Easier to build and program compared to more complex drivetrains.
Cost-effective: Requires fewer components, reducing overall cost.
Reliability: Fewer components generally mean fewer potential points of failure.
Power: Can deliver significant power and torque for specific tasks.
Suitable for beginners: Ideal for teams new to FTC robotics.
But they also have several disadvantages:
Limited maneuverability: Difficulty in performing precise turns and movements compared to more complex drivetrains.
Lower power output: Generally less powerful compared to 4-motor drivetrains, especially for heavier robots or demanding tasks.
Increased wear and tear: Due to higher load on each motor, components might degrade faster.
The 4 motor drive is the predominant drivetrain used in FTC and the drivetrain type for both of the test robots. They use 4 motor, typically one for each wheel, for locomotion.
Their advantages are:
Increased power: More motors mean more torque and speed.
Improved traction: Better weight distribution and grip on various surfaces.
Enhanced maneuverability: Greater control and ability to execute complex movements.
Versatility: Can accommodate different drivetrain configurations (tank, mecanum, etc.).
Better performance in challenging conditions: Handles rough terrain and obstacles more effectively.
Their disadvantages are:
Increased complexity: More components and wiring, leading to potential issues.
Higher cost: Requires additional motors and components.
Increased weight: Can impact robot performance.
Advanced programming: Requires more sophisticated control algorithms.
More components to inspect and maintain: With additional motors, gears, and wiring, there are more parts that can potentially fail or malfunction.
In short, 4 motor drives offer superior performance compared to 2 motor drives but require more complicated control methods and maintenance.
4 wheel drives also offer the unique ability to use Mecanum Wheels. By installing the wheels in an X shape, the robot can strafe, or move left and right without turning. This is due to force cancellations by rotating wheels in certain directions, causing a net movement to the overall drivetrain.
Here is a diagram showing how different motor movements can cause different movements.
All VRS simulated robots can use this feature.
Programming
I will be teaching how to program a 4 motor drivetrain as it is the drivetrain all VRS simulated robots use. If you want to learn to use a 2 motor drivetrain, just follow the guide but limit yourself to only using 2 wheels.
Here is a basic diagram of how to motors are named:
Before starting to move the robot, the direction of the motors should be first set. Motors can be set to either “FORWARD” or “REVERSE”. All motors are set by default to “FORWARD”, which means they turn counter-clockwise when given a positive power signal. When a motor is set to “REVERSE”, the motor now turns clockwise when given a positive power signal.
In our robots, the right motors (frontRight, backRight) should be set to reverse so that the robot moves forward when given a positive power signal. Although it might be arduous to have to set the direction of each motor, it makes programming the rest of the robot significantly simpler!
Autonomous:
The most common way to control the robot autonomously is to simply set each motor’s power, sleep the program for some time, and then cut the power to each motor.
But what does this mean?
Let me break it down.
Setting the power
For the lesson I am using a quad block for ease of understanding. You could write the same code using 4 set power blocks or 2 dual set power blocks:
What this code does is that it tells the motors what direction to move and how fast to move it. If the power is positive, the motor moves counter-clockwise. If the power is negative, the motor moves counter-clockwise. The motor power ranges from -1 to 1. The greater the magnitude of the motor, the faster it goes! The power doesn’t have to be a whole number either! It can be a decimal like 0.1 or -0.7.
Figuring out the correct power values to make the robot move how you want to might be a bit confusing but thankfully, due to setting the motor direction from earlier, a simple rule is positive makes the robot go forward, negative makes it go in backwards. By changing how the power values like this:
if you will back to the Mecanum Wheel chart:
If you want to move the robot in other ways, continue to reference the chart. Remember, for a precise strafe, the magnitude of the motors’ power should all be the same. An up arrow represents a positive power and a down arrow represents a negative power.
Feel free to play around with the power though to make the robot move in interesting ways.
Sleeping the program
By calling this block, the program doesn’t execute for the specified amount of milliseconds. This may seem dumb but it has an important purpose: it gives the motor direction in step 1 time to move the robot. Just setting the power of a motor doesn’t make the robot move! Instead it defines the motor’s behavior. To let the motor move the robot, you need to give it time, literally! Sleeping the program will allow the robot time to move around.
Stopping the robot.
To stop the robot, set the power of all motors to 0.
By completely cutting off the power the motor receives, it will completely stop.
Although the robot will automatically stop moving when it has fully executed its code, setting the power to 0 is a helpful way to ensure the robot moves precisely how it was intended.
Typically steps 1 and 2 are repeated several times to create more complex movements before stopping the robot. Step 3 may be incorporated, however, to allow other parts of the robot, like a claw or slide, to move before resuming locomotion.
Manual:
You get to set the controls to whatever you want! Just configure the controls in whatever way feels most intuitive!
Most of your code will be generally structured like this:
After the program has started, you repeat the setting the power for the motors as long as opMode, the designated period to control the robot, is active.
Map how you want the power of each motor to be set to.
The basic sections are:
set [MotorName].Power to which determines which motor is being affected.
Then you either set the motor to a gamepad control, like LeftStickX or RightStickY directly:
or
add a negative marker to reverse the gamepad’s effect on the motor.
Simply repeat the set command until you can control all the motors you want!
Don’t forget that the motor direction can be reversed. This has the same effect as simply putting the negative marker on the control. A negative marker on a reversed motor will cancel out, causing the motor to behave as if it was just directly controlled by the gamepad.
Feel free to experiment with what you have learned and, most importantly, don't forget to have fun!
,
, the robot will strafe right.