Skip to content

markusk/rvr

Repository files navigation

rvr

A ROS Python package for the Sphero RVR - used on a Raspberry Pi.

Please note: this code is still in the middle of the development process!

GitHub issues GitHub stars GitHub license


Step 1: Setup Raspberry Pi OS

  • Install Raspberry Pi OS (fka Rasbpian) on your Raspberry Pi (Instruction).
sudo ssh-keygen -A
  • Start ssh:
sudo systemctl restart ssh.service

Setup the Raspbery Pi serial port

sudo raspi-config

Choose:

  • Interfacing Options
  • P5 Serial
  • No (No Login shell over serial port)
  • Yes (Enable serial port hardware)

Do not reboot now!

  • Change /boot/cmdline.txt file regarding tty-entries to this (credits to richard_mark):

[...] console=tty1 [...]

sudo nano /boot/cmdline.txt
  • Add your user to the dialout group:
sudo gpasswd --add ${USER} dialout
  • Now reboot the Raspberry Pi!

Step 2: Joystick/Gamepad OS support

sudo apt-get install joystick

Microsoft XBOX Wireless Controller

  • Supported by the Kernel - if used with the USB connector.

Gamepad/Joystick test

  • Connect a Gamepad to the Pi, start the following command and press any buttons or move some axes:
jstest --normal /dev/input/js0

Step 3: ROS Noetic Setup (with Python 3 support)

  • Install ROS Noetic on your Raspberry Pi (Instruction):

  • Install ROS packages (+++ TO BE CHECKED !!! +++):

sudo apt-get install ros-melodic-urg-node ros-melodic-teleop-twist-keyboard joystick ros-melodic-joystick-drivers ros-melodic-teleop-twist-joy

Step 5: Create a central place for this repository

  • Create your own development directory "develop"
mkdir ~/develop
cd ~/develop
  • Clone this repository
git clone https://github.com/markusk/rvr.git
  • Create a catkin workspace without 'src' subfolder:
mkdir ~/catkin_ws
cd ~/catkin_ws
  • Create symbolic link with the name 'src', pointing to the 'src' folder in the ROS directory from this repository:
ln -s ~/develop/rvr/ROS/catkin_workspace/src/ src
catkin_make

Step 6: Setup Sphero Public SDK

Long version

Short version

pip3 install aiohttp pyserial_asyncio
cd ~/develop
git clone https://github.com/sphero-inc/sphero-sdk-raspberrypi-python

Make the Sphero Public SDK accessible for the RVR ROS package

  • Create symbolic link, pointing to the 'sphero_sdk' folder:
ln -s ~/develop/sphero-sdk-raspberrypi-python/sphero_sdk/ ~/develop/rvr/ROS/catkin_workspace/src/rvr/lib/

Turn on the RVR and test the SDK

  • Start the ROS test program:
cd ~/catkin_ws/src/rvr/nodes
./test.py
  • The output should look something like this:
Checking RVR firmware versions...
Checking CMS firmware versions...
Firmware check complete.
Battery percentage:  90 %
Voltage state:  1
Voltage states:  [unknown: 0, ok: 1, low: 2, critical: 3]

Note: The firmware check seems to pop up from time to time.

Step 7: Run ROS

Test the RVR ROS package

  • Start the ROS launch file:
cd ~/catkin_ws
roslaunch rvr test.launch
  • The output should look like above.
  • Exit the program with CTRL-C.

The main launch file

  • Run the main launch file on the robot (Raspberry Pi):
cd ~/catkin_ws
roslaunch rvr rvr.launch

to do: On another computer (the ground control center):

export ROS_MASTER_URI=http://<hostname>:11311
rosparam set joy_node/dev "/dev/input/js1"
roslaunch rvr ground_control_center.launch

to do: Step 8: Setting up ROS for autostart

systemd under Ubuntu

sudo cp raspi/etc__systemd__system__rvr-ros-start.service /etc/systemd/system/rvr-ros-start.service
sudo systemctl daemon-reload
sudo systemctl start rvr-ros-start.service
sudo systemctl enable rvr-ros-start.service

The ROS launch files

K

keyboard_control_test

Listens to a teleop_twist_keyboard node and prints out the data/messages. Uses:

  • teleop_twist_keyboard
  • nodes/keyboard_listener.py

M

motor_server

Controls the motors on the robot. Uses:

  • motor_server.py

R

rvr

Controls the whole robot. To be started on the robot. Uses:

  • motor_server.py

to do:

  • tf_broadcaster.py
  • battery_publisher.py
  • imu_bno055.py
  • base_controller.py
  • minibot_camera
  • urg_node