This repository includes multiple examples of ROS2 (Robot Operating System) packages. The objective of the examples in this repository is to show the basic concepts of using and simulating applications that use ROS2.
- my_first_package and my_second_package: simple packages with a message.
- pubsub_package: example on how to create two nodes (publisher and subscriber) and perform comunication between them using a topic.
- parameters_tutorial: this package includes a node with a custom parameter that can be modified via console or launch file.
- interfaces_tutorial: this package includes custom interfaces (messages, services and actions) used in some of the other packages of this workspace.
- srvcli_package: example on how to create a service server and client.
- action_package: example on how to create an action server an a client, it also includes an advanced example on how to cancel and modify actions.
- diff_drive_sim: this package includes the simulation of a differential drive robot using the robotics simulator WEBOTS. The package includes multiple applications like SLAM and navigation.
- diff_drive_sim_gazebo: this package includes a basic simulation of a differential drive robot using the robotics simulator GAZEBO FORTRESS.
- mecanum_robot_sim: this package includes the simulation of a omnidirectional robot with mecanum wheels using the robotics simulator WEBOTS. The package includes multiple applications like SLAM and navigation.
- lifecycle_nodes: this package includes an example on how to use the lifecycle nodes which allow to enable or disable a node using a service.
- rosmasterx3_sim: this package includes the simulation of a Yahboom ROSMASTER X3 omnidirectional robot with mecanum wheels using the robotics simulator WEBOTS. The package includes multiple applications like SLAM, navigation and multirobot systems.
If you are using Windows with WSL, you may need to make some modifications to the network configuration. This applies if you see the following log when running simulations:
[webots_controller_robot] Cannot connect to Webots instance, retrying for another 50 seconds...
...
[webots_controller_robot] Cannot connect to Webots instance, retrying for another 5 seconds...
[webots_controller_robot] Giving up...
[webots_controller_robot] [ros2run]: Process exited with failure 1
[ERROR] [webots_controller_robot-2]: process has died [pid 2287, exit code 1, cmd '/opt/ros/humble/share/webots_ros2_driver/scripts/webots-controller --robot-name=robot --protocol=tcp --ip-address= --port=1234 ros2 --ros-args -p robot_description:=path/robot.urdf'] To correctly configure the connection between Windows and WSL, follow these steps:
- In Windows, open the Command Prompt (CMD) and enter the command
ipconfig. - Look for the section labeled
Ethernet adapter vEthernet (WSL (Hyper-V firewall)). Find the line that saysIPv4 Addressand copy that IP address. This is the connection address for WSL. - In WSL (Linux), go to the
/etcfolder and modify thewsl.conffile to include the following:
[boot]
systemd=true
[network]
generateResolvConf=falseNote: The last line prevents WSL from automatically configuring the IP to connect with Windows, which is the root cause of the conflict.
- Once the file is modified and saved, restart WSL. You can do this by running
wsl --shutdownin the Windows Command Prompt (CMD). - In WSL (Linux), return to the
/etcfolder and modify theresolv.conffile (create it if it does not exist). Add the following content to this file:
nameserver "Insert the IP address copied in step 2"- Restart WSL again using
wsl --shutdown.
IMPORTANT: Verify in your Windows Firewall settings that Webots has permission to connect through both private and public networks.
Complementary material to this repository can be found in my YouTube Channel (NOTE: The videos are in spanish).