@@ -41,7 +41,7 @@ def create_dummy_tool_path() -> ToolPath:
4141 return tool_path
4242
4343
44- def create_toolpath_from_yaml (file_path ) -> ToolPath :
44+ def create_toolpath_from_yaml (file_path : str ) -> ToolPath :
4545 """Create a ToolPath message from a YAML file."""
4646 with open (file_path , "r" ) as file :
4747 data = yaml .safe_load (file )
@@ -74,7 +74,7 @@ def create_toolpath_from_yaml(file_path) -> ToolPath:
7474class MotionClient (Node ):
7575 """A ROS2 node for motion planning and robot control."""
7676
77- def __init__ (self ):
77+ def __init__ (self ): - > None
7878 super ().__init__ ("motion_client" )
7979 toolpath_default = os .path .join (
8080 get_package_share_directory ("snp_motion_planning" ),
@@ -83,6 +83,8 @@ def __init__(self):
8383 )
8484 self .declare_parameter ("toolpath_file" , toolpath_default )
8585 self .toolpath_file = self .get_parameter ("toolpath_file" ).get_parameter_value ().string_value
86+ self .motion_group = self .get_parameter ("motion_group" ).get_parameter_value ().string_value
87+ self .tcp_frame = self .get_parameter ("tcp_frame" ).get_parameter_value ().string_value
8688
8789 self .planner = self .create_client (GenerateMotionPlan , "/generate_motion_plan" )
8890 self .controller = ActionClient (
@@ -98,16 +100,16 @@ def request_plan(self):
98100 inspection_toolpath = create_toolpath_from_yaml (self .toolpath_file )
99101
100102 req .tool_paths = [inspection_toolpath ]
101- req .motion_group = "manipulator"
102- req .tcp_frame = "tcp"
103+ req .motion_group = self . motion_group
104+ req .tcp_frame = self . tcp_frame
103105
104106 while not self .planner .wait_for_service (timeout_sec = 1.0 ):
105107 self .get_logger ().info ("Waiting for service /generate_motion_plan..." )
106108
107109 future = self .planner .call_async (req )
108110 return future
109111
110- def request_control (self , trajectory : JointTrajectory ):
112+ def request_control (self , trajectory : JointTrajectory ): - > rclpy . Future :
111113 """Request control of the robot's by sending a Joint trajectory to the action server"""
112114 goal_msg = FollowJointTrajectory .Goal ()
113115 goal_msg .trajectory = trajectory
@@ -119,7 +121,7 @@ def request_control(self, trajectory: JointTrajectory):
119121 ctrl_result_future = self .request_control_result (send_goal_future )
120122 return ctrl_result_future
121123
122- def request_control_result (self , future ) :
124+ def request_control_result (self , future : rclpy . Future ): - > rclpy . Future :
123125 """Wait for the result from the action server."""
124126
125127 goal_handle = future .result ()
@@ -133,15 +135,10 @@ def request_control_result(self, future):
133135 ctrl_result_future .add_done_callback (self .get_result_callback )
134136 return ctrl_result_future
135137
136- def get_result_callback (self , future ):
138+ def get_result_callback (self , future : rclpy . Future ): - > None
137139 result = future .result ().result
138140 self .get_logger ().info (f"Result: { result .error_string } " )
139141
140- def feedback_callback (self , feedback_msg ):
141- feedback = feedback_msg .feedback
142- self .get_logger ().info (f"Received feedback: { feedback .partial_sequence } " )
143-
144-
145142def main (args = None ):
146143 rclpy .init (args = args )
147144
0 commit comments