//
you're reading...
leJOS Features, Moving around

LeJOS navigation: The Chassis

Differential dragster

This dragster has a differential setup. It steers by controlling the speed of both rear wheels independently. The front wheels swivel freely and automatically adjust their position when making a corner.

The next version of leJOS EV3 (the one after 0.9.0-beta) will bring a new addition the the navigation classes, the Chassis. It serves as an abstraction of the drivetrain of a mobile robot and translates movements of the robot into instructions to the motors. The Chassis encapsulates the the math involved in this process and makes it more easy to write programs for your mobile robot. The Chassis is a split-off from the Pilots, the Chassis taking over the calculations needed to drive the motors. The pilot still taking care of communication with the other navigation classes and offering a much richer set of instructions.

The Chassis brings something new in respect to the Pilots: an API based on velocity. This API is very useful for applications where the pilots performed poorly, like for example line following robots or remote controlled robots. Later in this post I will discuss the velocity based API. But first I will explain ho to create an instance of the Chassis and how to use this instance with a pilot. The Chassis is an interface that currently has just one implementation, the WheeledChassis. This implementation can be used for both differential and holonomic robots.

Constructing a Chassis
The task of the Chassis is to translate a movement of a robot into instructions to the robots actuators. To be able to do so the Chassis must know what the  robot looks like. What is the position of its wheels, which motor drives which wheel, is there a gear train, what is the size of the wheels? All this information must be provided while creating an instance of the Chassis. To help you to describe your robot  the WheeledChassis has some helper classes that help you model individual wheels. Here is an example where the two wheels of a differential robot are described first, then a Chassis object is created using the wheels.

Wheel leftWheel = WheeledChassis.modelWheel(Motor.A, 42.2).offset(72).gearRatio(2);
Wheel rightWheel = WheeledChassis.modelWheel(Motor.B, 42.2).offset(-72).gearRatio(2);
Chassis myChassis = new WheeledChassis( new Wheel[]{leftWheel, rightWheel}, WheeledChassis.TYPE_DIFFERENTIAL);

And here is an example for creating a holonomic robot.

Wheel wheel1 = WheeledChassis.modelHolonomicWheel(Motor.A, 48).polarPosition(0, 135).gearRatio(2);
Wheel wheel2 = WheeledChassis.modelHolonomicWheel(Motor.B, 48).polarPosition(120, 135).gearRatio(2);
Wheel wheel3 = WheeledChassis.modelHolonomicWheel(Motor.C, 48).polarPosition(240, 135).gearRatio(2);
Chassis myChassis = new WheeledChassis(new Wheel[]{wheel1, wheel2, wheel3}, WheeledChassis.TYPE_HOLONOMIC);

The new MovePilot will accept a Chassis object in its constructor.

pilot = new MovePilot(chassis);

As you can see from this constructor the MovePilot can be used with any Chassis, be it differential, holonomic or any other implementation of a Chassis.  So if you have a walking robot and model it as a Chassis you then would have the complete navigation stack at your disposal.
The different pilots currently offered by leJOS can only handle a single type of platform, these will be replaced by the new MovePilot in the next version of leJOS EV3.

A holonomic Robot

A holonomic robot can travel in any direction or rotate on the spot. The image links to the building instructions of this robot.

The velocity based API
The leJOS pilot uses a move based API. Every movement that the robot makes is specified in terms of geometric primitives, like a line, an arc or a rotation. The move based API also assumes that the robot is motionless at the start of a move and will be motionless again at the end of a move.
The Chassis supports this API, but besides that it supports an API that is based on velocity. The velocity based API basically is just one method, setVelocity(double linearSpeed, double angularSpeed), that you use to set the speed of the robot. As you can see from the method signature the API uses two kinds of speed, linear speed and angular speed. These two components determine the overall motion of the robot. It takes some time to get used to thinking of velocity this way but for some applications this is very powerful. Let us take the example of a line follower. To keep the line follower on track a program controls the angular speed of the robot. If it is exactly on track the angular speed can be set to zero, and the robot goes straight ahead. If the robot veers of to the right the angular speed can be set to a positive value to make the robot turn to the left. So the control mechanism of the line follower controls the angular speed. Linear speed can be controlled independently by some other mechanism.

A differential robot can only drive forward and backward, but a holonomic robot can go in any direction. Therefor the linear speed component of a holonomic robot not only has magnitude, it also has direction. To support this ability of holonomic robots there is a setVelocity method that accpts direction as a parameter:  setVelocity(double linearSpeed, double direction, double angularSpeed).

The Chassis uses acceleration settings to control the acceleration of the robot. It will also make sure that the acceleration of each of the wheels is such that all wheels will always reach final  speed at the same time. This results in smooth speed transitions of the robot.

Odometry
The Chassis offers an alternative PoseProvider to the OdometryPoseProvider that is used together with the pilot. This PoseProvider (get it with the getPoseProvider method) polls the tacho’s of the motors at a high frequency and integrates the changes in position to keep track of the robots Pose. You need to use this PoseProvider when using the velocity based API. The OdometryPoseProvider works with pilots only as it integrates moves. The alternative PoseProvider will also work with a pilot, but then the OdometryPoseProvider might be a better alternative as this one uses less CPU time.

Number of wheels
The WheeledChassis works with an unlimited number of wheels, It happily supports a differential or a holonomic robot with four wheels. But for the robot to be controllable there are some constraints. A differential Chassis needs at least two wheels and all its wheels must be located on the y-axis. A holonomic chassis needs at least three wheels, at least three of them must be placed at a different angles.

Advertisements

Discussion

4 thoughts on “LeJOS navigation: The Chassis

  1. Good article! Excited to get to grips with the new classes. Could you clarify what is meant by wheel offset though? The documentation says its the distance between the robots yPose-axis and the center of the wheel but I’m not sure what is meant by yPose-axis?

    Posted by Olly | 2016/01/27, 14:11
    • Hi,

      The offset of a wheel is the distance between the center of the robot (the origin of vector V in the picture) and the center of the wheel (the origin of vector Vleft or Vright in the picture). In a symmetrical robot it is equal to half the wheel base (L in the picture), but with a sign to distinguish between left and right wheels.

      The WheeledChassis does not demand that a robot is symmetrical. If you like to control some wacky shaped robot the Chassis will support this. This is one reason why you do need to specify the offset of all individual wheels instead of the wheel base for the robot. I will improve the documentation.

      Posted by Aswin | 2016/01/27, 23:25
  2. This dragster looks awesome! Would you have by any chance the building directions for my 4th graders?

    Posted by Ana | 2016/07/20, 18:43

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

About leJOS News

leJOS News keeps you up-to-date with leJOS. It features latest news, explains cool features, shows advanced techniques and highlights amazing projects. Be sure to subscribe to leJOS News and never miss an article again. Best of all, subscription is free!
Follow leJOS News on WordPress.com
%d bloggers like this: