From 16542baf2cd697e2f5e51233ddf0a6f476b0dbb9 Mon Sep 17 00:00:00 2001 From: ShortCircuit Date: Wed, 22 Jan 2025 21:50:07 -0500 Subject: [PATCH] mock rolled ros2bnyahaj reading/writing Co-authored-by: TiaSinghania Co-authored-by: Gyanepsaa Singh Co-authored-by: Tucker Shea Co-authored-by: Alden-G878 Co-authored-by: garrison2 Co-authored-by: delaynie --- rb_ws/src/buggy/CMakeLists.txt | 3 +- rb_ws/src/buggy/launch/debug_steer.xml | 2 + rb_ws/src/buggy/msg/SCDebugInfoMsg.msg | 10 + rb_ws/src/buggy/scripts/debug/debug_steer.py | 3 + rb_ws/src/buggy/scripts/serial/host_comm.py | 16 +- .../buggy/scripts/serial/ros_to_bnyahaj.py | 310 ------------------ .../scripts/serial/ros_to_bnyahaj_reader.py | 241 ++++++++++++++ .../scripts/serial/ros_to_bnyahaj_writer.py | 120 +++++++ 8 files changed, 387 insertions(+), 318 deletions(-) create mode 100644 rb_ws/src/buggy/msg/SCDebugInfoMsg.msg mode change 100644 => 100755 rb_ws/src/buggy/scripts/debug/debug_steer.py delete mode 100755 rb_ws/src/buggy/scripts/serial/ros_to_bnyahaj.py create mode 100755 rb_ws/src/buggy/scripts/serial/ros_to_bnyahaj_reader.py create mode 100755 rb_ws/src/buggy/scripts/serial/ros_to_bnyahaj_writer.py diff --git a/rb_ws/src/buggy/CMakeLists.txt b/rb_ws/src/buggy/CMakeLists.txt index b8827602..d7806234 100644 --- a/rb_ws/src/buggy/CMakeLists.txt +++ b/rb_ws/src/buggy/CMakeLists.txt @@ -33,7 +33,8 @@ install(PROGRAMS scripts/simulator/engine.py scripts/watchdog/watchdog_node.py scripts/buggy_state_converter.py - scripts/serial/ros_to_bnyahaj.py + scripts/serial/ros_to_bnyahaj_reader.py + scripts/serial/ros_to_bnyahaj_writer.py scripts/visualization/telematics.py DESTINATION lib/${PROJECT_NAME} ) diff --git a/rb_ws/src/buggy/launch/debug_steer.xml b/rb_ws/src/buggy/launch/debug_steer.xml index 29ad95ef..3a4c9443 100644 --- a/rb_ws/src/buggy/launch/debug_steer.xml +++ b/rb_ws/src/buggy/launch/debug_steer.xml @@ -1,4 +1,6 @@ + + \ No newline at end of file diff --git a/rb_ws/src/buggy/msg/SCDebugInfoMsg.msg b/rb_ws/src/buggy/msg/SCDebugInfoMsg.msg new file mode 100644 index 00000000..4e26b81a --- /dev/null +++ b/rb_ws/src/buggy/msg/SCDebugInfoMsg.msg @@ -0,0 +1,10 @@ +float64 encoder_angle +float64 rc_steering_angle +float64 software_steering_angle +float64 true_steering_angle +bool operator_ready +bool brake_status +bool use_auton_steer +bool tx12_state +uint8 stepper_alarm +uint8 rc_uplink_qual \ No newline at end of file diff --git a/rb_ws/src/buggy/scripts/debug/debug_steer.py b/rb_ws/src/buggy/scripts/debug/debug_steer.py old mode 100644 new mode 100755 index f7fe8a15..60c32063 --- a/rb_ws/src/buggy/scripts/debug/debug_steer.py +++ b/rb_ws/src/buggy/scripts/debug/debug_steer.py @@ -2,6 +2,7 @@ import argparse import rclpy +from rclpy.node import Node from std_msgs.msg import Float64 import numpy as np @@ -41,6 +42,8 @@ def loop(self): self.steer_cmd = self.sin_steer(self.tick_count) msg = Float64() msg.data = self.steer_cmd + # if self.tick_count % 10 == 0: + # self.get_logger().info(f"SIN STEER: {self.steer_cmd}") self.steer_publisher.publish(msg) self.tick_count += 1 diff --git a/rb_ws/src/buggy/scripts/serial/host_comm.py b/rb_ws/src/buggy/scripts/serial/host_comm.py index 766247e3..5dec741c 100755 --- a/rb_ws/src/buggy/scripts/serial/host_comm.py +++ b/rb_ws/src/buggy/scripts/serial/host_comm.py @@ -1,3 +1,5 @@ +import sys + import struct import time from dataclasses import dataclass @@ -165,7 +167,7 @@ class ChecksumMismatch(Exception): class Comms: def __init__(self, path_to_port): - self.port = Serial(path_to_port, 1_000_000) + self.port = Serial(path_to_port, 1_000_000, exclusive=True) self.rx_buffer = b'' def send_packet_raw(self, msg_type: bytes, payload: bytes): @@ -263,23 +265,23 @@ def read_packet(self): msg_type, payload = packet if msg_type == MSG_TYPE_NAND_DEBUG: - data = struct.unpack('