Robot installation: Difference between revisions

From Rsewiki
Line 23: Line 23:
Network time protocol, to keep clocks in sync.
Network time protocol, to keep clocks in sync.
At DTU most clock sources are blocked, the clock source needs to be configured.
At DTU most clock sources are blocked, the clock source needs to be configured.
sudo apt install ntp ntpdate


At DTU, edit /etc/ntp.conf, add ntp.ait.du.dk to server pool
At DTU, edit /etc/ntp.conf, add ntp.ait.du.dk to server pool

Revision as of 16:06, 9 December 2021

Installation of software on the robot

Linux

Start with a freash ubuntu 18.04 desktop full.

Packages to install

Install:

ntp
ntpdate
openssh-server
git
libreadline-dev

sudo apt install ntp ntpdate openssh-server git libreadline-dev

Install ros-melodic-desktop-full, follow instructions in: http://wiki.ros.org/melodic/Installation/Ubuntu up to section 2. Tutorials.

NTP

Network time protocol, to keep clocks in sync. At DTU most clock sources are blocked, the clock source needs to be configured.

At DTU, edit /etc/ntp.conf, add ntp.ait.du.dk to server pool

...
# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
pool ntp.ait.dtu.dk
...

Sync time

sudo ntpdate -u ntp.ait.dtu.dk

Should work in and around DTU - see also NTP howto for more details.

Boot in terminal mode

To boot in terminal mode. uncomment this line in /etc/default/grub

...
# Uncomment to disable graphical terminal (grub-pc only)
GRUB_TERMINAL=console
...

Start graphics using "startx" after this change, if you need.

Flexbot

Source code

Git repository is installed by

cd
git clone https://repos.gbar.dtu.dk/git/jcan/flexbot.git flexbot

MAV link

Generate MAV link code (between ROS and Teensy controllers)

Install tk dialogs and controls and start generator

pip install future
cd ~/flexbot/code/MAVLink/Generator
python mavgenerate.py

And follow the instructions here http://rsewiki.elektro.dtu.dk/index.php/Mavlink#Generating_C-headers_.26_Python_file

Teensy code compile

Install Arduino and Teensyduino as described in Software installation section "Toolchain installation" and "Teensy loader and udev rules"

and make tool links in teensy code directory (arduino version numbers and directory could be different):

cd ~/flexbot/code/teensy_v2/
ln -s ~/arduino-1.8.7/hardware/tools .
ln -s ~/arduino-1.8.7/hardware/teensy/avr/cores/teensy3 .
ln -s ~/arduino-1.8.7/hardware/teensy/avr/libraries libteensy   
ln -s tools/teensy .

The teensy code is compiled using a Makefile and not the arduino IDE, so:

cd ~/flexbot/code/teensy_v2/
mv teensy3/main.cpp teensy3/main.cpp.not
make
Teensy 3.5 SD-card error

These 2 files has an include error:

nano libteenst/SD/utility/SdFile.cpp 
nano libteensy/SD/utility/SdVolume.cpp

Change '#include <SdFat.h>' to '#include "SdFat.h"' in one of the first code lines.

Teensy rules

To recognize and access the Teensy then 49_teensy.rules implement:

ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789B]?", ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789A]?", ENV{MTP_NO_PROBE}="1"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789ABCD]?", MODE:="0666"
KERNEL=="ttyACM*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789B]?", MODE:="0666"

Upload new code to Teensy

Upload to one Teensy processor connected to this robot

make upload 

NB! only works if there is one Teensy connected (I think), else

./teensy

Load hex file and press program button on Teensy.

new device names

Teensy creates /dev/ttyACM0, /dev/ttyACM1, ... in order of detection

Based in serial number these are mapped to new device names.

Make a link to 99-flexbot-legs.rules like this

cd /etc/udev/rules.d
sudo ln -s ~/flexbot/code/99-flexbot-legs.rules

The 99-flexbot-legs.rules holds

# flexbot
# rename serial device for teensy 3.5 controllers for flexbot
# NB! must be changed every time a processor (or leg) is replaced
#
# This defines the order of the legs
#
# make a link in /etc/udev/rules.d/ to this file, e.g.
# $ cd /etc/udev/rules.d
# $ sudo ln -s /home/local/flexbot/code/99-fklexbot-legs.rules
# 
# to find the serial number for a device, connect just one device and
#
# $ udevadm info -q all -n /dev/ttyACM0
#
# find the ID_SERIAL_SHORT=4145230
# and insert that number into ATTRS{serial}=="xxxxx"
#
# to let udev read the changes you probably need
#
# $ sudo udevadm control --reload-rules
#
# Teensy at the base
SUBSYSTEM=="tty", ATTRS{idVendor}=="16c0",    ATTRS{idProduct}=="0483",    ATTRS{serial}=="4004150",    SYMLINK+="flexbot_base"
#
# teensy leg 1 - rear right
SUBSYSTEM=="tty", ATTRS{idVendor}=="16c0",    ATTRS{idProduct}=="0483",    ATTRS{serial}=="4145230",    SYMLINK+="flexbot_leg1"
#
# teensy leg 2 - front right
SUBSYSTEM=="tty", ATTRS{idVendor}=="16c0",    ATTRS{idProduct}=="0483",    ATTRS{serial}=="4000001",    SYMLINK+="flexbot_leg2"
#
# teensy leg 3 - front left
SUBSYSTEM=="tty", ATTRS{idVendor}=="16c0",    ATTRS{idProduct}=="0483",    ATTRS{serial}=="4000002",    SYMLINK+="flexbot_leg3"
#
# teensy leg 1 - rear left
SUBSYSTEM=="tty", ATTRS{idVendor}=="16c0",    ATTRS{idProduct}=="0483",    ATTRS{serial}=="4000003",    SYMLINK+="flexbot_leg4"

ROS for flexbot

Make a ROS workspace for flexbot (from http://wiki.ros.org/ROS/Tutorials/InstallingandConfiguringROSEnvironment)

cd
mkdir -p flexbot_ws/src
cd flexbot_sw
catkin_make

Link the flexbot code into the src directory

cd src
ln -s ~/flexbot/code/base_node_ros
cd ..
catkin_make

If everything goes right, then

catkin_make install


The binary code is then in install/bin.

run base_node_ros

Run the node

install/bin/base_node_ros

If you get a "... Failed to contact master ..." error, then start roscore first

roscore &

base_node_ros

This node has a command line interface. Press h for help

BASE_NODE >> h

to get a list of commands.

apt update ROS key error

See:

https://answers.ros.org/question/325039/apt-update-fails-cannot-install-pkgs-key-not-working/