From b220674e59a71b578f3d131ffd77bf8096bb5977 Mon Sep 17 00:00:00 2001 From: Tristan McGinnis Date: Mon, 24 Feb 2025 17:39:27 -0600 Subject: [PATCH 1/9] Add bio package. Subup ros2_interfaces_pkg --- src/bio_pkg/bio_pkg/__init__.py | 0 src/bio_pkg/bio_pkg/bio_node.py | 217 +++++++++++++++++++++++++++++ src/bio_pkg/package.xml | 21 +++ src/bio_pkg/resource/bio_pkg | 0 src/bio_pkg/setup.cfg | 4 + src/bio_pkg/setup.py | 25 ++++ src/core_pkg/core_pkg/core_node.py | 2 +- src/ros2_interfaces_pkg | 2 +- 8 files changed, 269 insertions(+), 2 deletions(-) create mode 100644 src/bio_pkg/bio_pkg/__init__.py create mode 100644 src/bio_pkg/bio_pkg/bio_node.py create mode 100644 src/bio_pkg/package.xml create mode 100644 src/bio_pkg/resource/bio_pkg create mode 100644 src/bio_pkg/setup.cfg create mode 100644 src/bio_pkg/setup.py diff --git a/src/bio_pkg/bio_pkg/__init__.py b/src/bio_pkg/bio_pkg/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/bio_pkg/bio_pkg/bio_node.py b/src/bio_pkg/bio_pkg/bio_node.py new file mode 100644 index 0000000..9004d8a --- /dev/null +++ b/src/bio_pkg/bio_pkg/bio_node.py @@ -0,0 +1,217 @@ +import rclpy +from rclpy.node import Node +import serial +import sys +import threading +import glob +import time +import atexit +import signal +from std_msgs.msg import String +from ros2_interfaces_pkg.msg import BioControl + +serial_pub = None +thread = None + +class SerialRelay(Node): + def __init__(self): + # Initialize node + super().__init__("bio_node") + + # Get launch mode parameter + self.declare_parameter('launch_mode', 'bio') + self.launch_mode = self.get_parameter('launch_mode').value + self.get_logger().info(f"bio launch_mode is: {self.launch_mode}") + + # Create publishers + self.debug_pub = self.create_publisher(String, '/bio/feedback/debug', 10) + #self.socket_pub = self.create_publisher(SocketFeedback, '/arm/feedback/socket', 10) + + + # Create subscribers\ + self.control_sub = self.create_subscription(BioControl, '/bio/control', self.send_control, 10) + + # Topics used in anchor mode + if self.launch_mode == 'anchor': + self.anchor_sub = self.create_subscription(String, '/anchor/bio/feedback', self.anchor_feedback, 10) + self.anchor_pub = self.create_publisher(String, '/anchor/relay', 10) + + + # Search for ports IF in 'arm' (standalone) and not 'anchor' mode + if self.launch_mode == 'bio': + # Loop through all serial devices on the computer to check for the MCU + self.port = None + for i in range(2): + try: + # connect and send a ping command + set_port = '/dev/ttyACM0' #MCU is controlled through GPIO pins on the PI + ser = serial.Serial(set_port, 115200, timeout=1) + #print(f"Checking port {port}...") + ser.write(b"ping\n") + response = ser.read_until("\n") + + # if pong is in response, then we are talking with the MCU + if b"pong" in response: + self.port = set_port + self.get_logger().info(f"Found MCU at {set_port}!") + break + except: + pass + + if self.port is None: + self.get_logger().info("Unable to find MCU... please make sure it is connected.") + time.sleep(1) + sys.exit(1) + + self.ser = serial.Serial(self.port, 115200) + atexit.register(self.cleanup) + + def run(self): + global thread + thread = threading.Thread(target=rclpy.spin, args=(self,), daemon=True) + thread.start() + + #if in arm mode, will need to read from the MCU + + try: + while rclpy.ok(): + if self.launch_mode == 'bio': + if self.ser.in_waiting: + self.read_mcu() + else: + time.sleep(0.1) + except KeyboardInterrupt: + pass + finally: + self.cleanup() + + + #Currently will just spit out all values over the /arm/feedback/debug topic as strings + def read_mcu(self): + try: + output = str(self.ser.readline(), "utf8") + if output: + self.get_logger().info(f"[MCU] {output}") + msg = String() + msg.data = output + self.debug_pub.publish(msg) + except serial.SerialException: + self.get_logger().info("SerialException caught... closing serial port.") + if self.ser.is_open: + self.ser.close() + pass + except TypeError as e: + self.get_logger().info(f"TypeError: {e}") + print("Closing serial port.") + if self.ser.is_open: + self.ser.close() + pass + except Exception as e: + print(f"Exception: {e}") + print("Closing serial port.") + if self.ser.is_open: + self.ser.close() + pass + + def send_ik(self, msg): + pass + + + def send_control(self, msg): + if msg.pumpID != 0: + command = "can_relay_tovic,citadel,27," + str(msg.pumpID) + "," + str(msg.pumpAmount) + "\n" + self.send_cmd(command) + if msg.fanID != 0: + command = "can_relay_tovic,citadel,40," + str(msg.fanID) + "," + str(msg.fanDuration) + "\n" + self.send_cmd(command) + if msg.servoID != 0: + command = "can_relay_tovic,citadel,25," + str(msg.servoID) + "," + str(msg.servoPosition) + "\n" + self.send_cmd(command) + + ######### + # To add LSS command here + ######### + + command = "can_relay_tovic,citadel,26," + str(msg.vibrationMotor) + "\n" + self.send_cmd(command) + + def send_manual(self, msg): + axis0 = msg.axis0 + axis1 = msg.axis1 + axis2 = msg.axis2 + axis3 = msg.axis3 + + #Send controls for arm + command = "can_relay_tovic,arm,40," + str(axis0) + "," + str(axis1) + "," + str(axis2) + "," + str(axis3) + "\n" + self.send_cmd(command) + + #Send controls for end effector + command = "can_relay_tovic,digit,35," + str(msg.effector_roll) + "\n" + self.send_cmd(command) + + command = "can_relay_tovic,digit,36,0," + str(msg.effector_yaw) + "\n" + self.send_cmd(command) + + command = "can_relay_tovic,digit,26," + str(msg.gripper) + "\n" + self.send_cmd(command) + + command = "can_relay_tovic,digit,28," + str(msg.laser) + "\n" + self.send_cmd(command) + + + + #print(f"[Wrote] {command}", end="") + + #Not yet finished, needs embedded implementation for new commands + # ef_roll = msg.effector_roll + # ef_yaw = msg.effector_yaw + # gripper = msg.gripper + # actuator = msg.linear_actuator + # laser = msg.laser + # #Send controls for digit + + # command = "can_relay_tovic,digit," + str(ef_roll) + "," + str(ef_yaw) + "," + str(gripper) + "," + str(actuator) + "," + str(laser) + "\n" + + return + + def send_cmd(self, msg): + if self.launch_mode == 'anchor': #if in anchor mode, send to anchor node to relay + output = String() + output.data = msg + self.anchor_pub.publish(output) + elif self.launch_mode == 'bio': #if in standalone mode, send to MCU directly + self.get_logger().info(f"[Bio to MCU] {msg}") + self.ser.write(bytes(msg, "utf8")) + + def anchor_feedback(self, msg): + self.get_logger().info(f"[Bio Anchor] {msg.data}") + #self.send_cmd(msg.data) + + + @staticmethod + def list_serial_ports(): + return glob.glob("/dev/ttyUSB*") + glob.glob("/dev/ttyACM*") + #return glob.glob("/dev/tty[A-Za-z]*") + + def cleanup(self): + print("Cleaning up...") + if self.ser.is_open: + self.ser.close() + +def myexcepthook(type, value, tb): + print("Uncaught exception:", type, value) + if serial_pub: + serial_pub.cleanup() + +def main(args=None): + rclpy.init(args=args) + sys.excepthook = myexcepthook + + global serial_pub + serial_pub = SerialRelay() + serial_pub.run() + +if __name__ == '__main__': + signal.signal(signal.SIGTSTP, lambda signum, frame: sys.exit(0)) # Catch Ctrl+Z and exit cleanly + signal.signal(signal.SIGTERM, lambda signum, frame: sys.exit(0)) # Catch termination signals and exit cleanly + main() diff --git a/src/bio_pkg/package.xml b/src/bio_pkg/package.xml new file mode 100644 index 0000000..1b26d45 --- /dev/null +++ b/src/bio_pkg/package.xml @@ -0,0 +1,21 @@ + + + + bio_pkg + 0.0.0 + TODO: Package description + tristan + TODO: License declaration + + rclpy + ros2_interfaces_pkg + + ament_copyright + ament_flake8 + ament_pep257 + python3-pytest + + + ament_python + + diff --git a/src/bio_pkg/resource/bio_pkg b/src/bio_pkg/resource/bio_pkg new file mode 100644 index 0000000..e69de29 diff --git a/src/bio_pkg/setup.cfg b/src/bio_pkg/setup.cfg new file mode 100644 index 0000000..ac38480 --- /dev/null +++ b/src/bio_pkg/setup.cfg @@ -0,0 +1,4 @@ +[develop] +script_dir=$base/lib/bio_pkg +[install] +install_scripts=$base/lib/bio_pkg diff --git a/src/bio_pkg/setup.py b/src/bio_pkg/setup.py new file mode 100644 index 0000000..5707e42 --- /dev/null +++ b/src/bio_pkg/setup.py @@ -0,0 +1,25 @@ +from setuptools import find_packages, setup + +package_name = 'bio_pkg' + +setup( + name=package_name, + version='0.0.0', + packages=find_packages(exclude=['test']), + data_files=[ + ('share/ament_index/resource_index/packages', + ['resource/' + package_name]), + ('share/' + package_name, ['package.xml']), + ], + install_requires=['setuptools'], + zip_safe=True, + maintainer='tristan', + maintainer_email='tristanmcginnis26@gmail.com', + description='TODO: Package description', + license='TODO: License declaration', + entry_points={ + 'console_scripts': [ + 'bio = bio_pkg.bio_node:main' + ], + }, +) diff --git a/src/core_pkg/core_pkg/core_node.py b/src/core_pkg/core_pkg/core_node.py index 8b4aeff..4ec6362 100644 --- a/src/core_pkg/core_pkg/core_node.py +++ b/src/core_pkg/core_pkg/core_node.py @@ -185,7 +185,7 @@ class SerialRelay(Node): self.ser.write(bytes(msg, "utf8")) def anchor_feedback(self, msg): - self.get_logger().info(f"[Arm Anchor] {msg}") + self.get_logger().info(f"[Core Anchor] {msg}") def ping_callback(self, request, response): return response diff --git a/src/ros2_interfaces_pkg b/src/ros2_interfaces_pkg index d29996f..7ab9cfc 160000 --- a/src/ros2_interfaces_pkg +++ b/src/ros2_interfaces_pkg @@ -1 +1 @@ -Subproject commit d29996f544d19e76bddc84a20c70a6c52bc4ee14 +Subproject commit 7ab9cfc8b2e48b09087ac6325f1ec732b7dfce28 From ec33dfd02d4788d55e9fb5a0afa348346d954b70 Mon Sep 17 00:00:00 2001 From: Tristan McGinnis Date: Mon, 24 Feb 2025 19:11:13 -0600 Subject: [PATCH 2/9] subup and update bio control CAN commands --- src/bio_pkg/bio_pkg/bio_node.py | 60 ++++++++++----------------------- src/ros2_interfaces_pkg | 2 +- 2 files changed, 19 insertions(+), 43 deletions(-) diff --git a/src/bio_pkg/bio_pkg/bio_node.py b/src/bio_pkg/bio_pkg/bio_node.py index 9004d8a..26f50ad 100644 --- a/src/bio_pkg/bio_pkg/bio_node.py +++ b/src/bio_pkg/bio_pkg/bio_node.py @@ -118,62 +118,38 @@ class SerialRelay(Node): def send_control(self, msg): + # Chem Pumps, only send if not zero if msg.pumpID != 0: command = "can_relay_tovic,citadel,27," + str(msg.pumpID) + "," + str(msg.pumpAmount) + "\n" self.send_cmd(command) + # Fans, only send if not zero if msg.fanID != 0: command = "can_relay_tovic,citadel,40," + str(msg.fanID) + "," + str(msg.fanDuration) + "\n" self.send_cmd(command) + # Servos, only send if not zero if msg.servoID != 0: command = "can_relay_tovic,citadel,25," + str(msg.servoID) + "," + str(msg.servoPosition) + "\n" - self.send_cmd(command) - - ######### - # To add LSS command here - ######### - - command = "can_relay_tovic,citadel,26," + str(msg.vibrationMotor) + "\n" - self.send_cmd(command) - - def send_manual(self, msg): - axis0 = msg.axis0 - axis1 = msg.axis1 - axis2 = msg.axis2 - axis3 = msg.axis3 - - #Send controls for arm - command = "can_relay_tovic,arm,40," + str(axis0) + "," + str(axis1) + "," + str(axis2) + "," + str(axis3) + "\n" - self.send_cmd(command) + self.send_cmd(command) + #Always update for turning on/off - #Send controls for end effector - command = "can_relay_tovic,digit,35," + str(msg.effector_roll) + "\n" + # LSS + command = "can_relay_tovic,citadel,26," + str(msg.lssDirection) + "\n" self.send_cmd(command) - - command = "can_relay_tovic,digit,36,0," + str(msg.effector_yaw) + "\n" + # Drill + command = "can_relay_tovic,citadel,19," + str(msg.drillDuty) + "\n" + self.send_cmd(command) + # Vibration Motor + command = "can_relay_tovic,citadel,37," + str(msg.vibrationMotor) + "\n" + self.send_cmd(command) + # Laser + command = "can_relay_tovic,citadel,28," + str(msg.laser) + "\n" + self.send_cmd(command) + # UV Light + command = "can_relay_tovic,citadel,38," + str(msg.uvLight) + "\n" self.send_cmd(command) - command = "can_relay_tovic,digit,26," + str(msg.gripper) + "\n" - self.send_cmd(command) - command = "can_relay_tovic,digit,28," + str(msg.laser) + "\n" - self.send_cmd(command) - - - - #print(f"[Wrote] {command}", end="") - #Not yet finished, needs embedded implementation for new commands - # ef_roll = msg.effector_roll - # ef_yaw = msg.effector_yaw - # gripper = msg.gripper - # actuator = msg.linear_actuator - # laser = msg.laser - # #Send controls for digit - - # command = "can_relay_tovic,digit," + str(ef_roll) + "," + str(ef_yaw) + "," + str(gripper) + "," + str(actuator) + "," + str(laser) + "\n" - - return - def send_cmd(self, msg): if self.launch_mode == 'anchor': #if in anchor mode, send to anchor node to relay output = String() diff --git a/src/ros2_interfaces_pkg b/src/ros2_interfaces_pkg index 7ab9cfc..9c62a20 160000 --- a/src/ros2_interfaces_pkg +++ b/src/ros2_interfaces_pkg @@ -1 +1 @@ -Subproject commit 7ab9cfc8b2e48b09087ac6325f1ec732b7dfce28 +Subproject commit 9c62a208b2f001f39beaf326439a0cdc0b389d89 From fe7e00d7b88c9b1ee22b8ba9e50d8f7a7de86dbc Mon Sep 17 00:00:00 2001 From: Tristan McGinnis Date: Tue, 25 Feb 2025 11:08:11 -0600 Subject: [PATCH 3/9] update arm CAN command --- src/arm_pkg/arm_pkg/arm_node.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arm_pkg/arm_pkg/arm_node.py b/src/arm_pkg/arm_pkg/arm_node.py index 63c5a57..5325a57 100644 --- a/src/arm_pkg/arm_pkg/arm_node.py +++ b/src/arm_pkg/arm_pkg/arm_node.py @@ -127,7 +127,7 @@ class SerialRelay(Node): axis3 = msg.axis3 #Send controls for arm - command = "can_relay_tovic,arm,40," + str(axis0) + "," + str(axis1) + "," + str(axis2) + "," + str(axis3) + "\n" + command = "can_relay_tovic,arm,39," + str(axis0) + "," + str(axis1) + "," + str(axis2) + "," + str(axis3) + "\n" self.send_cmd(command) #Send controls for end effector From 068ecbae4b9d8a4c97a98244b5591e0a1fd4e02b Mon Sep 17 00:00:00 2001 From: Tristan McGinnis Date: Wed, 26 Feb 2025 11:06:42 -0600 Subject: [PATCH 4/9] Update Citadel vicCAN cmd IDS & subup --- src/bio_pkg/bio_pkg/bio_node.py | 37 ++++++++++++++++++++++----------- src/ros2_interfaces_pkg | 2 +- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/bio_pkg/bio_pkg/bio_node.py b/src/bio_pkg/bio_pkg/bio_node.py index 26f50ad..8a11510 100644 --- a/src/bio_pkg/bio_pkg/bio_node.py +++ b/src/bio_pkg/bio_pkg/bio_node.py @@ -118,6 +118,10 @@ class SerialRelay(Node): def send_control(self, msg): + # CITADEL Control Commands + ################ + + # Chem Pumps, only send if not zero if msg.pumpID != 0: command = "can_relay_tovic,citadel,27," + str(msg.pumpID) + "," + str(msg.pumpAmount) + "\n" @@ -130,23 +134,32 @@ class SerialRelay(Node): if msg.servoID != 0: command = "can_relay_tovic,citadel,25," + str(msg.servoID) + "," + str(msg.servoPosition) + "\n" self.send_cmd(command) - #Always update for turning on/off + # LSS - command = "can_relay_tovic,citadel,26," + str(msg.lssDirection) + "\n" - self.send_cmd(command) - # Drill - command = "can_relay_tovic,citadel,19," + str(msg.drillDuty) + "\n" + command = "can_relay_tovic,citadel,24," + str(msg.lssDirection) + "\n" self.send_cmd(command) # Vibration Motor - command = "can_relay_tovic,citadel,37," + str(msg.vibrationMotor) + "\n" - self.send_cmd(command) - # Laser - command = "can_relay_tovic,citadel,28," + str(msg.laser) + "\n" - self.send_cmd(command) - # UV Light - command = "can_relay_tovic,citadel,38," + str(msg.uvLight) + "\n" + command = "can_relay_tovic,citadel,26," + str(msg.vibrationMotor) + "\n" self.send_cmd(command) + + + # FAERIE Control Commands + ################ + + # To be reviewed before use# + + # # Laser + # command = "can_relay_tovic,faerie,28," + str(msg.laser) + "\n" + # self.send_cmd(command) + + # # UV Light + # command = "can_relay_tovic,faerie,38," + str(msg.uvLight) + "\n" + # self.send_cmd(command) + + # # Drill + # command = "can_relay_tovic,faerie,19," + str(msg.drillDuty) + "\n" + # self.send_cmd(command) diff --git a/src/ros2_interfaces_pkg b/src/ros2_interfaces_pkg index 9c62a20..d2bdbed 160000 --- a/src/ros2_interfaces_pkg +++ b/src/ros2_interfaces_pkg @@ -1 +1 @@ -Subproject commit 9c62a208b2f001f39beaf326439a0cdc0b389d89 +Subproject commit d2bdbedb2685644fbf6588cd4ad0bd6112777a4a From 796c4e75d92dabbfe1431e6895a11a9a9d3873b2 Mon Sep 17 00:00:00 2001 From: Tristan McGinnis Date: Wed, 26 Feb 2025 14:43:04 -0600 Subject: [PATCH 5/9] Activated bio in rover_launch.py --- rover_launch.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/rover_launch.py b/rover_launch.py index e34a34d..64a4ccb 100644 --- a/rover_launch.py +++ b/rover_launch.py @@ -76,16 +76,16 @@ def launch_setup(context, *args, **kwargs): parameters=[{'launch_mode': mode}] ) ) - # elif mode == 'bio': - # nodes.append( - # Node( - # package='bio_pkg', - # executable='bio', - # name='bio', - # output='both', - # parameters=[{'launch_mode': mode}] - # ) - # ) + elif mode == 'bio': + nodes.append( + Node( + package='bio_pkg', + executable='bio', + name='bio', + output='both', + parameters=[{'launch_mode': mode}] + ) + ) else: # If an invalid mode is provided, print an error. # (You might want to raise an exception or handle it differently.) From 1ccc2e5def2dd8de93e71548e00a4ed752acdcfb Mon Sep 17 00:00:00 2001 From: Tristan McGinnis Date: Wed, 26 Feb 2025 15:01:14 -0600 Subject: [PATCH 6/9] Add bio to launch.py --- rover_launch.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/rover_launch.py b/rover_launch.py index 64a4ccb..05a9599 100644 --- a/rover_launch.py +++ b/rover_launch.py @@ -36,15 +36,15 @@ def launch_setup(context, *args, **kwargs): parameters=[{'launch_mode': mode}] ) ) - # nodes.append( - # Node( - # package='bio_pkg', - # executable='bio', # change as needed - # name='bio', - # output='both', - # parameters=[{'launch_mode': mode}] - # ) - # ) + nodes.append( + Node( + package='bio_pkg', + executable='bio', # change as needed + name='bio', + output='both', + parameters=[{'launch_mode': mode}] + ) + ) nodes.append( Node( package='anchor_pkg', From d38f44a47e361692036bfa618df17f449435efd1 Mon Sep 17 00:00:00 2001 From: Tristan McGinnis Date: Thu, 27 Feb 2025 13:44:25 -0600 Subject: [PATCH 7/9] Subup and update for interface changes --- src/bio_pkg/bio_pkg/bio_node.py | 23 ++++++++++++----------- src/ros2_interfaces_pkg | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/bio_pkg/bio_pkg/bio_node.py b/src/bio_pkg/bio_pkg/bio_node.py index 8a11510..80e0594 100644 --- a/src/bio_pkg/bio_pkg/bio_node.py +++ b/src/bio_pkg/bio_pkg/bio_node.py @@ -123,24 +123,24 @@ class SerialRelay(Node): # Chem Pumps, only send if not zero - if msg.pumpID != 0: - command = "can_relay_tovic,citadel,27," + str(msg.pumpID) + "," + str(msg.pumpAmount) + "\n" + if msg.pump_id != 0: + command = "can_relay_tovic,citadel,27," + str(msg.pump_id) + "," + str(msg.pump_amount) + "\n" self.send_cmd(command) # Fans, only send if not zero - if msg.fanID != 0: - command = "can_relay_tovic,citadel,40," + str(msg.fanID) + "," + str(msg.fanDuration) + "\n" + if msg.fan_id != 0: + command = "can_relay_tovic,citadel,40," + str(msg.fan_id) + "," + str(msg.fan_duration) + "\n" self.send_cmd(command) # Servos, only send if not zero - if msg.servoID != 0: - command = "can_relay_tovic,citadel,25," + str(msg.servoID) + "," + str(msg.servoPosition) + "\n" + if msg.servo_id != 0: + command = "can_relay_tovic,citadel,25," + str(msg.servo_id) + "," + str(msg.servo_position) + "\n" self.send_cmd(command) # LSS - command = "can_relay_tovic,citadel,24," + str(msg.lssDirection) + "\n" + command = "can_relay_tovic,citadel,24," + str(msg.lss_direction) + "\n" self.send_cmd(command) # Vibration Motor - command = "can_relay_tovic,citadel,26," + str(msg.vibrationMotor) + "\n" + command = "can_relay_tovic,citadel,26," + str(msg.vibration_motor) + "\n" self.send_cmd(command) @@ -157,9 +157,10 @@ class SerialRelay(Node): # command = "can_relay_tovic,faerie,38," + str(msg.uvLight) + "\n" # self.send_cmd(command) - # # Drill - # command = "can_relay_tovic,faerie,19," + str(msg.drillDuty) + "\n" - # self.send_cmd(command) + # Drill + command = "can_relay_tovic,faerie,19," + str(msg.drill_duty) + "\n" + print(msg.drill_duty) + self.send_cmd(command) diff --git a/src/ros2_interfaces_pkg b/src/ros2_interfaces_pkg index d2bdbed..ca65155 160000 --- a/src/ros2_interfaces_pkg +++ b/src/ros2_interfaces_pkg @@ -1 +1 @@ -Subproject commit d2bdbedb2685644fbf6588cd4ad0bd6112777a4a +Subproject commit ca65155cd75c8b78a1cccef972d19fb511c83fea From 87c340968c01d828df79f84d39d9be8f6fe62e26 Mon Sep 17 00:00:00 2001 From: Tristan McGinnis Date: Thu, 27 Feb 2025 14:34:15 -0600 Subject: [PATCH 8/9] Specify precision for drill_duty CAN packet --- src/bio_pkg/bio_pkg/bio_node.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bio_pkg/bio_pkg/bio_node.py b/src/bio_pkg/bio_pkg/bio_node.py index 80e0594..d7789fd 100644 --- a/src/bio_pkg/bio_pkg/bio_node.py +++ b/src/bio_pkg/bio_pkg/bio_node.py @@ -158,7 +158,7 @@ class SerialRelay(Node): # self.send_cmd(command) # Drill - command = "can_relay_tovic,faerie,19," + str(msg.drill_duty) + "\n" + command = f"can_relay_tovic,faerie,19,{msg.drill_duty:.2f}\n" print(msg.drill_duty) self.send_cmd(command) From f0d2ed69d8b02dc3ad13c3d531757c4df8307254 Mon Sep 17 00:00:00 2001 From: Tristan McGinnis Date: Thu, 27 Feb 2025 14:43:40 -0600 Subject: [PATCH 9/9] bio: enable laser control --- src/bio_pkg/bio_pkg/bio_node.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bio_pkg/bio_pkg/bio_node.py b/src/bio_pkg/bio_pkg/bio_node.py index d7789fd..1523ecd 100644 --- a/src/bio_pkg/bio_pkg/bio_node.py +++ b/src/bio_pkg/bio_pkg/bio_node.py @@ -149,9 +149,9 @@ class SerialRelay(Node): # To be reviewed before use# - # # Laser - # command = "can_relay_tovic,faerie,28," + str(msg.laser) + "\n" - # self.send_cmd(command) + # Laser + command = "can_relay_tovic,faerie,28," + str(msg.laser) + "\n" + self.send_cmd(command) # # UV Light # command = "can_relay_tovic,faerie,38," + str(msg.uvLight) + "\n"