andino_hardware

The andino_hardware package

README

andino_hardware

This package aims to provide the necessary information to the correct assembly of the robot.

Bill of Materials

Number

Module

Part

Links

Comments

1

SBC

Raspberry Pi 4 B (4 Gb)

PiShop, TiendaTec

If you want better performance you could buy the 8GB model

2

Chassis

2 x Print 3d Chassis + Rubber Tyre Wheels

Chassis, Wheels Sparkfun

-

3

Motors

2 x Motor with Encoder

Sparkfun

-

4

Microcontroller

Arduino Nano

Amazon

You can also use an Arduino Uno, but mind size. It should include a microUSB - USB cable. If not, you will need to purchase it.

5

Motor Driver

L298N Dual H Bridge

Amazon

-

6

Laser Scanner

RPLidar A1M8

RobotShop, Amazon

If no microUSB-USB cable is included, you will need to purchase one

7

Camera

Raspi Camera Module V2, 8 MP

Robotshop, Amazon, Longer cable

A link for a longer cable (30 cm) is included, just in case the one included with the camera is too short.

8

Electrical Power Supply

Powerbank 5V

Amazon

Any powerbank is suitable: Mind size / weight / output current(>=2A)

9

Power Step up

DC - DC boost converter

Amazon Europe

If motors support higher voltage than 5V a step-up(e.g: to 9V) can be added between powerbank (5V) and motor driver. Screw clockwise to reduce the output voltage.

10

Fixing & Mount

M3 bolts/fasteners - M3 Spacers - M2.5/2.0 bolts/fasteners for SBC

Mercado Libre, Amazon, Spacers

You will probably need to replace the default spacers for the LiDAR with M3 spacers

11

Other 3D printed parts

Camera Mount

3D models

These parts are for fixing the Raspi Cam at the front of the robot

12

Caster wheel

Caster wheel

Amazon

-

13

SD Card

64 GB SD Card

Apokin, Amazon

The SD Card is used to host the OS for the Raspberry Pi

14

(Optional) Plastic seals

-

-

You will need at least 2 longer ones to fix the powerbank to the upper chassis, and the shorter ones for all the wires. If you don’t want to use them, you can use other method to fix the powerbank and wires

When you gather all the parts, you should have the following (NOTE: the printed encoder wheels are no longer necessary, since the motors are equipped with an embedded encoder):

Tooling

Number

Tool

Links

Comments

1

Set of screwdrivers

Amazon

You need flat and star screwdrivers

2

Silicon Pistol

Amazon

This pistol should include 75 silicon bars so you won’t need to purchase them separately

Assembly Process

  1. Screw the Motor Driver and the idler wheel to the lower chassis.

Here you have a front image of how the caster wheel are mounted to the chassis:

  1. Screw the 3D printed parts for the Raspi Camera Module:

  1. Add the Arduino Nano to the back of the lower part of the chassis. It should look like this:

  1. Screw the Raspberry Pi and the DC-DC converter to the front of the lower part of the chassis:

  1. Fix the powerbank to the back of the upper part of the chassis:

  1. Add the RPLidar to the front of the upper part of the chassis:

  1. Add the IMU (WIP)

  1. Perform all the wiring following the Connections Diagram of both the upper and lower chassis. Note that some of the connections may need to be done by soldering the cables.

  2. Join both chassis together, and complete the remaining wiring to have your robot ready:

Connection Diagram

Motor-Arduino

Some frequent errors:

  • If one of the motors rotates in the opposite direction (think about the orientation of the motors in the chassis) probably the output(+ and -) of the L298N’s output should be toggled.

  • When moving forward the encoder values should increase while moving backwards they should decrease. If it is happening the other way around probably the A and B encoder signals should be toggled.

Raspberry-Power

*NOTE: depending on the power bank maximum output current, the motors may need to be powered with a voltage value lower than 9V. While a higher voltage value (up to 9V) leads to smoother operation (better motor speed control), it also increases their open-loop speed, which is noticeable particularly during motion start and varies according to the power bank quality (output current capabilities). Therefore, adjusting the output voltage to lower values (around 7V) may be required so as to make the motors work as expected.

**NOTE: Ensure the ribbon cable is properly connected with the blue or silver side facing the USB ports.

Microcontroller Configuration

For uploading the microcontroller firmware please refer to andino_firmware package.

Single Board Computer (SBC)

The SBC used in this project is a Raspberry Pi 4b so the guidelines here will refer particularly to this family of on-board computers, however extending its use to other families is possible as well.

This section details the required configuration that is needed in the SBC. You can either follow these steps or rely on community contribution (Recommended) for installing this via ansible playbooks: See https://github.com/garyservin/andino_ansible_config

Operative System

Ubuntu Mate 22.04 ARM64 is the recommended operative system for this project. This OS provides good capabilities for a educational platform as well as good performance.

