Skip to main content

How to declare your chassis?

In lightning declaring your chassis is possibly with the TankChassis class.

warning

At this moment, lightning just supports tank-drive chassis. Support for x-drives comming soon.

If you are not sure what type of drive train your robot has, check this video.


Choose your odometry configurationโ€‹

When declaring your chassis, it is important to provide your odometry configuration.

Odometry is an algorithm that allows you to determine the absolute position and orientation of your robot. With odometry, you can program more sophisticated autonomous routines, as the robot will always know its location.

lightning will ideally apply odometry to your robot based on your configuration.

note

lighting supports odometry with tracking wheels, using the ADI Encoders or the v5 Rotation Sensors.

For more information about odometry, how it works, and how to program it, check this..

Without odometryโ€‹

If you donยดt have tracking wheels in your robot, donยดt worry!. This configuration is for you.

You can declare your chassis without any problems, and still use different autonomous function that will help you to program your autonomous routine in a precise way.

It is important to be aware that some functions would not work in your robot, because that particullar functions need that your robot have odometry.

The motion functions are the following:

  • move_to_point()
  • follow_path()

The telemetry functions are the following:

  • set_coordinates()
  • track_pose()
  • get_pose()
  • get_current_index()
  • get_position()
  • get_ForwardTracker_position()
  • get_SideWays_position()
  • get_orientation()
  • get_x()
  • get_y()

With one tracking wheelโ€‹

If you have just one tracking wheel similar to you can use the following configurations:

Odometry configuration
ADI_ONE_ODOMUse this configuration if you are using the ADI Encoder.
ROTATION_ONE_ODOMUse this configuration if you are using the v5 Rotation Sensor.

One Tracking wheel preview

ONE_TRACKING_WHEEL


With two tracking wheelsโ€‹

If you have just two tracking wheels you can use the following configurations:

Odometry configuration
ADI_TWO_ODOMUse this configuration if you are using the ADI Encoders.
ROTATION_TWO_ODOMUse this configuration if you are using the v5 Rotation Sensors.

Two Tracking wheel preview

TWO_TRACKING_WHEEL


With two rotated tracking wheelsโ€‹

If you have two tracking wheels, you can rotate them by a certain number of degrees. This allows you to make better use of the space on your robot.

Although the tracking wheels will be offset, they will remain perpendicular to each other. Therefore, this configuration is possible.

With Lightning, you can use this configuration.

After declaring your chassis, you can specify the tracking wheels' rotation angle using set_odometry_rotation()

The available configurations are the following:

Odometry configuration
ADI_TWO_ROTATED_ODOMUse this configuration if you are using the ADI Encoders.
ROTATION_TWO_ROTATED_ODOMUse this configuration if you are using the v5 Rotation Sensors.

Two Rotated Tracking wheels preview

TWO_TRACKING_WHEEL


Check your chassis informationโ€‹

To declare your chassis is neccesary to provide important information about your chassis.

Parameters
left_side_portsA vector/list of the left motors ports of the drivetrain (using a negative number will reverse it!).
right_side_portsA vector/list of the right motors ports of the drivetrain (using a negative number will reverse it!).
gyro_portThe IMU port.
gearsetWhat is the cartridge of you drivetrain (blue,green, red)?
wheel_diameterWhat is the side of the drivetrain wheels in inches?
gear_ratioWhat is the gear ratio (Is the result of Driven/Driving, Drive:Driving)?
info

You can create a chassis with n number of motors by side. Just provide the ports of the motors.


Check your odometry information.โ€‹

To declare your chassis is neccesary to provide important information about your odometry configuration.

Parameters
odom_configWhat odometry configuration you would like to use?.
Forward_Tracker_diameterThe wheel diameter of your forward tracker (must to be in inches).
Forward_Tracker_distance_to_centerThe distance that exist between the forward tracker and the robot center point (must to be in inches).
Sideways_Tracker_diameterThe wheel diameter of your sideways tracker (must to be in inches).
Sidways_Tracker_distance_to_centerThe distance that exist between the sideways tracker and the robot center point (must to be in inches).

If you are using ADI Encodersโ€‹

warning

The ADI encoder ports need to be connected together. For example, if the top wire is connected to the 'A' port, the bottom wire needs to be connected to the 'B' port.

In lightning, you indicate the ADI ports using numbers, as follows:

  • 1 -> 'A' port
  • 2 -> 'B' port
  • 3 -> 'C' port
  • 4 -> 'D' port
  • 5 -> 'E' port
  • 6 -> 'F' port
  • 7 -> 'G' port
  • 8 -> 'H' port

Please keep this in mind! Introducing letters to the constructor will not work; use numbers instead.

