Repository navigation
Conversation
3f435c4 to
7724577
Compare
7724577 to
5aa8419
Compare
| return result | ||
|
|
||
|
|
||
| def main(args=None): |
There was a problem hiding this comment.
If the Teensy is unplugged or the port is wrong, Teensy() crashes after ROS is already started. This finally never runs, so ROS is never shut down. (which is fine if the whole process dies, but it breaks if a test or another script catches the error and keeps going)
tldr I think it's safer to set teensy_node = None before the try. In finally, only destroy the node if it was created, and always call rclpy.try_shutdown() after that
|
Changed to draft pending @nizhnerk's code quality changes. |
5aa8419 to
191b192
Compare
191b192 to
a17a3fd
Compare
# Conflicts: # src/sailing/sailing/teensy/teensy_node.py # src/sailing/test/test_teensy_node.py
| incoming_byte = self.serial.read()[0] | ||
|
|
||
| # If we see START_FLAG, prepare for reading in a new packet. | ||
| if incoming_byte == SERIAL.TX_START_FLAG: |
There was a problem hiding this comment.
correct me if i'm wrong, but the Teensy marks the start of a message with the byte 0xFF and the end with 0xEE, and nothing is restricting these bytes from getting sent in as actual wind directions in the packet itself? so if wind is either 0xEE or 0xFF the message is discarded/mangled. I think the fix would be to add an extra byte of some sort to indicate that the following byte is actual wind data/differentiate it from start/end markers
There was a problem hiding this comment.
yeah this is something i've been chewing on for a bit, i'll fix it before this pr is ready
|
|
||
| def mainsail_angle_callback(self, msg): | ||
| """Update the mainsail goal and send the full command.""" | ||
| self.desired_mainsail_angle = msg.data |
There was a problem hiding this comment.
i think this change would need to happen in the other callbacks too, but I assume we should safeguard against bad values. i.e, check the new angle against the allowed range before saving it. If it is outside that range, leave the old value in place and skip the send, so one bad rudder command cannot block the mainsail and jib commands that come after it
# Conflicts: # .github/workflows/ci.yml # jetson/setup/README.md
…es all solved now.
Summary
Add ROS 2 node for communicating with the Teensy through a serial port. Apologies for the large PR. Most changes are boilerplate and tests; the important changes are in
teensy_node.pyandserial_port.py.Changes
teensy_node.pyandteensy.pyin thesailbotrepo.sailboat_mainROS 2 package, thesailingpackage will containreinforcement_learningandteensysubdirectories.PHYSICAL.MAX_RUDDER_ANGLEconstant being set to -25 instead of -45 causing errors in angle conversion math. For an operational clamp, a separate constant should be used.INFOlogs, the sending and receiving packets logDEBUGlogs that are hidden by default. Warnings on send and receive errors are also throttled to a rate ofWARNING_THROTTLE_SECONDS.Testing
Future Work