For installing this OS in the Raspberry:

  1. Download the image from here: ubuntu mate download

  2. Install OS to a microSD card using Raspberry Pi Imager.

    • No extra configuration should be necessary.

  3. Boot your raspberry using the microSD and a HDMI connection. Some initial configuration is necessary. Follow the wizard for a proper set up. It is recommended to use simple User and Password combinations for the user. For example:

    • user: pi

    • password: admin

  4. Once is done, run sudo apt update && sudo apt upgrade in a terminal for updating the system. Then reboot.

Installing dependencies

Some packages are necessary to be installed towards a correct set up of the robot’s on-board computer.

ssh-server

In general, you will want to access to the Raspberry remotely via ssh connection while being connected in the same network. So we need to install ssh-server;

sudo apt-get install openssh-server

Enable it if it is not enabled yet:

sudo systemctl enable ssh --now

After this you will be able to access this device from a remote computer by doing:

ssh <user>@<ip>

For example if the user is pi and the ip is 192.168.0.102

ssh pi@192.168.0.102
Common utilities

Install some common utilities that will be required later on.

sudo apt update
sudo apt install git net-tools software-properties-common build-essential -y
sudo apt install python3-rosdep2 python3-catkin-pkg python3-catkin-pkg-modules python3-rospkg-modules python3-rospkg  -y
Install ROS

Follow suit the instructions for installing next dependencies from binaries:

To automatically source ROS installation, it is recommended to add source /opt/ros/humble/setup.bash line to the ~/.bashrc file.

Arduino

Arduino drivers are necessary for the SBC (Raspberry) <–> Microcontroller(Arduino) serial communication.

sudo apt install arduino

Configure it properly:

  1. Add user to dialout and plugdev groups:

    sudo usermod -a -G dialout $USER
    
    sudo usermod -a -G plugdev $USER
    

    Note you will need a reboot after this to be effective.

  2. Remove brltty from the system

    sudo apt remove brltty
    

    In Ubuntu 22.04 seems to be an issue with some chip drivers and the brltty daemon. To avoid this conflict we remove brltty as suggested. See this stackoverflow post for further information.

Raspberry Camera Module V2

After connecting the camera module to the Raspberry’s camera port.

sudo apt install libraspberrypi-bin v4l-utils
sudo usermod -aG video $USER

Check camera status:

vcgencmd get_camera

