Clone Repository
git clone git@github.com:KPI-Rover/ros_ws.git
cd ros_wsInstall Packages Using vcstool
vcs import src < kpi-rover.repos❗ Important: Run all next commands from the root of the ROS workspace (ros_ws folder) unless specified otherwise.
❗ Important: All pull requests must include source code that has been built and executed using Docker. CI integration following this approach will be added soon.
Build Docker
docker build -t kpi-rover . -f docker/Dockerfile.simBuild Project
docker run --rm -it \
--user $(id -u):$(id -g) \
-v $(pwd):/workspace \
-w /workspace \
kpi-rover colcon buildLaunch Simulation
docker run --rm -it \
--init \
--network=host \
--user $(id -u):$(id -g) \
-v $(pwd):/workspace \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v ~/.gz:/home/ubuntu/.gz \
-w /workspace \
-e ROS_DOMAIN_ID=1 \
-e GZ_PARTITION=1 \
kpi-rover \
bash -c "
source /opt/ros/jazzy/setup.bash \
&& source install/setup.bash \
&& ros2 launch kpi_rover launch_sim.launch.py"Gazebo runs very slowly in Docker. Because of this, we need to run the project locally to make it work faster.
To avoid problems with missing packages, always add new packages to the package.xml file. This helps to install them easily using the rosdep tool.
Install ROS Dependencies
rosdep update
rosdep install --from-paths src --ignore-src -r -ySource ROS2 (If Not Added to .bashrc)
source /opt/ros/jazzy/setup.bashBuild Project
colcon buildLaunch Simulation
source install/setup.bash
ros2 launch kpi_rover launch_sim.launch.pyNote: RPI, BBB and PC should be connected to the common network.
Install udev rules for the lidar
cd ~/ros_ws/src/lidar_coin_d4a
sudo cp sc_mini.rules /etc/udev/rules.dBuild Docker
cd ~/ros_ws
docker build -t kpi-rover . -f docker/Dockerfile.rpiBuild Project
docker run --rm -it \
--user $(id -u):$(id -g) \
-v $(pwd):/workspace \
-w /workspace \
kpi-rover colcon buildCreate system services
- For DDS server to establish communication between nodes through the network
- Create /etc/systemd/system/fastdds.service system service file with the following contents. You need sudo permission to do this.
[Unit]
After=network-online.target
Description=DDS server for ROS2 node comunication through network
[Service]
User=vik
Group=vik
ExecStart=fastdds discovery -i 0
Restart=always
RestartSec=5s
[Install]
WantedBy=default.target
- Enable and start the service.
sudo systemctl enable fastdds.service
sudo systemctl start fastdds.service- For running ROS nodes
- Create /etc/systemd/system/kpi-rover.service system service file with the following contents. You need sudo permission to do this.
[Unit]
After=network-online.target
After=docker.service
Requires=docker.service
After=fastdds.service
Description=ROS2 autonomous robot services
[Service]
User=<user>
Group=<group>
ExecStart= bash -c "${HOME}/ros_ws/run.sh -b <bbb_ip>"
TimeoutStartSec=0
Restart=always
RestartSec=2s
[Install]
WantedBy=default.target
- Enable and start the service.
sudo systemctl enable kpi-rover.service
sudo systemctl start kpi-rover.serviceexport ROS_DISCOVERY_SERVER=<ip of the RPI>:11811cd ~/ros_ws
source install/setup.bash
ros2 launch kpi_rover launch_visualization.launch.py This section holds temporary, unorganized notes.
ros2 run teleop_twist_keyboard teleop_twist_keyboard \
--ros-args \
-r /cmd_vel:=/diff_drive_base_controller/cmd_vel \
-p stamped:=True \
-p frame_id:=base_linkros2 launch cspc_lidar demo.launch.pyA DDS (Data Distribution Service) server facilitates real-time data exchange between distributed ROS2 nodes over the network. Using a DDS server ensures seamless communication between components, particularly when a PC has multiple network interfaces. It helps in optimizing discovery mechanisms and maintaining robust connectivity.
fastdds discovery -i 0docker run --rm -it \
--init \
--user $(id -u):$(id -g) \
-v $(pwd):/workspace \
-w /workspace \
-e ROS_DISCOVERY_SERVER=172.17.0.1:11811 \
-e ROS_DOMAIN_ID=1 \
-e IGN_DISCOVERY_URI=tcp://172.17.0.1:11811 \
-e FASTRTPS_DEFAULT_PROFILES_FILE=/workspace/super_client_cfg_file.xml \
-e GZ_PARTITION=1 \
kpi-rover \
bash -c "
source /opt/ros/jazzy/setup.bash \
&& source install/setup.bash \
&& ros2 launch apricotka-robot-car launch_sim.launch.py"- Add entrypoint to surce source install/setup.bash
- Create Docker container for RPI
- How to use gamepad