make mock mcu use VicCAN messages

This commit is contained in:
ryleu
2026-04-07 21:52:52 -05:00
parent 410d3706ed
commit bc9183d59a
2 changed files with 4 additions and 11 deletions

View File

@@ -84,7 +84,7 @@ $ ros2 topic pub /anchor/to_vic/relay astra_msgs/msg/VicCAN '{mcu_name: "core",
To emulate receiving data from a microcontroller, publish to the dedicated topic: To emulate receiving data from a microcontroller, publish to the dedicated topic:
```bash ```bash
$ ros2 topic pub /anchor/from_vic/mock_mcu std_msgs/msg/String '{data: "can_relay_fromvic,arm,55,0.0,450.0,900.0,0.0"}' $ ros2 topic pub /anchor/from_vic/mock_mcu astra_msgs/msg/VicCAN '{mcu_name: "arm", command_id: 55, data: [0.0, 450.0, 900.0, 0.0]}'
``` ```
### Testing Serial ### Testing Serial

View File

@@ -37,7 +37,7 @@ class Anchor(Node):
Subscribers: Subscribers:
* /anchor/from_vic/mock_mcu * /anchor/from_vic/mock_mcu
- For testing without an actual MCU, publish strings here as if they came from an MCU - For testing without an actual MCU, publish ViCAN messages here as if they came from an MCU
* /anchor/to_vic/relay * /anchor/to_vic/relay
- Core, Arm, and Bio publish VicCAN messages to this topic to send to the MCU - Core, Arm, and Bio publish VicCAN messages to this topic to send to the MCU
* /anchor/to_vic/relay_string * /anchor/to_vic/relay_string
@@ -229,16 +229,9 @@ class Anchor(Node):
elif msg.mcu_name == "citadel" or msg.mcu_name == "digit": elif msg.mcu_name == "citadel" or msg.mcu_name == "digit":
self.fromvic_bio_pub_.publish(msg) self.fromvic_bio_pub_.publish(msg)
def on_mock_fromvic(self, msg: String): def on_mock_fromvic(self, msg: VicCAN):
"""Relay a message as if it came from the MCU""" """Relay a message as if it came from the MCU"""
viccan = string_to_viccan( self.relay_fromvic(msg)
msg.data,
"mock",
self.get_logger(),
self.get_clock().now().to_msg(),
)
if viccan:
self.relay_fromvic(viccan)
def main(args=None): def main(args=None):