Usage
Ticking the Voyager
Ticking voyager is the most essential part of using the library. You are required to call the tick method of the voyager object in order to update almost everything robot related. Without ticking the voyager, the robot will not move and the trajectory will not update. You can call this method in a loop or in a separate thread to update the position of the robot. By not ticking voyager, you also will not be able to use the listeners, playbacks, or zones processing provided by the library.
voyager.tick();
There are also alternative methods to tick the voyager. You can set a tick configuration which allows you to set the tick rate of the voyager. This is useful if you want to control the tick rate. This same configuration file allows you to set a timeout for the voyager. This is useful if you want to stop the voyager after a certain amount of time.
TickConfig tickConfig = new TickConfig();
tickConfig.setDelayMs(10);
tickConfig.setTimeoutMs(10000);
You can also just tickVoyager until voyager is done with a path, or until a Supplier condition is met. If you want, set a timeout for the tickUntil method.
voyager.tickUntil();
voyager.tickUntil(10000);
voyager.tickUntil(() -> voyager.isActive());
voyager.tickUntil(() -> voyager.isActive(), 10000);
GoTo
The goto
method is the primary method used to navigate the vehicle to a specific point. It takes a PointXYZ
object as a parameter and will generate a trajectory to that point. The vehicle will then follow that path until it reaches the target point.
You are required to have already done the following:
.setSpeed(double)
.setAngleTolerance(Angle)
.setTolerance(double)
to set the speed, angle tolerance, and tolerance of the vehicle. You can then know when this path ends by calling the voyager.isActive() method. You can also check if the robot is near another place by calling voyager.isNear(PointXYZ point, double distance, Angle tolerance) which will return true if the robot is within the distance and angle tolerance of the point.
voyager.goto(new PointXYZ(10,0,Angle.fromDeg(90)));
voyager.isNear(new PointXYZ(10,0,Angle.fromDeg(90)), 1, Angle.fromDeg(5));
Manual Control
You can also directly control the robot by using the setTranslation method that is provided by your drivetrain. This takes in a x,y, and rotation value and will directly set the power of the motors to move the robot in that direction. This is useful for teleop or manual control of the robot. The setTranslation method is managed by your drivetrain object and therefor you are required to reference your drivetrain object to use this method.
voyager.getDrive().setTranslation(new Translation(1,0,0));
Stop
To stop your robot you can directly set it's translation to 0. This will stop the robot from moving and will not allow it to move until you update the translation.
voyager.getDrive().setTranslation(Translation.zero());
If you want to clear the trajectories and cancel the current path you can call the clear method.
voyager.clear();