@@ -63,10 +63,13 @@ def __init__(self):
63
63
self .publisher_rviz_torque = self .create_publisher (MarkerArray , '/torque_visualization' , 10 )
64
64
65
65
# Pusblisher for point cloud workspace area
66
- self .publisher_workspace_area = self .create_publisher (MarkerArray , '/workspace_area' , 10 )
66
+ self .publisher_workspace_area = self .create_publisher (MarkerArray , '/workspace_area' , qos_profile = rclpy . qos . QoSProfile ( durability = rclpy . qos . DurabilityPolicy . TRANSIENT_LOCAL , depth = 1 ) )
67
67
68
68
# Pusblisher for point cloud of maximum payloads in the workspace area
69
- self .publisher_maximum_payloads = self .create_publisher (MarkerArray , '/maximum_payloads' , 10 )
69
+ self .publisher_maximum_payloads = self .create_publisher (MarkerArray , '/maximum_payloads' , qos_profile = rclpy .qos .QoSProfile ( durability = rclpy .qos .DurabilityPolicy .TRANSIENT_LOCAL , depth = 1 ))
70
+
71
+ # Publisher for point cloud of all analyzed points
72
+ self .publisher_analyzed_points = self .create_publisher (MarkerArray , '/analyzed_points' , qos_profile = rclpy .qos .QoSProfile ( durability = rclpy .qos .DurabilityPolicy .TRANSIENT_LOCAL , depth = 1 ))
70
73
71
74
# subscription to joint states
72
75
self .joint_states_subscription = self .create_subscription (JointState , '/joint_states' , self .joint_states_callback , 10 )
@@ -103,6 +106,9 @@ def __init__(self):
103
106
# variable to store if there is a selected configuration from the workspace menu to visualize
104
107
self .selected_configuration = None
105
108
109
+ # variable to store analyzed points of the workspace area
110
+ self .marker_analyzed_points = None
111
+
106
112
# timer to compute the valid workspace area
107
113
self .timer_workspace_calculation = self .create_timer (1.0 , self .workspace_calculation )
108
114
# timer to publish the selected configuration in joint states
@@ -161,6 +167,53 @@ def update_payload_selection(self):
161
167
162
168
self .links = links # Update the links to the current ones
163
169
170
+
171
+ def publisher_analyzed_point_markers (self ):
172
+ """
173
+ Publish the analyzed points in the workspace area.
174
+ This will publish all the points in the workspace area where the robot can reach with the current configuration.
175
+ """
176
+ if self .menu is not None :
177
+
178
+ if len (self .robot_handler .get_analyzed_points ()) == 0 :
179
+ return
180
+ else :
181
+ if self .marker_analyzed_points is None :
182
+
183
+ self .marker_analyzed_points = MarkerArray ()
184
+
185
+ # publish the analyzed points
186
+ for i , analyzed_point in enumerate (self .robot_handler .get_analyzed_points ()):
187
+ point = Marker ()
188
+ point .header .frame_id = self .robot_handler .get_root_name ()
189
+ point .header .stamp = Time ()
190
+ point .ns = f"analyzed_points_ns"
191
+ point .id = i
192
+ point .type = Marker .SPHERE
193
+ point .action = Marker .ADD
194
+ point .scale .x = 0.01
195
+ point .scale .y = 0.01
196
+ point .scale .z = 0.01
197
+ point .pose .position .x = analyzed_point ['position' ][0 ]
198
+ point .pose .position .y = analyzed_point ['position' ][1 ]
199
+ point .pose .position .z = analyzed_point ['position' ][2 ]
200
+ point .pose .orientation .w = 1.0
201
+ point .color .a = 1.0 # Alpha
202
+ point .color .r = 1.0 # Red
203
+ point .color .g = 1.0 # Green
204
+ point .color .b = 1.0 # Blue
205
+
206
+ self .marker_analyzed_points .markers .append (point )
207
+
208
+ self .publisher_analyzed_points .publish (self .marker_analyzed_points )
209
+
210
+ else :
211
+ # update with current time
212
+ for marker in self .marker_analyzed_points .markers :
213
+ marker .header .stamp = Time ()
214
+
215
+ self .publisher_analyzed_points .publish (self .marker_analyzed_points )
216
+
164
217
def publish_payload_force (self ):
165
218
"""
166
219
Publish the gravity force on the frame with id `id_force`.
@@ -227,6 +280,9 @@ def workspace_calculation(self):
227
280
228
281
# compute the maximum payloads for the valid configurations
229
282
self .valid_configurations = self .robot_handler .compute_maximum_payloads (self .valid_configurations )
283
+
284
+ # publish the analyzed points in the workspace area
285
+ self .publisher_analyzed_point_markers ()
230
286
231
287
# insert the valid configurations in the menu
232
288
self .menu .insert_dropdown_configuration (self .valid_configurations )
0 commit comments