2 """ This simple script creates an interactive marker for changing desired centering pose of 3 two the dual_panda_cartesian_impedance_example_controller. It features also resetting the 4 marker to current centering pose between the left and the right endeffector. 11 InteractiveMarkerServer, InteractiveMarkerFeedback
12 from visualization_msgs.msg
import InteractiveMarker, \
13 InteractiveMarkerControl, Marker
14 from franka_msgs.msg
import FrankaState
15 from geometry_msgs.msg
import PoseStamped
17 marker_pose = PoseStamped()
19 centering_frame_ready =
False 22 left_has_error =
False 23 right_has_error =
False 30 This function returns sphere marker for 3D translational movements. 31 :param scale: scales the size of the sphere 32 :return: sphere marker 35 marker.type = Marker.SPHERE
36 marker.scale.x = scale * 0.45
37 marker.scale.y = scale * 0.45
38 marker.scale.z = scale * 0.45
48 This function publishes desired centering pose which the controller will subscribe to. 51 marker_pose.header.stamp = rospy.Time(0)
52 pose_pub.publish(marker_pose)
57 This callback function set `has_error` variable to True if the left arm is having an error. 58 :param msg: FrankaState msg data 61 global has_error, left_has_error
62 if msg.robot_mode == FrankaState.ROBOT_MODE_MOVE:
63 left_has_error =
False 66 has_error = left_has_error
or right_has_error
71 This callback function set `has_error` variable to True if the right arm is having an error. 72 :param msg: FrankaState msg data 75 global has_error, right_has_error
76 if msg.robot_mode == FrankaState.ROBOT_MODE_MOVE:
77 right_has_error =
False 79 right_has_error =
True 80 has_error = left_has_error
or right_has_error
85 This callback function sets the marker pose to the current centering pose from a subscribed topic. 88 global centering_frame_ready
92 centering_frame_ready =
True 97 This function resets the marker pose to current "middle pose" of left and right arm EEs. 101 global centering_frame_ready
104 centering_frame_ready =
False 106 centering_frame_pose_sub = rospy.Subscriber(
107 "dual_arm_cartesian_impedance_example_controller/centering_frame",
108 PoseStamped, centering_pose_callback)
111 while not centering_frame_ready:
114 centering_frame_pose_sub.unregister()
119 This callback function clips the marker_pose inside a predefined box to prevent misuse of the marker. 120 :param feedback: feedback data of interactive marker 124 if feedback.event_type == InteractiveMarkerFeedback.POSE_UPDATE:
125 marker_pose.pose.position.x = feedback.pose.position.x
126 marker_pose.pose.position.y = feedback.pose.position.y
127 marker_pose.pose.position.z = feedback.pose.position.z
128 marker_pose.pose.orientation = feedback.pose.orientation
129 server.applyChanges()
132 if __name__ ==
"__main__":
133 rospy.init_node(
"target_pose_node")
135 parser = argparse.ArgumentParser(
"dual_panda_interactive_marker.py")
136 parser.add_argument(
"--left_arm_id",
137 help=
"The id of the left arm.",
139 parser.add_argument(
"--right_arm_id",
140 help=
"The id of the right arm.",
142 parser.add_argument(
'args', nargs=argparse.REMAINDER)
143 args = parser.parse_args()
146 left_arm_id = args.left_arm_id
147 right_arm_id = args.right_arm_id
150 left_state_sub = rospy.Subscriber(left_arm_id +
"_state_controller/franka_states",
151 FrankaState, left_franka_state_callback)
153 right_state_sub = rospy.Subscriber(right_arm_id +
"_state_controller/franka_states",
154 FrankaState, right_franka_state_callback)
160 pose_pub = rospy.Publisher(
161 "dual_arm_cartesian_impedance_example_controller/centering_frame_target_pose",
166 server = InteractiveMarkerServer(
"target_pose_marker")
167 int_marker = InteractiveMarker()
168 int_marker.header.frame_id = marker_pose.header.frame_id
169 int_marker.scale = 0.3
170 int_marker.name =
"centering_frame_pose" 171 int_marker.description = (
"Target centering pose\n" 173 "If you move the target marker\n" 174 "both robots will follow it \n" 175 "as the center between the two\n" 176 "endeffectors. Be aware of\n" 177 "potential collisions!")
178 int_marker.pose = marker_pose.pose
181 control = InteractiveMarkerControl()
182 control.orientation.w = 1
183 control.orientation.x = 1
184 control.orientation.y = 0
185 control.orientation.z = 0
186 control.name =
"rotate_x" 187 control.interaction_mode = InteractiveMarkerControl.ROTATE_AXIS
188 int_marker.controls.append(control)
190 control = InteractiveMarkerControl()
191 control.orientation.w = 1
192 control.orientation.x = 1
193 control.orientation.y = 0
194 control.orientation.z = 0
195 control.name =
"move_x" 196 control.interaction_mode = InteractiveMarkerControl.MOVE_AXIS
197 int_marker.controls.append(control)
198 control = InteractiveMarkerControl()
199 control.orientation.w = 1
200 control.orientation.x = 0
201 control.orientation.y = 1
202 control.orientation.z = 0
203 control.name =
"rotate_y" 204 control.interaction_mode = InteractiveMarkerControl.ROTATE_AXIS
205 int_marker.controls.append(control)
206 control = InteractiveMarkerControl()
207 control.orientation.w = 1
208 control.orientation.x = 0
209 control.orientation.y = 1
210 control.orientation.z = 0
211 control.name =
"move_y" 212 control.interaction_mode = InteractiveMarkerControl.MOVE_AXIS
213 int_marker.controls.append(control)
214 control = InteractiveMarkerControl()
215 control.orientation.w = 1
216 control.orientation.x = 0
217 control.orientation.y = 0
218 control.orientation.z = 1
219 control.name =
"rotate_z" 220 control.interaction_mode = InteractiveMarkerControl.ROTATE_AXIS
221 int_marker.controls.append(control)
222 control = InteractiveMarkerControl()
223 control.orientation.w = 1
224 control.orientation.x = 0
225 control.orientation.y = 0
226 control.orientation.z = 1
227 control.name =
"move_z" 228 control.interaction_mode = InteractiveMarkerControl.MOVE_AXIS
229 int_marker.controls.append(control)
230 control = InteractiveMarkerControl()
231 control.orientation.w = 1
232 control.orientation.x = 1
233 control.orientation.y = 1
234 control.orientation.z = 1
235 control.name =
"move_3D" 236 control.always_visible =
True 238 control.interaction_mode = InteractiveMarkerControl.MOVE_3D
239 int_marker.controls.append(control)
241 server.insert(int_marker, process_feedback)
242 server.applyChanges()
245 while not rospy.is_shutdown():
250 server.setPose(
"centering_frame_pose", marker_pose.pose)
251 server.applyChanges()
def process_feedback(feedback)
def centering_pose_callback(msg)
def make_sphere(scale=0.3)
def right_franka_state_callback(msg)
def publish_target_pose()
def left_franka_state_callback(msg)
def reset_marker_pose_blocking()