An example robot that demonstrates the capabilities of the ROS2 ecosystem.
- Open a terminal and navigate to a directory of your choice using
lsandcdcommands. - Clone the repository:
git clone https://github.com/treedel/stembot.git cd stembot - Build the packages using:
colcon build
- Source the setup script before running any package (do this in every new terminal):
Make sure you are in the
source install/setup.bashstembotfolder before running the command.
- Launch the Gazebo simulator:
This starts the Gazebo simulator along with supporting nodes to simulate the robot.
ros2 launch stembot_gazebo gazebo.launch.py
- Run the
teleop_twist_keyboardnode in another terminal to control the robot:This node publishes velocity commands (ros2 run teleop_twist_keyboard teleop_twist_keyboard
cmd_vel) based on keyboard inputs.
- Launch the Gazebo simulator with EKF odometry enabled:
ros2 launch stembot_gazebo gazebo.launch.py use_ekf_odom:=true
There are two approaches for this experiment: using a prebuilt node or creating your own.
- Launch the Gazebo simulator:
ros2 launch stembot_gazebo gazebo.launch.py
- Run the
two_point_loopernode in another terminal after sourcing:ros2 run stembot_state_manipulator two_point_looper
- Change to the
srcfolder and create an empty ROS2 package:ros2 pkg create --build-type ament_python --license Apache-2.0 <package_name>
- Navigate to the newly created package directory:
Here, you'll find a
cd src/<package_name>/<package_name>
__init__.pyfile. Create a new Python script for your node in this folder. - Open
setup.py(located insrc/<package_name>) and add an entry point for the node underconsole_scriptsas'<node_name> = <package_name>.<python_file_name>:main'. It should look similar to this:entry_points={ 'console_scripts': [ 'two_point_looper = stembot_state_manipulator.two_point_looper:main' ], },
- Build, source, and run the node:
colcon build source install/setup.bash ros2 run <package_name> <node_name>
Note: You can find reference code in the code folder or the src package files.
- Use the prebuilt
obstacle_avoidernode:ros2 run stembot_obstacle_avoidance obstacle_avoider
- Alternatively, create your own package and implement the obstacle avoidance logic in a custom node.
- Don't forget to launch the simulator before running the node.
- Launch the Gazebo simulator with EKF odometry:
The
ros2 launch stembot_gazebo gazebo.launch.py use_ekf_odom:=true world_name:=shapes.sdf
world_nameis a parameter that accepts demo world names from gazebo (ex: shapes.sdf, empty.sdf, etc) - Launch the SLAM nodes for mapping:
The
ros2 launch stembot_mapping toolbox_oma.launch.py use_sim_time:=true
use_sim_time:=trueparameter tells the system to use Gazebo's simulated clock. - Manually move the robot to explore the environment:
ros2 run teleop_twist_keyboard teleop_twist_keyboard