From 9beaf7f4ff24a30a9dc7ae655662acc19dea415a Mon Sep 17 00:00:00 2001 From: Achllle Date: Sun, 31 Mar 2024 23:28:00 +0000 Subject: [PATCH] Simplified instructions for serial comms setup and switch to using primary serial device (miniUART) --- ROS/osr_bringup/config/roboclaw_params.yaml | 2 +- config/serial_udev_ubuntu.rules | 7 ---- scripts/roboclawtest.py | 2 +- setup/rpi.md | 39 ++++----------------- 4 files changed, 8 insertions(+), 42 deletions(-) delete mode 100644 config/serial_udev_ubuntu.rules diff --git a/ROS/osr_bringup/config/roboclaw_params.yaml b/ROS/osr_bringup/config/roboclaw_params.yaml index 0ec923f..831af3e 100644 --- a/ROS/osr_bringup/config/roboclaw_params.yaml +++ b/ROS/osr_bringup/config/roboclaw_params.yaml @@ -4,7 +4,7 @@ roboclaw_wrapper: corner_acceleration_factor: 0.8 # fraction used to scale down the corner motor acceleration (0, 1]) velocity_timeout: 2.0 # maximum time [s] a particular velocity command will stay active without a new command before stopping baud_rate: 115200 - device: "/dev/serial1" + device: "/dev/serial0" addresses: [128, 129, 130] duty_mode: true # send duty commands to the roboclaw instead of velocity commands. This can mean a smoother drive but shouldn't be used for autonomous navigation as velocity commands aren't interpreted correclty velocity_qpps_to_duty_factor: 8 # hand-tuned factor to convert velocity commands to duty commands, must be integer diff --git a/config/serial_udev_ubuntu.rules b/config/serial_udev_ubuntu.rules deleted file mode 100644 index 0a21f95..0000000 --- a/config/serial_udev_ubuntu.rules +++ /dev/null @@ -1,7 +0,0 @@ -# make symlinks serial0 and serial1, pointing to the default device names. Grant read/write permissions for the devices -# note: not sure if these actually ought to be tty, but this works. -# note2: this mapping from tty* to serial* is apparently the canonical one for RPI 3&4. Should not change this unless -# there's a super good reason to. -# See https://www.engineersgarage.com/microcontroller-projects/articles-raspberry-pi-serial-communication-uart-protocol-serial-linux-devices/ -KERNEL=="ttyS0", SYMLINK+="serial0" GROUP="tty" MODE="0660" -KERNEL=="ttyAMA0", SYMLINK+="serial1" GROUP="tty" MODE="0660" diff --git a/scripts/roboclawtest.py b/scripts/roboclawtest.py index 23dba88..8a9cccf 100644 --- a/scripts/roboclawtest.py +++ b/scripts/roboclawtest.py @@ -24,7 +24,7 @@ print(roboclaw0.ReadVersion(address)) print(roboclaw0.ReadEncM1(address)) elif connected1: - print("Connected to /dev/serial1.") + print("Connected to /dev/serial1. Only proceed if you know what you're doing, otherwise ask for help on Slack.") print(roboclaw1.ReadVersion(address)) print(roboclaw1.ReadEncM1(address)) else: diff --git a/setup/rpi.md b/setup/rpi.md index c5c990e..0c6ab49 100644 --- a/setup/rpi.md +++ b/setup/rpi.md @@ -118,43 +118,16 @@ The RPi talks to the motor controllers over serial bus. sudo raspi-config ``` -Then use the menu to enable **I2C** and **Serial** under `Interfaces`. More on raspi-config [here](https://www.raspberrypi.com/documentation/computers/configuration.html). +Then use the menu to enable **I2C** and **Serial** under `Interfaces`. When you enable `Serial Port`, it will ask: -**TIP**: If `raspi-config` isn't installed, run `sudo apt-get install raspi-config`. If that doesn't work, run `echo "deb http://archive.raspberrypi.org/debian/ buster main" >> /etc/apt/sources.list && apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 7FA3303E && sudo apt-get update` to allow `apt` to find the program, then try reinstalling with `sudo apt-get install raspi-config`. - -### Disable serial-getty@ttyS0.service - -**NOTE**: this section may no longer be necessary with newer versions of debian. We suggest skipping it and revisiting if serial does not work. +* Would you like a login shell to be accessible over serial? --> Select 'No' using the arrow keys and 'tab' and 'enter' keys on your keyboard +* Would you like the serial port hardware to be enabled? --> Yes -Because we are using the serial port for communicating with the roboclaw motor controllers, we have to disable the serial-getty@ttyS0.service service. This service has some level of control over serial devices that we use, so if we leave it on it we'll get weird errors ([source](https://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3-4/)). Note that the masking step was suggested [here](https://stackoverflow.com/a/43633467/4292910). It seems to be necessary for some setups of the rpi4 - just using `systemctl disable` won't cut it for disabling the service. +If it asks you to reboot, answer 'yes'. -**Note that the following will stop you from being able to communicate with the RPi over the serial, wired connection. However, it won't affect communication with the rpi with SSH over wifi.** +More on raspi-config [here](https://www.raspberrypi.com/documentation/computers/configuration.html). -``` -sudo systemctl stop serial-getty@ttyS0.service -sudo systemctl disable serial-getty@ttyS0.service -sudo systemctl mask serial-getty@ttyS0.service -``` - -### Copy udev rules - -Now we'll need to copy over a udev rules file, which is used to automatically configure needed linux device files in `/dev` namely, `ttyS0 and ttyAMA0`. These are used to connect to the Roboclaws using the RPi's GPIO pins. Here's a [good primer](http://reactivated.net/writing_udev_rules.html) on udev. - -```commandline -# copy udev file from the repo to your system -cd ~/osr_ws/src/osr-rover-code/config -sudo cp serial_udev_ubuntu.rules /etc/udev/rules.d/10-local.rules -``` - -and enter your password if requested. - -Reload the udev rules so that the rules go into effect and the devices files are set up correctly. - -```commandline -sudo udevadm control --reload-rules && sudo udevadm trigger -``` - -This configuration will persist across RPi reboots. +**TIP**: If `raspi-config` isn't installed, run `sudo apt-get install raspi-config`. If that doesn't work, run `echo "deb http://archive.raspberrypi.org/debian/ buster main" >> /etc/apt/sources.list && apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 7FA3303E && sudo apt-get update` to allow `apt` to find the program, then try reinstalling with `sudo apt-get install raspi-config`. ### Add user to tty and dialout groups