Before installing ROS 2, ensure your system locale is set to UTF-8.
locale # check for UTF-8
sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
locale # verify settingsTo add the ROS 2 apt repository, enable the Ubuntu Universe repository.
sudo apt install software-properties-common
sudo add-apt-repository universeAdd the ROS 2 GPG key with apt.
sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpgThen add the repository to your sources list.
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/nullUpdate your apt repository caches and install ROS 2 packages.
sudo apt update
sudo apt upgrade
sudo apt install ros-humble-desktopInstall development tools.
sudo apt install ros-dev-toolsTo start working with ROS 2, source the setup script in each terminal session.
source /opt/ros/humble/setup.bashTalker-Listener Example
Open a terminal and start a talker node:
source /opt/ros/humble/setup.bash
ros2 run demo_nodes_py talkerOpen another terminal and start a listener node:
source /opt/ros/humble/setup.bash
ros2 run demo_nodes_py listener
sim_vehicle.py -I1 --model JSON #run each instance in differt terminal
sim_vehicle.py -I2 --model JSON
sim_vehicle.py -I3 --model JSON
sim_vehicle.py -I4 --model JSON
gz sim -r -v4 swarm.sdf
python3 sim_leader.py
python3 sim_follower1.py #run each instance in differt terminal
python3 sim_follower2.py
python3 sim_follower3.py