If the output of the previous command is `supported=1 detected=1’, everything is fine. If not, your camera won’t work correctly, you need to perform some configuration first.

Modify the config.txt file for the boot:

 sudo nano /boot/firmware/config.txt

And add these lines:

# Autoload overlays for any recognized cameras or displays that are attached
# to the CSI/DSI ports. Please note this is for libcamera support, *not* for
# the legacy camera stack
start_x=1
gpu_mem=128

Save and close the file. Then we need to enable the camera support for the raspberry:

sudo raspi-config

Go to Interface Options, select camera and enable it.

Finally, you just need to reboot and the camera should be working fine.

RPLidar installation

The installation of the A1M8 RPLidar sensor is quite straight forward and a ros integration package will be installed later on via rosdep.

For now, after connecting it to the usb port:

  1. Verify USB connection: Green light in the usb conversor(A1M8 side board) should be turned on.

  2. Check the authority of RPLidar’s serial-port:

    • ls -l /dev |grep ttyUSB

    • Add extra bits by doing sudo chmod 666 /dev/ttyUSB<number_of_device>

USB Port name configuration

Fixed USB port names

As having multiple USB devices connected to the USB ports of the Raspberry Pi, the automatically assigned USB port numbers could unexpectedly change after a reboot. To avoid assigning your device to a tty_USBX number that isn’t the correct one we should assign fixed USB port name for each connected device.

The idea is to be able to generate a link between the real ttyUSBX port and an invented one. For this we will need to create rules, that every time the Raspberry Pi boots are executed, and therefore we always point to the correct port name.

In order to create fixed names for the USB devices follow the instructions:

  1. Check the devices you have connected:

    sudo dmesg | grep ttyUSB
    
    [  10.016170] usb 1-1.2: ch341-uart converter now attached to ttyUSB0
    [ 309.186487] usb 1-1.1: cp210x converter now attached to ttyUSB1
    

    In the setup where this was tested we have: -> Arduino Microcontroller -> usb 1-1.2: ch341-uart converter now attached to ttyUSB0 -> A1M8 Lidar Scanner -> usb 1-1.1: cp210x converter now attached to ttyUSB1

    Note: If you don’t know how to identify each one you can simply connect them one by one and check this output.

  2. Look for attributes for each device that we will use to anchor a particular device with a name. We will use the idProduct and idVendor of each device.

    • Arduino Microcontroller:

      udevadm info --name=/dev/ttyUSB0 --attribute-walk
      

      You should look for the idProduct and idVendor under the category that matches the usb number(1-1.X): In this case the ttyUSB0 was referenced to the usb 1-1.2, so go to that section and find the ids:

        ATTRS{idProduct}=="7523"
        ATTRS{idVendor}=="1a86"
      
    • Lidar Scanner

      udevadm info --name=/dev/ttyUSB1 --attribute-walk
      

      In this case the ttyUSB0 was referenced to the usb 1-1.1, so go to that section and find the ids:

        ATTRS{idProduct}=="ea60"
        ATTRS{idVendor}=="10c4"
      
  3. Create the rules:

    Open the file:

    sudo nano /etc/udev/rules.d/10-usb-serial.rules
    

    Add the following:

    SUBSYSTEM=="tty", ATTRS{idProduct}=="7523", ATTRS{idVendor}=="1a86", SYMLINK+="ttyUSB_ARDUINO"
    SUBSYSTEM=="tty", ATTRS{idProduct}=="ea60", ATTRS{idVendor}=="10c4", SYMLINK+="ttyUSB_LIDAR"
    

    Note that in the symlink field a fixed name is indicated.

  4. Re-trigger the device manager:

    sudo udevadm trigger
    
  5. Verify

    ls -l /dev/ttyUSB*
    
    crw-rw---- 1 root dialout 188, 0 Sep  2 15:09 /dev/ttyUSB0
    crw-rw---- 1 root dialout 188, 1 Sep  2 15:09 /dev/ttyUSB1
    lrwxrwxrwx 1 root root         7 Sep  2 15:09 /dev/ttyUSB_ARDUINO -> ttyUSB0
    lrwxrwxrwx 1 root root         7 Sep  2 15:09 /dev/ttyUSB_LIDAR -> ttyUSB1
    

Done! You can always use your devices by the fixed names without using the port number. Here, ttyUSB_ARDUINO and ttyUSB_LIDAR are fixed names for the Arduino Microcontroller and the Lidar Scanner respectively.

For more information you can take a look at this external tutorial: Here

Create robot workspace

Let’s create our workspace and build from source this repository.

cd ~
mkdir robot_ws/src -p

Clone this repository in the src folder

cd robot_ws/src
git clone <repository_address>

Install dependencies via rosdep:

cd ~/robot_ws

When it is the first time you run rosdep:

rosdep update

Make sure to export the ROS_DISTRO environment variable:

export ROS_DISTRO=humble

And then proceed to install the workspace dependencies:

rosdep install --from-paths src -i -y -r

Note that option -r has been added. For ARM based processors, there are missing packages, e.g. those related to simulation. We would not try to run the simulation in the compute platform of andino, however for convenience it is added here.

Let’ source the ROS Humble installation:

source /opt/ros/humble/setup.bash

Let’s build the packages (andino_gz_classic and andino_apps work only in simulation):

colcon build --packages-skip andino_gz_classic andino_apps

After building is completed:

source install/setup.bash

After this, you are good to go and use the robot! Refer to usage section.

Extra Recommendations & Tools

Network

Via terminal the wifi connection can be switched by doing:

List available wifi networks:

sudo nmcli dev wifi list

Connect to the desired one:

sudo nmcli --ask dev wifi connect <SSID>
Copy files remotely

Using scp is a useful tool when copying files remotely over ssh.

For copying a folder from host to remote unit:

scp -r <path/to/folder> <remote_user>@<remote_ip>:<remote_path_to_folder>
ROS Domain ID

The domain ID is used by DDS to compute the UDP ports that will be used for discovery and communication.

When using a “public” network using the domain id is a good technique to avoid extra noise with other ROS 2 system in the same network.

See ROS_DOMAIN_ID

TLDR? Export an environment variable with the same ID in all ROS 2 clients in the network for a correct discovery.

export ROS_DOMAIN_ID=<a_number_between_0_and_101>
Using joystick for teleoperation

andino_bringup package provides a launch file for launching the corresponding ROS 2 nodes for teleoperating the robot using a joystick.

It is worth mentioning that a set up might be needed depending on the gamepad you are using. Here some general guidelines:

  • In case you are using a Xbox One Controller and you want use it wireless (via USB Wirless Dongle) installing Xone is recommended.

  • Verify that your joystick is actually working on Ubuntu:

    • Some tools that might be useful:

      • sudo apt install joystick jstest-gtk evtest

    • Run evtest to check if your pad is connected:

      $ evtest
        No device specified, trying to scan all of /dev/input/event*
        Not running as root, no devices may be available.
        Available devices:
          /dev/input/event22:   Microsoft X-Box One pad
      
      
    • Alternatively, you can use jstest-gtk to check the controller, you will find a pretty GUI to play with.