Parameters
Encoder_Forward_Tracker_portsForward ADI ENCODER PORTS (using a negative number will reverse it!)!
Encoder_SideWays_Tracker_portsSideways ADI ENCODER PORTS (using a negative number will reverse it!), setting -1,-1 would cancel the tracker!

If you are using v5 Rotation Sensorsโ€‹

Parameters
Rotation_Forward_Tracker_portForward V5 ROTATION SENSOR PORT (using a negative number will reverse it!)!
Rotation_SideWays_Tracker_portSideways V5 ROTATION SENSOR PORT (using a negative number will reverse it!)!, setting 0, would cancel the tracker

Declaring NO_ODOMโ€‹

main.cpp
//Chassis declaration, name of my_chassis
lightning::TankChassis my_chassis(
//Odometry configuration/ chassis without odometry
lightning::tank_odom_e_t::NO_ODOM,
//Declaration of drivetrain motors
{-11,-12,-13,-14}, //Left side ports (using a negative number will reverse it!)
{20,19,18,17}, //Right side ports (using a negative number will reverse it!)
5, //IMU port
pros::E_MOTOR_GEAR_600, //Which motor cartride are you using, blue,red,green?
3.25, //Wheel Diameter in inches
1.3333); //what is the gear ratio (Is the result of Driven/Driving, Drive:Driving)

Declaring ADI_ONE_ODOMโ€‹

In this configuration is vital to cancel the sideways tracker, because you are using only one tracking wheel. For this reason, we cancel the sideways tracker by setting the ports in this way {-1,-1}.

main.cpp
//Chassis declaration using just ONE tracking wheel!!!!!! 
lightning::TankChassis my_chassis(
//Odometry configuration, with ADI tracking wheel
lightning::tank_odom_e_t::ADI_ONE_ODOM,
//Declaration of drivetrain motors
{-11,-12,-13,-14}, //Left side ports (using a negative number will reverse it!)
{20,19,18,17}, //Right side ports (using a negative number will reverse it!)
5, //IMU port
pros::E_MOTOR_GEAR_600, //Which motor cartride are you using, blue,red,green?
3.25, //Wheel Diameter in inches
1.3333, //what is the gear ratio (Is the result of Driven/Driving, Drive:Driving)

{-1,-2}, //Forward ADI ENCODER PORTS (using a negative number will reverse it!), top wire is connected to A and the bottom wire is connected to B.

2.507, //Forward tracking wheel diameter in inches
1.783, //Distance that exist between the forward tracker and the robot rotation center.

{-1,-1},//SIDEWAYS ADI ENCODER PORTS (using a negative number will reverse it!), setting -1,-1 would cancel the tracker!
0, //Sideways tracking wheel diameter
0); //Distance that exist between the Sideways tracker and the robot rotation center.

Declaring ADI_TWO_ODOMโ€‹

main.cpp
//Chassis declaration using just ONE tracking wheel!!!!!! 
lightning::TankChassis my_chassis(
//Odometry configuration, with ADI tracking wheel
lightning::tank_odom_e_t::ADI_TWO_ODOM,
//Declaration of drivetrain motors
{-11,-12,-13,-14}, //Left side ports (using a negative number will reverse it!)
{20,19,18,17}, //Right side ports (using a negative number will reverse it!)
5, //IMU port
pros::E_MOTOR_GEAR_600, //Which motor cartride are you using, blue,red,green?
3.25, //Wheel Diameter in inches
1.3333, //what is the gear ratio (Is the result of Driven/Driving, Drive:Driving)

{-1,-2}, //Forward ADI ENCODER PORTS (using a negative number will reverse it!), top wire is connected to A and the bottom wire is connected to B.

2.507, //Forward tracking wheel diameter in inches
1.783, //Distance that exist between the forward tracker and the robot rotation center.

{-3,-4},//SIDEWAYS ADI ENCODER PORTS (using a negative number will reverse it!), setting -1,-1 would cancel the tracker!,
//top wire is connected to C and the bottom wire is connected to D.

2.507, //Sideways tracking wheel diameter
1.783); //Distance that exist between the Sideways tracker and the robot rotation center.

Declaring ADI_TWO_ROTATED_ODOMโ€‹

main.cpp
//Chassis declaration using just ONE tracking wheel!!!!!! 
lightning::TankChassis my_chassis(
//Odometry configuration, with ADI tracking wheel
lightning::tank_odom_e_t::ADI_TWO_ROTATED_ODOM,
//Declaration of drivetrain motors
{-11,-12,-13,-14}, //Left side ports (using a negative number will reverse it!)
{20,19,18,17}, //Right side ports (using a negative number will reverse it!)
5, //IMU port
pros::E_MOTOR_GEAR_600, //Which motor cartride are you using, blue,red,green?
3.25, //Wheel Diameter in inches
1.3333, //what is the gear ratio (Is the result of Driven/Driving, Drive:Driving)

{-1,-2}, //Forward ADI ENCODER PORTS (using a negative number will reverse it!), top wire is connected to A and the bottom wire is connected to B.

2.507, //Forward tracking wheel diameter in inches
1.783, //Distance that exist between the forward tracker and the robot rotation center.

{-3,-4},//SIDEWAYS ADI ENCODER PORTS (using a negative number will reverse it!), setting -1,-1 would cancel the tracker!,
//top wire is connected to C and the bottom wire is connected to D.

2.507, //Sideways tracking wheel diameter
1.783); //Distance that exist between the Sideways tracker and the robot rotation center.

