Skip to content

Commit

Permalink
feat: add rely script
Browse files Browse the repository at this point in the history
Signed-off-by: TetsuKawa <kawaguchitnon@icloud.com>
  • Loading branch information
TetsuKawa committed Jun 28, 2024
1 parent b0adbf8 commit 67eb555
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
6 changes: 6 additions & 0 deletions simulator/simple_planning_simulator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ rclcpp_components_register_node(${PROJECT_NAME}
EXECUTABLE ${PROJECT_NAME}_exe
)

install(PROGRAMS
tool/rely_trajectry.py

Check warning on line 33 in simulator/simple_planning_simulator/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (trajectry)

Check warning on line 33 in simulator/simple_planning_simulator/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / spell-check-partial

Unknown word (trajectry)
DESTINATION lib/${PROJECT_NAME}
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
)

if(BUILD_TESTING)
ament_add_ros_isolated_gtest(test_simple_planning_simulator
test/test_simple_planning_simulator.cpp
Expand Down
47 changes: 47 additions & 0 deletions system/control_cmd_switcher/tool/rely_trajectry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env python3

import rclpy
from rclpy.node import Node
from autoware_auto_planning_msgs.msg import Trajectory
import threading

class RelayTrajectoryNode(Node):

def __init__(self):
super().__init__('relay_trajectory')
self.subscription = self.create_subscription(
Trajectory,
'/tmp/planning/scenario_planning/trajectory',
self.listener_callback,
10)
self.publisher = self.create_publisher(Trajectory, '/planning/scenario_planning/trajectory', 10)
self.running = True

def listener_callback(self, msg):
if self.running:
self.publisher.publish(msg)

def main(args=None):
rclpy.init(args=args)
node = RelayTrajectoryNode()

def input_thread():
nonlocal node
while True:
user_input = input("Enter 'y' to stop publishing: ")
if user_input.lower() == 'y':
node.running = False
print("Publishing stopped.")
break

thread = threading.Thread(target=input_thread)
thread.start()

rclpy.spin(node)

thread.join()
node.destroy_node()
rclpy.shutdown()

if __name__ == '__main__':
main()

0 comments on commit 67eb555

Please sign in to comment.