mirror of
https://github.com/SHC-ASTRA/rover-ros2.git
synced 2026-04-20 11:51:16 -05:00
some consistency stuff with comments and also remove timeout from serial reads
This commit is contained in:
@@ -40,9 +40,9 @@ class Anchor(Node):
|
||||
* /anchor/to_vic/relay
|
||||
- Core, Arm, and Bio publish VicCAN messages to this topic to send to the MCU
|
||||
* /anchor/to_vic/relay_string
|
||||
- Send raw strings to connectors. Does not work for CANConnector.
|
||||
- Send raw strings to connectors. Does not work for CANConnector
|
||||
* /anchor/relay
|
||||
- (Deprecated) Legacy method. Takes String, converts to VicCAN, then sends to connector.
|
||||
- (Deprecated) Legacy topic. Takes String, converts to VicCAN, then sends to connector
|
||||
"""
|
||||
|
||||
connector: Connector
|
||||
@@ -52,7 +52,7 @@ class Anchor(Node):
|
||||
|
||||
logger = self.get_logger()
|
||||
|
||||
# ROS2 Parameter Setup
|
||||
# ROS2 parameter setup
|
||||
|
||||
self.declare_parameter(
|
||||
"connector",
|
||||
@@ -87,7 +87,7 @@ class Anchor(Node):
|
||||
),
|
||||
)
|
||||
|
||||
# Determine which connector to use. Options are Mock, Serial, and CAN
|
||||
# determine which connector to use. options are Mock, Serial, and CAN
|
||||
connector_select = (
|
||||
self.get_parameter("connector").get_parameter_value().string_value
|
||||
)
|
||||
@@ -127,9 +127,9 @@ class Anchor(Node):
|
||||
)
|
||||
exit(1)
|
||||
|
||||
# ROS2 Topic Setup
|
||||
# ROS2 topic setup
|
||||
|
||||
# Publishers
|
||||
# publishers
|
||||
self.fromvic_debug_pub_ = self.create_publisher( # only used by serial
|
||||
String,
|
||||
"/anchor/from_vic/debug",
|
||||
@@ -150,14 +150,14 @@ class Anchor(Node):
|
||||
"/anchor/from_vic/bio",
|
||||
20,
|
||||
)
|
||||
# Debug publisher for outgoing messages
|
||||
# debug publisher for outgoing messages
|
||||
self.tovic_debug_pub_ = self.create_publisher(
|
||||
String,
|
||||
"/anchor/to_vic/debug",
|
||||
20,
|
||||
)
|
||||
|
||||
# Subscribers
|
||||
# subscribers
|
||||
self.tovic_sub_ = self.create_subscription(
|
||||
VicCAN,
|
||||
"/anchor/to_vic/relay",
|
||||
@@ -183,10 +183,10 @@ class Anchor(Node):
|
||||
20,
|
||||
)
|
||||
|
||||
# Timer to poll connector for incoming data at 100 Hz
|
||||
# poll at 100Hz for incoming data
|
||||
self.read_timer_ = self.create_timer(0.01, self.read_connector)
|
||||
|
||||
# Close devices on exit
|
||||
# close devices on exit
|
||||
atexit.register(self.cleanup)
|
||||
|
||||
def cleanup(self):
|
||||
@@ -249,6 +249,7 @@ def main(args=None):
|
||||
except (KeyboardInterrupt, ExternalShutdownException):
|
||||
pass
|
||||
finally:
|
||||
# might not have to shut down everything manually, find out later ~riley
|
||||
executor.shutdown()
|
||||
anchor_node.destroy_node()
|
||||
rclpy.try_shutdown()
|
||||
|
||||
@@ -154,7 +154,7 @@ class SerialConnector(Connector):
|
||||
serial_interface: serial.Serial
|
||||
try:
|
||||
self.logger.info(f"asking {port} for its name")
|
||||
serial_interface = serial.Serial(port, BAUD_RATE, timeout=1)
|
||||
serial_interface = serial.Serial(port, BAUD_RATE)
|
||||
|
||||
serial_interface.write(b"can_relay_mode,on\n")
|
||||
|
||||
@@ -429,7 +429,7 @@ class CANConnector(Connector):
|
||||
class MockConnector(Connector):
|
||||
def __init__(self, logger: RcutilsLogger, clock: Clock):
|
||||
super().__init__(logger, clock)
|
||||
# No hardware interface for MockConnector. Publish to `/anchor/from_vic/mock_mcu` instead.
|
||||
# no hardware interface for MockConnector. publish to `/anchor/from_vic/mock_mcu` instead
|
||||
|
||||
def read(self) -> tuple[VicCAN | None, str | None]:
|
||||
return (None, None)
|
||||
|
||||
Reference in New Issue
Block a user