-
Notifications
You must be signed in to change notification settings - Fork 2
InstallingRaspberryPi
The OpenBMP utilizes a ROS node on a raspberry pi 4B for converting and relaying latched commands and data from the main ROS system to the CAN network. The ODrive v3.6 units are daisy chained to the CAN network via the MCP2515 Stand-Alone CAN Controller with SPI Interface. This system is responsible for controlling the 8 DoF upper arms of the robot, from shoulder folding to elbow bending.
Important
Things you will need: 1. CAN Bus Hat for Raspberry Pi 2. Raspberry Pi 4, 4GB or above 3. Ethernet cable 4. Router
Tip
TODO: upload the schematics for the custom MCP2515 CAN hat used
To begin, install Ubuntu Server (20.04) for arm64 (RPI) Use the imager to install Ubuntu 20.04 for RPi on a microSD card or use the native installer on the Raspberry Pi Ubuntu for RPI download page There isn't a specific desktop version for 20.04. Use the command to install the desktop GUI environment:
sudo apt-get install ubuntu-desktop
Note
The server version can be used to configure a more lightweight and headless setup. Desktop addon files are approximately 3 Gb
Once Ubuntu has been installed, attach the hat. Alternative hat Waveshare RS485 CAN HAT
Note
A good idea is to install net-tools
sudo apt install net-tools
Since we are using version 20.04.5 LTS, we will be installing ROS Noetic ROS Installation
For the RPI, only the barebone is required. Running visual and perception packages can result in excess load to the RPI.
sudo apt install ros-noetic-ros-base
We just need the rostopic and ROS communication modules to enable ROS over multiple machines.
- Edit
.bashrcto include:
export ROS_MASTER_URI=http://192.168.1.100:11311/
export ROS_IP=192.168.1.102
source /opt/ros/noetic/setup.bash
source ~/catkin_ws/devel/setup.bash
Important
ROS_IP is the designated IP of the RPI, ROS_MASTER_URI is the main computer IP
- Edit the files
/boot/config.txt,syscfg.txt, andusercfg.txtto enable SPI for Raspberry Pi boards Sample files are available at Open-Biomanual-Manipulation-System/Software/pi_catkin_ws_src
Important
Update oscillator frequency according to your hat, same with the interrupt pin
We need to set the following line:
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25 This sets up the interface for can0
-
Download and extract the code from pi_catkin_ws_src to your workspace
srcfolder -
Some of the catkin_make dependencies you will need to install first:
sudo apt install ros-noetic-diagnostic-updater
sudo apt install ros-noetic-can-msgs
- run
catkin_make
chmod +x can_odrive_passover.py
chmod +x bag2armhand.py
Important
Make sure the Python scripts are executable using chmod +x can_odrive_passover.py
Install pip, python-can, and cantools
sudo apt install python3-pip
pip install python-can
pip install cantools
Once the can0 connection is set via SPI, reboot and use the following to check the status of the connection:
ip -det link show can0
ip -details -statistics link show can0
We need to reduce the TX queue length to make sure the most recent data is being broadcasted onto the CAN network from ROS First, we need to shut down can0
sudo ip link set can0 down
Then, we can edit the interface's properties.
sudo ip link set can0 up type can bitrate 1000000
sudo ip link set can0 txqueuelen 1000
sudo ip link set can0 txqueuelen 1
To make the change effective, restart the systemd-networkd
sudo systemctl enable systemd-networkd
sudo systemctl start systemd-networkd
sudo systemctl restart systemd-networkd
Now running ip -details -statistics link show can0, we should see the txqueuelen reduced to 1
This can happen if txqueuelen is not 1 and system has been left on for a while...
Here are some useful commands to monitor your CANBUS
dmesg | grep -i spi
dmesg | grep -i can
rosrun socketcan_interface socketcan_dump can0
canbusload can0@1000000
python3 -m can.viewer -c "can0" -i "socketcan"
candump can0 -xct z -n 10
Tip
RPI is now ready for relaying data to CANBUS
It's a good idea to install the official odrive_ros code for testing the ODrive:
sudo apt install git
sudo apt install sublime-text
sudo apt install terminator
