Welcome to the basic ROS workshop! This tutorial is designed to introduce you to the fundamental concepts of ROS, along with practical hands-on exercises using the Turtlesim package. By the end of this workshop, you will have a basic understanding of ROS architecture, its commands, and how to control a simulated turtle in Turtlesim.
- Basic knowledge of Linux commands
- Ubuntu (preferably 18.04 or 20.04)
- ROS melodic installed on your machine
- Introduction to ROS
- ROS Concepts
- ROS Master
- ROS Nodes
- ROS Topics
- ROS Services
- ROS Actions
- Basic ROS Commands
- Working with Turtlesim
- Conclusion
ROS (Robot Operating System) is an open-source, flexible framework for writing robot software. It provides tools, libraries, and conventions to simplify the task of creating complex and robust robot behavior across a wide variety of robotic platforms.
The ROS Master provides naming and registration services to the rest of the ROS system. It enables nodes to locate each other and manage communications.
Nodes are the basic processes that perform computation in ROS. Each node is designed to execute a specific task, and nodes can communicate with each other to build a complete robotic system.
Topics are named buses over which nodes exchange messages. A node can publish messages to a topic, and other nodes can subscribe to that topic to receive those messages. This communication method is asynchronous.
Services in ROS provide a synchronous communication mechanism between nodes. A service consists of a request and a response. A node can call a service to request a specific action, and the service will respond once the action is complete.
Actions in ROS are designed for tasks that take an extended period and can be preempted. They provide a way to send goals to a server, receive feedback during execution, and get a result when the task is completed. Actions are particularly useful for long-running or continuous tasks.
source /opt/ros/melodic/setup.bash
-
Create a directory for your workspace:
mkdir -p ~/ros_workspace/src
-
Initialize the workspace:
cd ~/ros_workspace/src catkin_init_workspace
-
Build the workspace:
cd ~/ros_workspace catkin_make
-
Source the workspace:
source devel/setup.bash
- Starting ROS Master:
roscore
- Creating a New Package:
catkin_create_pkg <package_name> std_msgs rospy roscpp
- Listing ROS Nodes:
rosnode list
- Displaying Node Information:
rosnode info /node_name
- Listing ROS Topics:
rostopic list
- Displaying Topic Information:
rostopic info /topic_name
- Publishing to a Topic:
rostopic pub /topic_name std_msgs/String "data: 'Hello, ROS!'"
- Subscribing to a Topic:
rostopic echo /topic_name
- Running a ROS Node:
rosrun <package_name> <node_name>
sudo apt-get install ros-melodic-turtlesim
-
Open a terminal and start the ROS Master:
roscore
-
In a new terminal, launch Turtlesim:
rosrun turtlesim turtlesim_node
-
In another terminal, open the Turtlesim Teleop Key:
rosrun turtlesim turtle_teleop_key
-
List nodes:
rosnode list
This will show you the nodes that are currently running, including
/rosout
and/turtlesim
. -
Node information:
rosnode info /turtlesim
This command provides information about the
/turtlesim
node, such as the topics it publishes and subscribes to.
-
List topics:
rostopic list
This will display all the active topics, including
/turtle1/cmd_vel
and/turtle1/pose
. -
Topic information:
rostopic info /turtle1/pose
This command shows details about the
/turtle1/pose
topic, including the type of messages and the nodes publishing and subscribing to it. -
Echo topic:
rostopic echo /turtle1/pose
This command prints messages being published to the
/turtle1/pose
topic, showing the turtle's position in real-time.
-
List services:
rosservice list
This lists all available services, such as
/clear
and/spawn
. -
Service information:
rosservice info /spawn
This provides information about the
/spawn
service. -
Call service:
rosservice call /spawn 2 2 0.2 "turtle2"
This spawns a new turtle at the specified coordinates with the name "turtle2".
- List actions: There are no default actions with Turtlesim, but you can explore actions with other ROS packages that support actions, such as the navigation stack.
- Action information: To understand actions, you typically need a package that defines action servers and clients. Actions involve more complex interactions than services, suitable for tasks that provide feedback and can be preempted.
-
Create a new package: Follow the instructions to create a package and set up your workspace.
-
Create a Python script: Write a script to move the turtle in a pattern using the
geometry_msgs/Twist
message type. -
Run the script: Execute the script using
rosrun
and observe the turtle's movements in the Turtlesim window.
Congratulations! You have completed the basic ROS workshop. You now have a foundational understanding of ROS concepts, commands, and how to work with the Turtlesim package. Additionally, you have learned about ROS services, actions, and the role of the ROS Master in managing communications. Keep exploring ROS to build more complex and exciting robotic applications.
Happy coding!
Welcome to the TurtleBot3 simulation workshop! This tutorial will guide you through setting up and using TurtleBot3 in a simulated environment using RViz and Gazebo. You will learn how to perform basic movements, SLAM (Simultaneous Localization and Mapping), save maps, and navigate autonomously.
- Basic knowledge of Linux commands
- Ubuntu (preferably 18.04 or 20.04)
- ROS melodic installed on your machine
- TurtleBot3 packages installed
- Introduction to TurtleBot3
- Basic Setup
- RViz Simulation
- Gazebo Simulation
- Empty World
- Predefined World
- Teleoperation
- SLAM
- Map Saving
- Autonomous Navigation
TurtleBot3 is a low-cost, personal robot kit with open-source software. It is designed to support education, research, and product prototyping.
-
Install TurtleBot3 packages:
sudo apt-get update sudo apt-get install ros-melodic-turtlebot3 ros-melodic-turtlebot3-simulations
-
Set the TurtleBot3 model environment variable:
echo "export TURTLEBOT3_MODEL=burger" >> ~/.bashrc source ~/.bashrc
-
Open a terminal and start the ROS Master:
roscore
-
In a new terminal, launch the TurtleBot3 simulation in RViz:
roslaunch turtlebot3_fake turtlebot3_fake.launch
-
RViz will start, showing the TurtleBot3 model. You can use RViz to visualize different sensor data and robot states.
- Open a terminal and launch Gazebo with an empty world:
roslaunch turtlebot3_gazebo turtlebot3_empty_world.launch
- Open a terminal and launch Gazebo with a predefined world:
roslaunch turtlebot3_gazebo turtlebot3_world.launch
- Open a terminal and run the teleop node to control TurtleBot3:
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
- Use the keyboard to move the robot around the simulation.
-
Open a terminal and launch the TurtleBot3 in a Gazebo world:
roslaunch turtlebot3_gazebo turtlebot3_world.launch
-
In a new terminal, start the SLAM node:
roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping
-
In another terminal, run the teleop node to control the robot and explore the environment:
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
-
Move the robot around to create a map in RViz.
-
Once you are satisfied with the map created, save it using the following command in a new terminal:
rosrun map_server map_saver -f ~/map
-
This will save the map as
map.pgm
andmap.yaml
in your home directory.
-
Launch the TurtleBot3 in a Gazebo world:
roslaunch turtlebot3_gazebo turtlebot3_world.launch
-
Launch the navigation stack with your saved map:
roslaunch turtlebot3_navigation turtlebot3_navigation.launch map_file:=$HOME/map.yaml
-
Use RViz to set an initial pose estimate:
- Click on the "2D Pose Estimate" button and click on the map to set the initial pose.
-
Use RViz to set a goal for autonomous navigation:
- Click on the "2D Nav Goal" button and click on the map to set the target destination.
Congratulations! You have completed the TurtleBot3 simulation workshop. You now have a foundational understanding of simulating TurtleBot3 using RViz and Gazebo, performing SLAM, saving maps, and navigating autonomously. Keep exploring and building upon these skills to create more advanced robotic applications.
Happy coding!