Skip to content

Commit 5b44be6

Browse files
authored
Added workspace walls to the planning scene (#82)
Added 3 workspace walls to the planning scene
1 parent ef64e83 commit 5b44be6

File tree

2 files changed

+100
-16
lines changed

2 files changed

+100
-16
lines changed

ada_feeding/config/ada_planning_scene.yaml

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,53 @@ ada_planning_scene:
66
- wheelchair_collision
77
- table
88
- head
9-
# For each object, specify the filename of the mesh, and the position and
10-
# orientation relative to the robot's base frame.
9+
- workspace_wall_front
10+
- workspace_wall_left
11+
- workspace_wall_top
12+
# For each object, specify:
13+
# - Shape: EITHER `filepath` (for a mesh) OR `primitive_type` and
14+
# `primitive_dims`(for a primitive -- see shape_msgs/SolidPrimitive.msg)
15+
# - Pose: `position` and `quat_xyzw` (see geometry_msgs/Pose.msg)
16+
# - Frame ID: `frame_id` (the frame_id of the object that the pose is
17+
# relative to)
1118
wheelchair: # the wheelchair mesh
1219
filename: wheelchair.stl
1320
position: [0.02, -0.02, -0.05]
1421
quat_xyzw: [0.0, 0.0, 0.0, 1.0]
15-
frame_id: root # the frame_id of the wheelchair meshthat the pose is relative to
22+
frame_id: root # the frame_id that the pose is relative to
1623
# an expanded mesh around the wheelchair to account for a user sitting in it
1724
wheelchair_collision:
1825
filename: wheelchair_collision.stl
1926
position: [0.02, -0.02, -0.05] # should match the wheelchair position
2027
quat_xyzw: [0.0, 0.0, 0.0, 1.0] # should match the wheelchair orientation
21-
frame_id: root # the frame_id of the wheelchair meshthat the pose is relative to
28+
frame_id: root # the frame_id that the pose is relative to
2229
table: # the table mesh
2330
filename: table.stl
2431
position: [0.08, -0.5, -0.45]
2532
quat_xyzw: [0.0, 0.0, 0.0, 1.0]
26-
frame_id: root # the frame_id of the wheelchair meshthat the pose is relative to
33+
frame_id: root # the frame_id that the pose is relative to
2734
head: # the head mesh
2835
filename: tom.stl
2936
# This is an initial guess of head position; it will be updated as the
3037
# robot perceives the face.
3138
position: [0.29, 0.35, 0.85]
3239
quat_xyzw: [-0.0616284, -0.0616284, -0.704416, 0.704416]
33-
frame_id: root # the frame_id of the wheelchair meshthat the pose is relative to
40+
frame_id: root # the frame_id that the pose is relative to
41+
workspace_wall_front:
42+
primitive_type: 1 # Box=1. See shape_msgs/SolidPrimitive.msg
43+
primitive_dims: [1.59, 0.01, 0.8] # Box has 3 dims: [x, y, z]
44+
position: [-0.05, -0.58, 0.65]
45+
quat_xyzw: [0.0, 0.0, 0.0, 1.0]
46+
frame_id: root # the frame_id that the pose is relative to
47+
workspace_wall_left:
48+
primitive_type: 1 # Box=1. See shape_msgs/SolidPrimitive.msg
49+
primitive_dims: [0.01, 1.5, 1.60] # Box has 3 dims: [x, y, z]
50+
position: [0.75, 0.17, 0.25]
51+
quat_xyzw: [0.0, 0.0, 0.0, 1.0]
52+
frame_id: root # the frame_id that the pose is relative to
53+
workspace_wall_top:
54+
primitive_type: 1 # Box=1. See shape_msgs/SolidPrimitive.msg
55+
primitive_dims: [1.59, 1.5, 0.01] # Box has 3 dims: [x, y, z]
56+
position: [-0.05, 0.17, 1.05]
57+
quat_xyzw: [0.0, 0.0, 0.0, 1.0]
58+
frame_id: root # the frame_id that the pose is relative to

ada_feeding/scripts/ada_planning_scene.py

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@
2323
from rclpy.node import Node
2424

2525
CollisionMeshParams = namedtuple(
26-
"CollisionMeshParams", ["filepath", "position", "quat_xyzw", "frame_id"]
26+
"CollisionMeshParams",
27+
[
28+
"filepath",
29+
"primitive_type",
30+
"primitive_dims",
31+
"position",
32+
"quat_xyzw",
33+
"frame_id",
34+
],
2735
)
2836

2937

@@ -108,15 +116,47 @@ def load_parameters(self) -> None:
108116
for object_id in object_ids.value:
109117
filename = self.declare_parameter(
110118
f"{object_id}.filename",
119+
None,
111120
descriptor=ParameterDescriptor(
112121
name="filename",
113122
type=ParameterType.PARAMETER_STRING,
114-
description=f"The filename of the mesh for the '{object_id}' object.",
123+
description=(
124+
f"The filename of the mesh for the '{object_id}' object. "
125+
"Either this or `primitive_type` and `primitive_dims` must "
126+
"be specified."
127+
),
128+
read_only=True,
129+
),
130+
)
131+
primitive_type = self.declare_parameter(
132+
f"{object_id}.primitive_type",
133+
None,
134+
descriptor=ParameterDescriptor(
135+
name="primitive_type",
136+
type=ParameterType.PARAMETER_INTEGER,
137+
description=(
138+
f"The primitive type of the '{object_id}' object. "
139+
"Either this and `primitive_dims` must be defined, or `filename`."
140+
),
141+
read_only=True,
142+
),
143+
)
144+
primitive_dims = self.declare_parameter(
145+
f"{object_id}.primitive_dims",
146+
None,
147+
descriptor=ParameterDescriptor(
148+
name="primitive_dims",
149+
type=ParameterType.PARAMETER_DOUBLE_ARRAY,
150+
description=(
151+
f"The dimensions of the '{object_id}' object. "
152+
"Either this and `primitive_type` must be defined, or `filename`."
153+
),
115154
read_only=True,
116155
),
117156
)
118157
position = self.declare_parameter(
119158
f"{object_id}.position",
159+
None,
120160
descriptor=ParameterDescriptor(
121161
name="position",
122162
type=ParameterType.PARAMETER_DOUBLE_ARRAY,
@@ -126,6 +166,7 @@ def load_parameters(self) -> None:
126166
)
127167
quat_xyzw = self.declare_parameter(
128168
f"{object_id}.quat_xyzw",
169+
None,
129170
descriptor=ParameterDescriptor(
130171
name="quat_xyzw",
131172
type=ParameterType.PARAMETER_DOUBLE_ARRAY,
@@ -138,6 +179,7 @@ def load_parameters(self) -> None:
138179
)
139180
frame_id = self.declare_parameter(
140181
f"{object_id}.frame_id",
182+
None,
141183
descriptor=ParameterDescriptor(
142184
name="frame_id",
143185
type=ParameterType.PARAMETER_STRING,
@@ -147,8 +189,15 @@ def load_parameters(self) -> None:
147189
)
148190

149191
# Add the object to the list of objects
192+
filepath = (
193+
None
194+
if filename.value is None
195+
else path.join(assets_dir.value, filename.value)
196+
)
150197
self.objects[object_id] = CollisionMeshParams(
151-
filepath=path.join(assets_dir.value, filename.value),
198+
filepath=filepath,
199+
primitive_type=primitive_type.value,
200+
primitive_dims=primitive_dims.value,
152201
position=position.value,
153202
quat_xyzw=quat_xyzw.value,
154203
frame_id=frame_id.value,
@@ -176,13 +225,23 @@ def initialize_planning_scene(self) -> None:
176225
"""
177226
# Add each object to the planning scene
178227
for object_id, params in self.objects.items():
179-
self.moveit2.add_collision_mesh(
180-
id=object_id,
181-
filepath=params.filepath,
182-
position=params.position,
183-
quat_xyzw=params.quat_xyzw,
184-
frame_id=params.frame_id,
185-
)
228+
if params.primitive_type is None:
229+
self.moveit2.add_collision_mesh(
230+
id=object_id,
231+
filepath=params.filepath,
232+
position=params.position,
233+
quat_xyzw=params.quat_xyzw,
234+
frame_id=params.frame_id,
235+
)
236+
else:
237+
self.moveit2.add_collision_primitive(
238+
id=object_id,
239+
prim_type=params.primitive_type,
240+
dims=params.primitive_dims,
241+
position=params.position,
242+
quat_xyzw=params.quat_xyzw,
243+
frame_id=params.frame_id,
244+
)
186245

187246

188247
def main(args: List = None) -> None:

0 commit comments

Comments
 (0)