This is a brief guide to our project's motion-planning module. This GitHub repository has all of the code necessary to run the robot manually, run it autonomously either based on time or distance, and generate a spline and display it with Python's Turtle module.
We are managing our dependencies with GradleRIO. You can check out the build.gradle for more info.
If you're interested in what the actual robot code looks like, check out this section. We included it mainly because the code doesn't make sense without this. If not, move to the Path Finding section.
RobotMap: declares motors, encoders, and other I/O devices connected to the RoboRIO
OI: binds controller buttons and joysticks to commands
Robot: connects everything and runs it all
Subsystems: describe parts of the robot (groups of motors and sensors) that are controlled independently
Commands: define actions that act on a specific subsystem (for instance, DriveDistance acts on the Drivetrain subsystem)
CommandGroups: allow chaining groups of subsystems together, either sequentially or in parallel
This is mainly what we worked on for the AP Computer Science Project. All files referenced are here. If you're confused on how the spline path is generated, see here. If you want to visualize how the discrete points are generated from the path, see here.
Note: the interfaces are not included for brevity, but every geometric object has an interface
- Rotation2D: Data type for rotation/heading of robot
- Translation2D: Data type for location of robot
- Pose2D: Combines Rotation2D and Translation2D for a position object
- Pose2DWithCurvature: Adds curvature to Pose2D; makes it easier to follow the path
- Trajectory: A list of Pose2D
- CSVEditor: A class for creating, saving CSV files; calling this main method will run the code
- CubicSpline: Draws a spline between two poses; has utility functions for splines
- PathGenerator
- Draw a spline between each waypoint
- Sample the spline and connect each sampled points with linear segments
- Use the linear segments as an approximation for finding equidistant points on the spline
- path_draw.py: reads the csv file (command-line argument) and draws the path using Python Turtle
- Run CSVEditor.java to generate the path
- Run path_draw.py to visualize the path