Signed-off-by: Jakub Delicat <delicat.kuba@gmail.com>
This commit is contained in:
Jakub Delicat 2023-08-16 16:33:44 +02:00
parent 7360abc3f4
commit 21d327c74f

View File

@ -3,9 +3,9 @@
from safety_master_plugin.clutch_state import ClutchState as CS from safety_master_plugin.clutch_state import ClutchState as CS
from safety_master_plugin.stop_state import StopState as SS from safety_master_plugin.stop_state import StopState as SS
class RobotInfo:
def __init__(self,robot_id): class RobotInfo:
def __init__(self, robot_id):
self.robot_id = robot_id self.robot_id = robot_id
self.battery_voltage = None self.battery_voltage = None
self.linear_velocity = None self.linear_velocity = None
@ -13,18 +13,26 @@ class RobotInfo:
self.state = None self.state = None
self.clutch = None self.clutch = None
def update_robot_info(self,robot_info_msg): def update_robot_info(self, robot_info_msg):
self.robot_id = robot_info_msg.robot_id.data self.robot_id = robot_info_msg.robot_id.data
self.battery_voltage = robot_info_msg.battery_voltage.data self.battery_voltage = robot_info_msg.battery_voltage.data
self.linear_velocity = [robot_info_msg.twist.linear.x,robot_info_msg.twist.linear.y,robot_info_msg.twist.linear.z] self.linear_velocity = [
self.angular_velocity = [robot_info_msg.twist.angular.x,robot_info_msg.twist.angular.y,robot_info_msg.twist.angular.z] robot_info_msg.twist.linear.x,
robot_info_msg.twist.linear.y,
robot_info_msg.twist.linear.z,
]
self.angular_velocity = [
robot_info_msg.twist.angular.x,
robot_info_msg.twist.angular.y,
robot_info_msg.twist.angular.z,
]
if robot_info_msg.state.data == True: if robot_info_msg.state.data is True:
self.state = SS.RUNNING self.state = SS.RUNNING
else: else:
self.state = SS.STOPPED self.state = SS.STOPPED
if robot_info_msg.clutch.data == True: if robot_info_msg.clutch.data is True:
self.clutch = CS.ENGAGED self.clutch = CS.ENGAGED
else: else:
self.clutch = CS.DISENGAGED self.clutch = CS.DISENGAGED