IT/Robot

[ROS2] Install & Turtlebot3 Simulation

루벤초이 2022. 3. 3. 16:16

Let's install ROS2 Foxy(Humble) to Ubuntu 20.04 (22.04) LTS and play with the robot using turtlebot3 simulation.

Ubuntu 20.04

ROS2 Foxy

Follow the instruction from https://docs.ros.org/en/foxy/Installation/Ubuntu-Install-Debians.html it's so easy!

 

Ubuntu (Debian) — ROS 2 Documentation: Foxy documentation

Make sure you have a locale which supports UTF-8. If you are in a minimal environment (such as a docker container), the locale may be something minimal like POSIX. We test with the following settings. However, it should be fine if you’re using a differen

docs.ros.org

Turtlebot3 Foxy

Follow the instruction from https://emanual.robotis.com/docs/en/platform/turtlebot3/quick-start/

Don't forget to select Foxy and begin with 3.1.3 section since ROS2 is already installed.

 

ROBOTIS e-Manual

 

emanual.robotis.com

Turtlebot3 Simulation Foxy

Follow the instruction from https://emanual.robotis.com/docs/en/platform/turtlebot3/simulation/

Run

ros2 launch turtlebot3_gazebo turtlebot3_house.launch.py
(or ros2 launch turtlebot3_gazebo empty_world.launch.py)

(In new terminal,)
ros2 run teleop_twist_keyboard teleop_twist_keyboard

Troubleshoots

Problem

To use Cyclone DDS

Solution

sudo apt-get install -y ros-foxy-rmw-cyclonedds-cpp

export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp

Problem

[gzclient   -2] X Error of failed request:  BadValue (integer parameter out of range for operation)

Solution

install NVIDIA driver 

 

Ubuntu 22.04

ROS2 Humble

Follow the instruction from https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html

Turtlebot3 Humble

Follow the instruction from https://emanual.robotis.com/docs/en/platform/turtlebot3/quick-start/ replacing foxy to humble

For example, sudo apt-get install ros-humble-gazebo-*

Troubleshoots

Problem 

[ERROR] [1672108143.603458451] [spawn_entity]: Service %s/spawn_entity unavailable. Was Gazebo started with GazeboRosFactory?
[ERROR] [1672108143.603828040] [spawn_entity]: Spawn service failed. Exiting.

Solution

export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:~/turtlebot3_ws/src/turtlebot3_simulations/turtlebot3_gazebo/models

Problem

[gazebo-2] process has died [pid 32212, exit code 255, ... gzserver

Solution

killall gzserver / killall gzclient

 

Docker

Humble Turtlebot3 Gazebo (X11)

Remember that ROS2 versions of Docker and Local PC must be same as it shares turtlebot3_simulations.

  • docker pull osrf/ros:humble-desktop
  • docker run --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" --volume="/home/ruben/turtlebot3_ws:/root/turtlebot3_ws" -it --rm --privileged osrf/ros:humble-desktop /bin/bash
  • sudo apt update
  • sudo apt-get install ros-humble-gazebo-*
  • sudo apt install ros-humble-cartographer
  • sudo apt install ros-humble-cartographer-ros
  • sudo apt install ros-humble-navigation2
  • sudo apt install ros-humble-nav2-bringup
  • sudo apt install ros-humble-dynamixel-sdk 
  • sudo apt install ros-humble-turtlebot3-msgs 
  • sudo apt install ros-humble-turtlebot3
  • echo 'export ROS_DOMAIN_ID=30' >> ~/.bashrc 
  • source ~/.bashrc
  • (In new terminal) docker commit <container ID> <name>
  • xhost +local:docker
    • It causes protocol error without this line (or xhost -local:docker also causes protocol error)
  • docker run --net=host -e DISPLAY=$DISPLAY --volume="$HOME/.Xauthority:/root/.Xauthority:rw" --volume="/home/ruben/turtlebot3_ws:/home/ruben/turtlebot3_ws" -it --rm --privileged <image_ID> /bin/bash
    • the directory should be same otherwise it causes an link error.
  • (in new terminal) docker exec -it <container ID> bash
  • source /opt/ros/humble/setup.bash
  • source /home/ruben/turtlebot3_ws/install/setup.bash
  • export TURTLEBOT3_MODEL=burger
  • ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py
    • works properly in Foxy, but error on Humble
    • (In humble) error log: Service %s/spawn_entity unavailable. Was Gazebo started with GazeboRosFactory? 
    • It does not work with 'export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:/home/ruben/turtlebot3_ws/src/turtlebot3_simulations/turtlebot3_gazebo/models'

 

Reference

 

728x90
반응형

'IT > Robot' 카테고리의 다른 글

[ROS2] Turtlebot3  (0) 2023.01.22
[ROS2] Rosbridge_suite & websocket secure  (1) 2022.03.25
[ROS2] CLOi ROS2 Simulator  (2) 2022.03.06