Robot installation

From Rsewiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "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 ...")
 
 
(25 intermediate revisions by one user not shown)
Line 1: Line 1:
 +
Back to [[Flexbot]]
 +
 
Installation of software on the robot
 
Installation of software on the robot
  
 
== Linux ==
 
== Linux ==
  
Start with a freash ubuntu 18.04 desktop full.
+
Start with a fresh ubuntu 20.04
  
 
=== Packages to install ===
 
=== Packages to install ===
Line 12: Line 14:
 
  openssh-server
 
  openssh-server
 
  git
 
  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 ===
 
=== 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
 
At DTU, edit /etc/ntp.conf, add ntp.ait.du.dk to server pool
Line 27: Line 37:
 
Sync time
 
Sync time
  
  ntpdate -u ntp.ait.dtu.dk
+
  sudo ntpdate -u ntp.ait.dtu.dk
 +
 
 +
Should work in and around DTU - see also [[NTP howto]] for more details.
 +
 
 +
=== Boot in terminal mode ===
 +
 
 +
The raspberry is booted in terminal mode (should be default, to save memory).
 +
 
 +
Start graphics mode using "startx" after this change, if you need (Requires that a screen and keyboard is connected to the Raspberry).
 +
 
 +
== 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 ====
  
Should work in and around DTU
+
This node has a command line interface.
 +
Press h for help
 +
BASE_NODE >> h
 +
to get a list of commands.
  
=== flexbot code ===
+
=== apt update ROS key error ===
  
Git repository
+
See:
  
=== ROS ===
+
https://answers.ros.org/question/325039/apt-update-fails-cannot-install-pkgs-key-not-working/

Latest revision as of 09:54, 24 December 2021

Back to Flexbot

Installation of software on the robot

Contents

[edit] Linux

Start with a fresh ubuntu 20.04

[edit] 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.

[edit] 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.

[edit] Boot in terminal mode

The raspberry is booted in terminal mode (should be default, to save memory).

Start graphics mode using "startx" after this change, if you need (Requires that a screen and keyboard is connected to the Raspberry).

[edit] Flexbot

[edit] Source code

Git repository is installed by

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

[edit] 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

[edit] 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
[edit] 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.

[edit] 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"

[edit] 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.

[edit] 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"

[edit] 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.

[edit] 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 &

[edit] base_node_ros

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

BASE_NODE >> h

to get a list of commands.

[edit] apt update ROS key error

See:

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

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox