Skip to content

InstallingRaspberryPi

Che-Ming Chang edited this page Feb 29, 2024 · 40 revisions

Setup Ubuntu for RPI

To begin, install ubuntu mate for arm64

WIP

Attach the hat. Alternatives include Waveshare RS485 CAN HAT

edit .bashrc to 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

edit the files /boot/config.txt, syscfg.txt, and usercfg.txt to enable spi for raspberry pi boards

the line:

dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25 Update oscillator frequency according to your hat, same with the interrupt pin

Reduce CANBUS queue length

Once the can0 connection is setup 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

Canbus debug code

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

RPI is now ready for relaying data to CANBUS

Setup tools for ODrive

WIP

Clone this wiki locally