Skip to content
markuskPublic

About

My robot for my YouTube channel 'Markus Knapp - Einfach machen'

Resources

Stars

2 stars

Watchers

1 watching

Forks

Repository files navigation

rosbot

ROS 2 control software for a four-wheel omniwheel robot running on a Raspberry Pi. The active package targets ROS 2 Jazzy and is located at ROS/colcon_workspace/src/rosbot. The ROS/rosbot.old__TMP!__migrating_to_ros2_!/ directory is a legacy ROS 1 archive; its nodes and launch files are not used by the ROS 2 build.

Requirements

  • ROS 2 Jazzy on Ubuntu. For Raspberry Pi installation, see the ROS 2 Raspberry Pi installation guide.
  • colcon and rosdep.
  • On the robot: gpiozero for GPIO control.
  • Optional devices: a Linux-compatible gamepad, a libcamera-supported Raspberry Pi camera with camera_ros, and/or a Hokuyo URG-LX04-UG01 with urg_node.

One-time setup

Do these steps once for each computer or Raspberry Pi where you want to build or run the package.

1. Get the source

git clone https://github.com/markusk/rosbot.git
cd rosbot

If the repository is already cloned, use its existing directory instead.

2. Install ROS dependencies and build

source /opt/ros/jazzy/setup.bash
cd ROS/colcon_workspace
rosdep install --from-paths src --ignore-src -r -y
colcon build --symlink-install --packages-select rosbot

rosdep install installs the package dependencies, including the ROS joystick, camera, and laser drivers. Optional devices still need to be physically connected and configured. Re-run dependency installation if package dependencies change; rebuild after changing source code.

3. Configure the Raspberry Pi for motor GPIO (robot only)

Motor GPIO access is enabled only when the system hostname is exactly rosbot. Set the hostname once on the robot and reboot if it changed:

sudo hostnamectl set-hostname rosbot
hostname

Install gpiozero on the Raspberry Pi:

sudo apt-get update
sudo apt-get install python3-gpiozero

gpiozero accesses GPIO directly through its selected pin factory and does not require a separate GPIO daemon or systemd service.

On any host whose name is not rosbot, the motor node does not access GPIO and simulates motor output. Do not set the robot hostname on a development computer.

4. Optional device setup

  • Joystick: Connect a supported gamepad to Linux. To diagnose the Linux device, install the joystick package (sudo apt-get install joystick) and run jstest --normal /dev/input/js0. The ROS joy driver is installed through rosdep.
  • Camera: Connect a camera supported by the Pi's libcamera version. The camera_ros driver is installed through rosdep.
  • Hokuyo laser: Connect the URG-LX04-UG01 over USB. Confirm its serial device and supported baud rate on the robot; prefer a stable path under /dev/serial/by-id/ when available.

Camera and laser launches are restricted to the host whose name is exactly rosbot. Their physical operation has not been verified; the scanner's base-to-laser transform must also be measured before use for navigation.

Start the robot later

Do these steps in each new terminal session. No dependency installation or rebuild is needed unless dependencies or source code have changed.

1. Source ROS 2 and the workspace

source /opt/ros/jazzy/setup.bash
cd ~/rosbot/ROS/colcon_workspace
source install/setup.bash

If the repository is in a different location, replace ~/rosbot with its path.

2. Start the standard launch

ros2 launch rosbot rosbot_launch.py

This starts the motor controller, command arbitrator, and keyboard teleoperation. The keyboard node needs an interactive terminal. Press ESC in that terminal or Ctrl+C in the launch terminal to stop all launched nodes. On the robot, make the first movement tests with the wheels raised and at low speed; the software watchdog is not a physical emergency stop.

Start with optional devices

Add launch arguments to the same command when you want to use an optional device:

ros2 launch rosbot rosbot_launch.py joystick_enabled:=true joy_device_id:=0
ros2 launch rosbot rosbot_launch.py camera_enabled:=true
ros2 launch rosbot rosbot_launch.py laser_enabled:=true

The laser defaults to /dev/ttyACM0, baud 115200, and frame laser. Override the serial settings if needed:

ros2 launch rosbot rosbot_launch.py laser_enabled:=true laser_device:=/dev/serial/by-id/your-hokuyo laser_baud:=115200 laser_frame_id:=laser

Combine multiple options in one launch command, for example joystick_enabled:=true camera_enabled:=true. The joystick requires a supported Linux device. Camera and laser nodes only start on the robot hostname rosbot.

After changing the source

From the workspace directory, rebuild and source the updated package in each terminal that will use it:

cd ~/rosbot/ROS/colcon_workspace
colcon build --symlink-install --packages-select rosbot
source install/setup.bash

If package.xml dependencies changed, run rosdep install --from-paths src --ignore-src -r -y before building.

Raspberry Pi 5 and L298N pin assignments

The code uses BCM GPIO numbers. Physical pin numbers refer to positions on the Raspberry Pi's 40-pin header. Both numbers are listed below; do not confuse them. The GPIO assignments are unchanged from earlier Raspberry Pi models with the same 40-pin header.

Wheel L298N input BCM GPIO Physical Pi pin
Front left IN A 5 29
Front left IN B 6 31
Front left ENA / PWM 12 32
Front right IN A 20 38
Front right IN B 21 40
Front right ENB / PWM 13 33
Rear left IN A 23 16
Rear left IN B 24 18
Rear left ENA / PWM 18 12
Rear right IN A 16 36
Rear right IN B 26 37
Rear right ENB / PWM 19 35

Remove the corresponding jumpers on the L298N modules when using PWM on ENA/ENB. GPIO 18 (physical pin 12) is assigned to the rear-left wheel's enable input; the separate LED PWM test uses the same GPIO and must not run at the same time as motor control.

Safety: Raspberry Pi GPIOs use 3.3 V logic and are not 5 V tolerant. Do not connect motors directly to the Pi; power them through the L298N drivers. The Pi and motor drivers must share a common ground. Check the wiring and header orientation before powering on; perform initial movement tests with the wheels raised and at low speed.

For more information about nodes, joystick control, and hardware limitations, see the package README.

About

My robot for my YouTube channel 'Markus Knapp - Einfach machen'

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages