55geometry_msgs::msg::Pose
poseToCpp(
const py::object& pose)
58 geometry_msgs::msg::Pose pose_cpp;
59 pose_cpp.orientation.w = pose.attr(
"orientation").attr(
"w").cast<
double>();
60 pose_cpp.orientation.x = pose.attr(
"orientation").attr(
"x").cast<
double>();
61 pose_cpp.orientation.y = pose.attr(
"orientation").attr(
"y").cast<
double>();
62 pose_cpp.orientation.z = pose.attr(
"orientation").attr(
"z").cast<
double>();
63 pose_cpp.position.x = pose.attr(
"position").attr(
"x").cast<
double>();
64 pose_cpp.position.y = pose.attr(
"position").attr(
"y").cast<
double>();
65 pose_cpp.position.z = pose.attr(
"position").attr(
"z").cast<
double>();
86geometry_msgs::msg::Point
pointToCpp(
const py::object& point)
89 geometry_msgs::msg::Point point_cpp;
90 point_cpp.x = point.attr(
"x").cast<
double>();
91 point_cpp.y = point.attr(
"y").cast<
double>();
92 point_cpp.z = point.attr(
"z").cast<
double>();
100 geometry_msgs::msg::Vector3 vector3_cpp;
101 vector3_cpp.x = vector3.attr(
"x").cast<
double>();
102 vector3_cpp.y = vector3.attr(
"y").cast<
double>();
103 vector3_cpp.z = vector3.attr(
"z").cast<
double>();
111 geometry_msgs::msg::Quaternion quaternion_cpp;
112 quaternion_cpp.w = quaternion.attr(
"w").cast<
double>();
113 quaternion_cpp.x = quaternion.attr(
"x").cast<
double>();
114 quaternion_cpp.y = quaternion.attr(
"y").cast<
double>();
115 quaternion_cpp.z = quaternion.attr(
"z").cast<
double>();
117 return quaternion_cpp;
123 shape_msgs::msg::SolidPrimitive primitive_cpp;
124 primitive_cpp.type = primitive.attr(
"type").cast<
int>();
125 for (
auto& dimension : primitive.attr(
"dimensions"))
127 primitive_cpp.dimensions.push_back(py::reinterpret_borrow<py::object>(dimension).cast<
double>());
130 return primitive_cpp;
136 shape_msgs::msg::MeshTriangle mesh_triangle_cpp;
137 mesh_triangle_cpp.vertex_indices[0] = mesh_triangle.attr(
"vertex_indices").attr(
"__getitem__")(0).cast<int>();
138 mesh_triangle_cpp.vertex_indices[1] = mesh_triangle.attr(
"vertex_indices").attr(
"__getitem__")(1).cast<int>();
139 mesh_triangle_cpp.vertex_indices[2] = mesh_triangle.attr(
"vertex_indices").attr(
"__getitem__")(2).cast<int>();
141 return mesh_triangle_cpp;
147 shape_msgs::msg::Mesh mesh_cpp;
148 mesh_cpp.vertices.resize(mesh.attr(
"vertices").attr(
"__len__")().cast<
int>());
149 for (
const auto& vertex : mesh.attr(
"vertices"))
151 mesh_cpp.vertices.push_back(
pointToCpp(py::reinterpret_borrow<py::object>(vertex)));
153 mesh_cpp.triangles.resize(mesh.attr(
"triangles").attr(
"__len__")().cast<int>());
154 for (
const auto& triangle : mesh.attr(
"triangles"))
156 mesh_cpp.triangles.push_back(
meshTriangleToCpp(py::reinterpret_borrow<py::object>(triangle)));
165 moveit_msgs::msg::BoundingVolume bounding_volume_cpp;
168 for (
const auto& primitive : bounding_volume.attr(
"primitives"))
170 bounding_volume_cpp.primitives.push_back(
solidPrimitiveToCpp(py::reinterpret_borrow<py::object>(primitive)));
174 for (
const auto& primitive_pose : bounding_volume.attr(
"primitive_poses"))
176 bounding_volume_cpp.primitive_poses.push_back(
poseToCpp(py::reinterpret_borrow<py::object>(primitive_pose)));
180 for (
const auto& mesh : bounding_volume.attr(
"meshes"))
182 bounding_volume_cpp.meshes.push_back(
meshToCpp(py::reinterpret_borrow<py::object>(mesh)));
186 for (
const auto& mesh_poses : bounding_volume.attr(
"mesh_poses"))
188 bounding_volume_cpp.mesh_poses.push_back(
poseToCpp(py::reinterpret_borrow<py::object>(mesh_poses)));
191 return bounding_volume_cpp;
197 moveit_msgs::msg::JointConstraint joint_constraint_cpp;
198 joint_constraint_cpp.joint_name = joint_constraint.attr(
"joint_name").cast<std::string>();
199 joint_constraint_cpp.position = joint_constraint.attr(
"position").cast<
double>();
200 joint_constraint_cpp.tolerance_above = joint_constraint.attr(
"tolerance_above").cast<
double>();
201 joint_constraint_cpp.tolerance_below = joint_constraint.attr(
"tolerance_below").cast<
double>();
202 joint_constraint_cpp.weight = joint_constraint.attr(
"weight").cast<
double>();
204 return joint_constraint_cpp;
210 moveit_msgs::msg::PositionConstraint position_constraint_cpp;
211 position_constraint_cpp.header.frame_id = position_constraint.attr(
"header").attr(
"frame_id").cast<std::string>();
212 position_constraint_cpp.link_name = position_constraint.attr(
"link_name").cast<std::string>();
213 position_constraint_cpp.target_point_offset =
vector3ToCpp(position_constraint.attr(
"target_point_offset"));
214 position_constraint_cpp.constraint_region =
boundingVolumeToCpp(position_constraint.attr(
"constraint_region"));
215 position_constraint_cpp.weight = position_constraint.attr(
"weight").cast<
double>();
217 return position_constraint_cpp;
223 moveit_msgs::msg::OrientationConstraint orientation_constraint_cpp;
224 orientation_constraint_cpp.header.frame_id =
225 orientation_constraint.attr(
"header").attr(
"frame_id").cast<std::string>();
226 orientation_constraint_cpp.link_name = orientation_constraint.attr(
"link_name").cast<std::string>();
227 orientation_constraint_cpp.orientation =
quaternionToCpp(orientation_constraint.attr(
"target_quaternion"));
228 orientation_constraint_cpp.absolute_x_axis_tolerance =
229 orientation_constraint.attr(
"absolute_x_axis_tolerance").cast<
double>();
230 orientation_constraint_cpp.absolute_y_axis_tolerance =
231 orientation_constraint.attr(
"absolute_y_axis_tolerance").cast<
double>();
232 orientation_constraint_cpp.absolute_z_axis_tolerance =
233 orientation_constraint.attr(
"absolute_z_axis_tolerance").cast<
double>();
234 orientation_constraint_cpp.parameterization = orientation_constraint.attr(
"parameterization").cast<
int>();
235 orientation_constraint_cpp.weight = orientation_constraint.attr(
"weight").cast<
double>();
237 return orientation_constraint_cpp;
243 moveit_msgs::msg::VisibilityConstraint visibility_constraint_cpp;
244 visibility_constraint_cpp.target_radius = visibility_constraint.attr(
"target_radius").cast<
double>();
245 visibility_constraint_cpp.target_pose =
poseStampedToCpp(visibility_constraint.attr(
"target_pose"));
246 visibility_constraint_cpp.cone_sides = visibility_constraint.attr(
"cone_sides").cast<
int>();
247 visibility_constraint_cpp.sensor_pose =
poseStampedToCpp(visibility_constraint.attr(
"sensor_pose"));
248 visibility_constraint_cpp.max_view_angle = visibility_constraint.attr(
"max_view_angle").cast<
double>();
249 visibility_constraint_cpp.max_range_angle = visibility_constraint.attr(
"max_range_angle").cast<
double>();
250 visibility_constraint_cpp.sensor_view_direction = visibility_constraint.attr(
"sensor_view_direction").cast<
int>();
251 visibility_constraint_cpp.weight = visibility_constraint.attr(
"weight").cast<
double>();
253 return visibility_constraint_cpp;
259 moveit_msgs::msg::CollisionObject collision_object_cpp;
262 collision_object_cpp.header.frame_id = collision_object.attr(
"header").attr(
"frame_id").cast<std::string>();
265 collision_object_cpp.pose =
poseToCpp(collision_object.attr(
"pose"));
268 collision_object_cpp.id = collision_object.attr(
"id").cast<std::string>();
271 collision_object_cpp.type.key = collision_object.attr(
"type").attr(
"key").cast<std::string>();
272 collision_object_cpp.type.db = collision_object.attr(
"type").attr(
"db").cast<std::string>();
275 for (
const auto& primitive : collision_object.attr(
"primitives"))
278 collision_object_cpp.primitives.push_back(primitive_cpp);
282 for (
const auto& primitive_pose : collision_object.attr(
"primitive_poses"))
284 auto primitive_pose_cpp =
poseToCpp(py::reinterpret_borrow<py::object>(primitive_pose));
285 collision_object_cpp.primitive_poses.push_back(primitive_pose_cpp);
289 for (
const auto& mesh : collision_object.attr(
"meshes"))
292 auto mesh_cpp =
meshToCpp(py::reinterpret_borrow<py::object>(mesh));
293 collision_object_cpp.meshes.push_back(mesh_cpp);
297 for (
const auto& mesh_pose : collision_object.attr(
"mesh_poses"))
299 auto mesh_pose_cpp =
poseToCpp(py::reinterpret_borrow<py::object>(mesh_pose));
300 collision_object_cpp.mesh_poses.push_back(mesh_pose_cpp);
304 collision_object_cpp.operation = collision_object.attr(
"operation").cast<
char>();
306 return collision_object_cpp;
312 moveit_msgs::msg::Constraints constraints_cpp;
315 for (
const auto& joint_constraint : constraints.attr(
"joint_constraints"))
317 auto joint_constraint_cpp =
jointConstraintToCpp(py::reinterpret_borrow<py::object>(joint_constraint));
318 constraints_cpp.joint_constraints.push_back(joint_constraint_cpp);
322 for (
const auto& position_constraint : constraints.attr(
"position_constraints"))
324 auto position_constraint_cpp =
positionConstraintToCpp(py::reinterpret_borrow<py::object>(position_constraint));
325 constraints_cpp.position_constraints.push_back(position_constraint_cpp);
329 for (
const auto& orientation_constraint : constraints.attr(
"orientation_constraints"))
331 auto orientation_constraint_cpp =
333 constraints_cpp.orientation_constraints.push_back(orientation_constraint_cpp);
337 for (
const auto& visibility_constraint : constraints.attr(
"visibility_constraints"))
339 auto visibility_constraint_cpp =
341 constraints_cpp.visibility_constraints.push_back(visibility_constraint_cpp);
344 return constraints_cpp;