-
Notifications
You must be signed in to change notification settings - Fork 27
sub8_thrust_and_kill_board, NaviGator/mission_control/navigator_alarm migration, navigator_emergency_control, navigator_joystick_control, and navigator_keyboard_control to ROS2 #1174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: ros2
Are you sure you want to change the base?
Changes from 5 commits
10cfae7
e7a9030
8c9cbd5
4d5ac5f
27091f6
f6786ea
8734935
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
|
Nihar3430 marked this conversation as resolved.
|
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| #!/usr/bin/python3 | ||
| import rospy | ||
| import rclpy | ||
| from mil_usb_to_can.sub8 import SimulatedCANDevice | ||
| from rclpy.duration import Duration | ||
| from std_srvs.srv import SetBool, SetBoolRequest, SetBoolResponse | ||
|
|
||
| from .packets import ( | ||
|
|
@@ -27,7 +28,7 @@ class ThrusterAndKillBoardSimulation(SimulatedCANDevice): | |
| soft_kill_mobo (bool): Whether the motherboard experienced a soft kill request. | ||
| """ | ||
|
|
||
| HEARTBEAT_TIMEOUT_SECONDS = rospy.Duration(1.0) | ||
| HEARTBEAT_TIMEOUT_SECONDS = Duration(seconds=1.0) | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| self.hard_kill_plug_pulled = False | ||
|
|
@@ -37,18 +38,18 @@ def __init__(self, *args, **kwargs): | |
| self.go_button = False | ||
| self._last_heartbeat = None | ||
| super().__init__(*args, **kwargs) | ||
| self._update_timer = rospy.Timer(rospy.Duration(1), self.send_updates) | ||
| self._soft_kill = rospy.Service( | ||
| "/simulate_soft_kill", | ||
| self._update_timer = rclpy.create_timer(1.0, self.send_updates) | ||
| self._soft_kill = self.create_service( | ||
| SetBool, | ||
| "/simulate_soft_kill", | ||
| self.set_soft_kill, | ||
| ) | ||
| self._hard_kill = rospy.Service( | ||
| "/simulate_hard_kill", | ||
| self._hard_kill = self.create_service( | ||
| SetBool, | ||
| "/simulate_hard_kill", | ||
| self.set_hard_kill, | ||
| ) | ||
| self._go_srv = rospy.Service("/simulate_go", SetBool, self._on_go_srv) | ||
| self._go_srv = self.create_service(SetBool, "/simulate_go", self._on_go_srv) | ||
|
|
||
| def _on_go_srv(self, req): | ||
| self.go_button = req.data | ||
|
|
@@ -102,7 +103,7 @@ def heartbeat_timedout(self) -> bool: | |
| """ | ||
| return ( | ||
| self._last_heartbeat is None | ||
| or (rospy.Time.now() - self._last_heartbeat) | ||
| or (self.get_clock().now() - self._last_heartbeat) | ||
| > self.HEARTBEAT_TIMEOUT_SECONDS | ||
| ) | ||
|
|
||
|
|
@@ -154,6 +155,6 @@ def on_data(self, data: bytes, can_id: int) -> None: | |
| packet = ThrustPacket.from_bytes(data) | ||
| elif data[0] == HeartbeatMessage.IDENTIFIER: | ||
| packet = HeartbeatMessage.from_bytes(data) | ||
| self._last_heartbeat = rospy.Time.now() | ||
| self._last_heartbeat = self.get_clock().now() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, for this, you're going to need to make this class into a node. Otherwise, it will not be able to get the current time.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if I use the Clock().now() command from rclpy.clock? The current time is stored in a variable and the Clock().now() retrieves the current time without the need for a node. |
||
| else: | ||
| raise Exception("No recognized identifier") | ||
Uh oh!
There was an error while loading. Please reload this page.