This is a ROS2 Jazzy based mecanum drive robot project simulated in Gazebo Harmonic with features such as rotary encoder based odometry, PID kinematics control, directed graph map based motion, and A* pathfinding.
Make sure you have installed ROS2 Jazzy Jalisco, Gazebo Harmonic, common C++ and Python toolchain and the dependencies listed in package.xml
in your environment.
- Clone the repository.
- Change into the repository home directory, then source the environment.
source install/setup.bash
- Build the package with
colcon
.
colcon build --symlink-install
Add this argument if you'd like to use clang
for the workspace:
--cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
A few tips here, run the simulator at 0.01s step size otherwise the robot might rotate endlessly during autonomous mode, and set the odometry_worker
node to a high priority during runtime to avoid latency in odometry calculations.
There are multiple ways to move/interact with the robot:
- Using
/path_command
topic to have the robot find the shortest path and move from one landmark/frame in the map to another. - Using
/trajectory_command
topic to move the robot in a certain simple trajectory in either absolute or relative coordinate reference. - Publishing directly to
/cmd_vel
to control the robot without in an open-loop fashion. - To change speed, set
speed_multiplier
parameter of thekinematics_control
node to a desired value. Default is 1.
This topic uses std_msgs/String
interface with my custom format: "start_frame end_frame"
start_frame
should be the robot's current or closest frame.end_frame
is the goal frame.
Example:
ros2 topic pub /path_command std_msgs/msg/String "{data: 'start end'}" --once
This topic uses std_msgs/String
interface with my custom format: "trajectory/string_arguments/numeric_arguments"
trajectory
type of trajectory or motion for the robot to execute. Available trajectory(s):point
moves robot to a certain coordinate with encoder feedback. Have one string argument with two options: Absoluteabs
and relativerel
coordinate reference. When usingabs
the input coordinate will be calculated relative to the initial point of theworld
frame. When usingrel
the input coordinate will be calculated relative to the robot's current position which is relative to theworld
frame. It has three numeric arguments:x,y,theta
, which are the input coordinates,theta
uses radian.
string_arguments
string arguments that are trajectory specific, separated with comma,
symbol.numeric_arguments
numeric (float) arguments that are trajectory specific, separated with comma,
symbol.
Example:
(Moves the robot to the input coordinate relative to the world
frame.)
ros2 topic pub /trajectory_command std_msgs/msg/String "{data: 'point/abs/2,7,1.57'}"
Compatible with the teleop_twist_keyboard
executable.
These are references and algorithm explanations used in the project.
- Rotary Encoder Based Odometry Youtube: Odometry 101 for FIRST Tech Challenge Robots by DrBatanga
- Locomotion Kinematics Youtube: How to Use Mecanum Wheels in 200 Seconds by Gavin Ford
- A* Pathfinding Algorithm Youtube: A* Pathfinding (E01: algorithm explanation)