-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Planning Scene transcription V2 #31
Changes from 4 commits
0b10366
808ed9a
996476a
9506420
204b105
1a24acf
ecd3376
a565092
77d6f01
34598ae
59fa46b
f10ff7a
c891ed9
c215249
418a107
b4b02e8
eedf50d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
services: | ||
moveit: | ||
moveit_drake: | ||
image: moveit_drake:latest | ||
container_name: moveit_drake | ||
build: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,6 +228,11 @@ void KTOptPlanningContext::setRobotDescription(std::string robot_description) | |
|
||
void KTOptPlanningContext::transcribePlanningScene(const planning_scene::PlanningScene& planning_scene) | ||
{ | ||
// NOTE: Information tree, to be deleted after implementation | ||
// Planning scene -> World (getWorld, WorldConstPtr) | ||
// objectIds -> World.getObjectIds() | ||
// Object -> World.getObject(objectIds) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete? |
||
// | ||
try | ||
{ | ||
auto world = planning_scene.getWorld(); | ||
|
@@ -248,29 +253,84 @@ void KTOptPlanningContext::transcribePlanningScene(const planning_scene::Plannin | |
} | ||
if (object == OCTOMAP_NS) | ||
{ | ||
RCLCPP_ERROR(getLogger(), "skipping octomap for now ..."); | ||
RCLCPP_INFO(getLogger(), "skipping octomap for now ..."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make this a warning and say explicitly: Octomap parsing not supported at the moment |
||
continue; | ||
} | ||
RCLCPP_INFO(getLogger(), "iterating inside collision object's shapes"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove before merging |
||
for (const auto& shape : collision_object->shapes_) | ||
{ | ||
RCLCPP_ERROR(getLogger(), "iterating inside collision object's shapes"); | ||
const auto& pose = collision_object->shape_poses_[0]; | ||
const auto& shape_type = collision_object->shapes_[0]->type; | ||
RCLCPP_INFO(getLogger(), "Shape type: %d, object id: %s, shape: %s", shape_type, object, shape); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove before merging, or make into debug? Might still be useful, long as it doesn't spam by default |
||
|
||
switch (shape_type){ | ||
case shapes::ShapeType::BOX: { | ||
|
||
const auto objectptr = std::dynamic_pointer_cast<const shapes::Box>(shape); | ||
RCLCPP_INFO(getLogger(), "Box, size: %f", objectptr->size[0]); // shape.size | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as other comment. In general, should clean up what to print. So I'll stop commenting the same thing |
||
const SourceId box_source_id = scene_graph.RegisterSource("template_box"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name should probably not be "template_SHAPE" but rather the actual entity name from the planning scene? |
||
const GeometryId box_geom_id = scene_graph.RegisterAnchoredGeometry( | ||
box_source_id, | ||
std::make_unique<GeometryInstance>( | ||
RigidTransformd(pose), | ||
std::make_unique<Box>( | ||
objectptr->size[0], | ||
objectptr->size[0], | ||
objectptr->size[0]), | ||
"box")); | ||
|
||
// add illustration, proximity, perception properties | ||
scene_graph.AssignRole(box_source_id, box_geom_id, IllustrationProperties()); | ||
scene_graph.AssignRole(box_source_id, box_geom_id, ProximityProperties()); | ||
scene_graph.AssignRole(box_source_id, box_geom_id, PerceptionProperties()); | ||
break; | ||
} | ||
case shapes::ShapeType::UNKNOWN_SHAPE: { | ||
RCLCPP_INFO(getLogger(), "Unknown shape, ignoring in scene graph"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this should be a warning instead |
||
break; | ||
} | ||
case shapes::ShapeType::SPHERE:{ | ||
const auto objectptr = std::dynamic_pointer_cast<const shapes::Sphere>(shape); | ||
const SourceId box_source_id = scene_graph.RegisterSource("template_sphere"); | ||
const GeometryId box_geom_id = scene_graph.RegisterAnchoredGeometry( | ||
box_source_id, | ||
std::make_unique<GeometryInstance>( | ||
RigidTransformd(pose), | ||
std::make_unique<Sphere>( | ||
objectptr->radius), "sphere")); | ||
RCLCPP_INFO(getLogger(), "Sphere"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove |
||
|
||
// add illustration, proximity, perception properties | ||
scene_graph.AssignRole(box_source_id, box_geom_id, IllustrationProperties()); | ||
scene_graph.AssignRole(box_source_id, box_geom_id, ProximityProperties()); | ||
scene_graph.AssignRole(box_source_id, box_geom_id, PerceptionProperties()); | ||
break; | ||
} | ||
case shapes::ShapeType::CYLINDER:{ | ||
const auto objectptr = std::dynamic_pointer_cast<const shapes::Cylinder>(shape); | ||
const SourceId box_source_id = scene_graph.RegisterSource("template_cylinder"); | ||
const GeometryId box_geom_id = scene_graph.RegisterAnchoredGeometry( | ||
box_source_id, | ||
std::make_unique<GeometryInstance>( | ||
RigidTransformd(pose), | ||
std::make_unique<Cylinder>( | ||
objectptr->radius, objectptr->length), "cylinder")); | ||
RCLCPP_INFO(getLogger(), "Cylinder"); | ||
|
||
// add illustration, proximity, perception properties | ||
scene_graph.AssignRole(box_source_id, box_geom_id, IllustrationProperties()); | ||
scene_graph.AssignRole(box_source_id, box_geom_id, ProximityProperties()); | ||
scene_graph.AssignRole(box_source_id, box_geom_id, PerceptionProperties()); | ||
RCLCPP_INFO(getLogger(), "Cylinder"); | ||
break; | ||
} | ||
case shapes::ShapeType::CONE:{ | ||
RCLCPP_WARN(getLogger(), "Cone not supported in drake"); | ||
break; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these all possible shape types? If not, you should add a default like this at the end of the switch statement
|
||
} | ||
|
||
// Creates a box geometry and anchors it to the world origin. Better | ||
// approach is to create a ground object, anchor that, and then anchor | ||
// every non-moving entity to the ground plane | ||
// TODO: Create and anchor ground entity | ||
Vector3d p(0.3, -0.3, 0.5); | ||
const SourceId box_source_id = scene_graph.RegisterSource("box1"); | ||
const GeometryId box_geom_id = scene_graph.RegisterAnchoredGeometry( | ||
box_source_id, std::make_unique<GeometryInstance>( | ||
RigidTransformd(p), std::make_unique<Box>(0.15, 0.15, 0.15), | ||
"box")); // hard coded for now because I know box dimensions and pose, from | ||
|
||
// add illustration, proximity, perception properties | ||
scene_graph.AssignRole(box_source_id, box_geom_id, IllustrationProperties()); | ||
scene_graph.AssignRole(box_source_id, box_geom_id, ProximityProperties()); | ||
scene_graph.AssignRole(box_source_id, box_geom_id, PerceptionProperties()); | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to Sebastian's comment: Why do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this for linting and LSP support, so that vim has access to the symbols for functionality like Goto definition/declaration etc.