void initialize(){
//the tracking wheel are rotated -45 degrees from the robots center rotation
my_chassis.set_odometry_rotation(-45);
}

Declaring ROTATION_ONE_ODOMโ€‹

In this configuration is vital to cancel the sideways tracker, because you are using only one tracking wheel. For this reason, we cancel the sideways tracker by setting the port in 0.

main.cpp
//Chassis declaration using just ONE tracking wheel!!!!!! 
lightning::TankChassis my_chassis(
//Odometry configuration
lightning::tank_odom_e_t::ROTATION_ONE_ODOM,
//Declaration of drivetrain motors
{-11,-12,-13,-14}, //Left side ports (using a negative number will reverse it!)
{20,19,18,17}, //Right side ports (using a negative number will reverse it!)
5, //IMU port
pros::E_MOTOR_GEAR_600, //Which motor cartride are you using, blue,red,green?
3.25, //Wheel Diameter
1.3333, //what is the gear ratio (Is the result of Driven/Driving, Drive:Driving)

1, //Forward V5 ROTATION SENSOR PORT (using a negative number will reverse it!),
2.507, //Forward tracking wheel diameter
1.783, //Distance that exist between the forward tracker and the robot rotation center.

0,//Sideways V5 ROTATION SENSOR PORT (using a negative number will reverse it!), setting 0 would cancel the tracker!
0, //Sideways tracking wheel diameter
0 //Distance that exist between the Sideways tracker and the robot rotation center.
);

Declaring ROTATION_TWO_ODOMโ€‹

main.cpp
//Chassis declaration using TWO tracking wheels!!!!!! 
lightning::TankChassis my_chassis(
//Odometry configuration
lightning::tank_odom_e_t::ROTATION_TWO_ODOM,
//Declaration of drivetrain motors
{-11,-12,-13,-14}, //Left side ports (using a negative number will reverse it!)
{20,19,18,17}, //Right side ports (using a negative number will reverse it!)
5, //IMU port
pros::E_MOTOR_GEAR_600, //Which motor cartride are you using, blue,red,green?
3.25, //Wheel Diameter
1.3333, //what is the gear ratio (Is the result of Driven/Driving, Drive:Driving)
1, //Forward V5 ROTATION SENSOR PORT (using a negative number will reverse it!)
2.507, //Forward tracking wheel diameter
1.783, //Distance that exist between the forward tracker and the robot rotation center.

2,//Sideways V5 ROTATION SENSOR PORT (using a negative number will reverse it!), setting 0 would cancel the tracker!
2.507, //Sideways tracking wheel diameter
1.783); //Distance that exist between the Sideways tracker and the robot rotation center.

Declaring ROTATION_TWO_ROTATED_ODOMโ€‹

main.cpp
//Chassis declaration using TWO ROTATED tracking wheels!!!!!! 
lightning::TankChassis my_chassis(
//Odometry configuration
lightning::tank_odom_e_t::ROTATION_TWO_ROTATED_ODOM,
//Declaration of drivetrain motors
{-11,-12,-13,-14}, //Left side ports (using a negative number will reverse it!)
{20,19,18,17}, //Right side ports (using a negative number will reverse it!)
5, //IMU port
pros::E_MOTOR_GEAR_600, //Which motor cartride are you using, blue,red,green?
3.25, //Wheel Diameter
1.3333, //what is the gear ratio (Is the result of Driven/Driving, Drive:Driving)

1, //Forward V5 ROTATION SENSOR PORT (using a negative number will reverse it!)
2.507, //Forward tracking wheel diameter
1.783, //Distance that exist between the forward tracker and the robot rotation center.

2,//Sidways V5 ROTATION SENSOR PORT (using a negative number will reverse it!), setting 0 would cancel the tracker!
2.507, //Sideways tracking wheel diameter
1.783); //Distance that exist between the Sideways tracker and the robot rotation center.
void initialize(){
//the tracking wheel are rotated -45 degrees from the robots center rotation
my_chassis.set_odometry_rotation(-45);
}

Program autonomous routines ๐Ÿค– and driver period ๐ŸŽฎโ€‹

Now, you can start programming!

tip

Check the tutorials to know how program an autonomous routines and the driver period.

Check how to program the autonomous routines and the driver period.