!

(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Setup and Install packages to control the platform

Description: This tutorial shows step-by-step instructions on how to download, setup and build the required packages to comunicate with the platform.

Tutorial Level: BEGINNER

Hardware requirements

  • Computer
  • Robosavvy Self-balance robotic platform
  • (optional) RC remote and receiver

OS

Ubuntu 16.04.3 LTS: http://releases.ubuntu.com/16.04/ (Use auto-login)

Prepare software

sudo apt-get update -y
sudo apt-get dist-upgrade -y
sudo apt-get install git openssh-client openssh-server xserver-xorg-core xserver-xorg-video-dummy screen -y

Disable screen lock - go to Settings, Brightness and Lock and choose OFF in the lock option

Set IP addresses

Edit /etc/network/interfaces to setup a static IP so you can connect later to the robot. Make sure to configure the static IP in the same subnetwork as your pc.

 auto eno1
 iface eno1 inet static
   address 192.168.0.31
   netmask 255.255.255.0

Installing ROS base (tested version: ROS Kinetic)

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
sudo apt-get update
sudo apt-get install ros-kinetic-desktop-full -y
sudo apt-get install ros-kinetic-rosserial -y
sudo apt-get install ros-kinetic-rqt-ez-publisher -y
sudo rosdep init
rosdep update
rm ~/.config/ros.org/rqt_gui.ini

Setup bashrc

echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc

Platform software

mkdir -p ~/ros_ws/src
cd ~/ros_ws/src
git clone https://github.com/robosavvy/gd_msgs.git

Create a dummy screen

This is a workaround for linux to start without needing a screen to be able to connect a VNC client afterwards.

Edit your xorg.conf

sudo vi /usr/share/X11/xorg.conf.d/xorg.conf

and add the following lines

Section "Device"
    Identifier  "Configured Video Device"
    Driver      "dummy"
EndSection

Section "Monitor"
    Identifier  "Configured Monitor"
    HorizSync 31.5-48.5
    VertRefresh 50-70
EndSection

Section "Screen"
    Identifier  "Default Screen"
    Monitor     "Configured Monitor"
    Device      "Configured Video Device"
    DefaultDepth 24
    SubSection "Display"
    Depth 24
    Modes "1024x800"
    EndSubSection
EndSection

Restart the computer

Build our software

cd ~/ros_ws/
catkin_make -j1
echo "source ~/ros_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc

Generate the matrices file (given the weight)

Download and install the matrices calculator. Note that you need to change the parameters on the last command to calculate the matrices.

wget https://robosavvy.com/RoboSavvyPages/RSVPlatform/gd_Calculator.tar.gz
tar xvzf gd_Calculator.tar.gz
cd gd_Calculator
sudo chmod a+x gd_Calculator
./gd_Calculator <weight [kg]> <distance payloadCM-base [m]> <directory location>

This will create 2 files: matrices.txt and info.txt. The info.txt is only the information about the robot that was inputed into the system. The matrices.txt will be used by the platform every time it is turned on.

IMPORTANT: The output file “matrices.txt” must be copied to the same directory of the startup_parameters.py

cp matrices.txt ~/ros_ws/src/gd_msgs/scripts/

Configure startup scripts when platform PC starts

roscore and rosserial should run on the background when the PC is turned on. To do that you need to put the launch file on the startup applications.

Open "Startup Applications" / "Add" / "Browse" and point to this location: ~/ros_ws/src/gd_msgs/scripts/launch_all.sh

Access the computer to control the platform

We suggest you to access remotely to the platform using a Remote Desktop client (like Remmina). Insert the IP address of the host computer and fix color depth to "True Color (24bit)". Connect.

Turn on the platform hardware

Press the black button in the back of the platform. A sound sequence will be played by the platform to inform that it booted properly. When it finishes you can check the status with this command

screen -r ros_selfbalance

The “loaded all parameters” string should appear on the bottom of that terminal. This means that all topics and services are set up.

Since the roscore is already executing on the background you can control the platform using sliders under rqt:

rqt

Open "Plugins" / "Robot Tools" / "Robot Steering" and associate the topic /cmd_vel to this plugin. Open "Plugins" / "Topics" / "Easy Message Publisher" and add 2 topics (/cmd_height and /calib_center) to this plugin.

Start the self balancing platform

If the payload center of mass is not properly aligned with the center of wheels, the idle balance position will have a slight incline. This can be adjusted through the parameter “calib_value”. Changing this value will correct the idle balance position of the platform. This is valid also to keep the platform balanced on floors that are not flat or with some incline. This parameter can also be adjusted by a RC input.

On a terminal write:

python ~/ros_ws/src/gd_msgs/scripts/startup_parameters.py (1) (2)

Where:

(1) is the calibration value for the tilt (tested between -0.1 and 0.1). For our stand is -0.01 (startup value)

(2) is the input definition. 0 for the PC and 1 for the RC

The platform will start balancing with the input parameters set before. The first thing that should be done is to adjust the calibration value.

If using the host PC to control the platform use rqt to adjust the tilt calibration value (calib_value) and the height of the center of mass (cmd_height). Use the Robot steering plugin to control the speed and the direction of the movements. You should always use this calibration value to start the robot.

If using the RC remote ou should have it previously configured with the proper receiver. You should choose 3 receiver channels and connect them to the “fwd/bwd”, “left/right” and “calib” cables (black - GND, red - PWR positive, green - signal).

Check what is running on the background

To check the roscore and rosserial that are running on the background use these commands on separate terminal windows:

screen -r ros_core
screen -r ros_selfbalance

TOPICs and SERVICEs that can be used by the host PC

You can subscribe to these topics

  • charging_platform -> returns TRUE if the charger is connected of FALSE if not

  • battery_platform -> returns the voltage of the segway platform (60V charged, 53V discharged, 52V shutdown)

  • tf -> relationship between the wheels and the center of the platform

  • odom -> data feedback of the wheels

  • state -> Here we have the feedback state, desired state e wip state. The IMU tilt value is displayed on the "dx" entry.

You can publish to these topics

  • cmd_vel -> direction and speed commands for the platform

  • cmd_height -> height of the center of mass (whole robot)

  • calib_center -> correction value for the tilt angle

Other services

  • set_input -> Set if the input commands are coming from PC (0) or RC (1).

  • init_balance -> Start balancing (needs parameters first)

  • reset_odom -> Resets the odometry value

Wiki: RoboSavvy/RoboSavvy-Balance/Tutorials/Setup and install on physical Robot (last edited 2017-10-20 17:03:51 by RoboSavvy)