Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

Bespoke serial protocol #274

Merged
merged 15 commits into from
Jun 15, 2017
Merged

Bespoke serial protocol #274

merged 15 commits into from
Jun 15, 2017

Conversation

sp4ghet
Copy link
Collaborator

@sp4ghet sp4ghet commented Jun 12, 2017

Summary

This change replaces rosserial with a bespoke serial communications protocol. The goal of this was to create a faster, more reliable connection between the Arduino and the Raspberry Pi. This change is also a step towards using individual nodes for each hardware component, so we can use USB sensors and start writing our devices in python.

Motivation

rosserial was notoriously flaky, so we wanted to either fix it or replace it. We decided to replace it, and work on a new serial communication protocol that would be more reliable.
We also wanted to remove the topic_connector node since we could just have the sensors publish to /environments/environment_1/environment_variable/raw instead of mapping /sensors/ over to the same thing.
This is mainly an interim fix for the RPi Arduino combination we currently run, and we will hopefully move on to something like BeagleBone or Standalone RPi in the near future.

Details

First, all the firmware_module classes are now non-blocking and no longer contain ROS code. They also return status_level s (currently OK, WARN, and ERROR) which allow the main Arduino sketch to figure out if there is an error or not.

Second, the serial protocol is implemented in such a way that the "state" of sensors and actuators are passed around. The commands are not "Turn on for 15 seconds", but "It should be on". The firmware modules have a safety mechanism to shutoff after a set amount of time, usually 10 sec., so it is not going to be disastrous if the ROS side fails. The serial loop is running at around 50 Hz, and the ROS loop is configured to be around 1Hz.

The topics that the arduino_handler node listens on is also hard_coded, as mapping between actuator and environment_variable is not declared in an efficient way for this implementation. The publishing of sensor values happens in a way that is less hard coded as it was mapped more directly.

Drawbacks

This change removes the codegen and dynamic configuration capabilities from the firmware side of things.
It also hard-codes the data types for the Arduino sensors and actuators without referencing the var_types file or the other params since it was meant to be tightly coupled with the Arduino and not all variables map in a simple way.

Alternatives

  • rosserial
  • BeagleBone
  • standalone sensors, standalone nodes

Working notes: https://wiki.openag.media.mit.edu/contributors/rikuo/serial

@sp4ghet sp4ghet added this to the fix rosserial milestone Jun 12, 2017
@sp4ghet sp4ghet requested a review from rbaynes June 12, 2017 18:33
@rbaynes
Copy link
Contributor

rbaynes commented Jun 13, 2017

Wow, that is the best PR description evah! Reviewing now.

Copy link
Contributor

@rbaynes rbaynes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on rob-bot, works with slow EC sensor. Thanks R!

@rbaynes rbaynes merged commit 40ea843 into develop Jun 15, 2017
@rbaynes rbaynes deleted the bespoke_serial branch June 15, 2017 17:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants