Skip to content
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

Merged
merged 17 commits into from
Aug 20, 2024
Merged

Conversation

kamiradi
Copy link
Member

@kamiradi kamiradi commented Aug 6, 2024

@sea-bass @sjahr. This is at a reviewable stage. The planning scene transcription contains the following

  • Transcribes Box, Sphere, Cylinder primitives directly from the planning scene object (tested on box, yet to test on sphere and cylinder)
  • I tried going down the octomap road, but I could not see an obvious way of transcribing it in drake. Any thoughts?

I'll do the pre-commit stuff after any other changes you guys have in mind

Copy link
Contributor

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good!

I think all I see is cleaning up some of the debug prints and the hard-coded names -- ensure the planning scene object names match those specified here? But maybe I am misunderstanding how the Drake scene graph works.

.docker/Dockerfile Show resolved Hide resolved
continue;
}
RCLCPP_INFO(getLogger(), "iterating inside collision object's shapes");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove before merging

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);
Copy link
Contributor

Choose a reason for hiding this comment

The 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

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
Copy link
Contributor

Choose a reason for hiding this comment

The 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 auto objectptr = std::dynamic_pointer_cast<const shapes::Box>(shape);
RCLCPP_INFO(getLogger(), "Box, size: %f", objectptr->size[0]); // shape.size
const SourceId box_source_id = scene_graph.RegisterSource("template_box");
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

break;
}
case shapes::ShapeType::UNKNOWN_SHAPE: {
RCLCPP_INFO(getLogger(), "Unknown shape, ignoring in scene graph");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be a warning instead

Copy link
Contributor

@sjahr sjahr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to run pre-commit run -a between the iterations on the code. It makes it also easier to read and review

@@ -26,6 +26,7 @@ RUN apt update && \
apt install -y \
build-essential \
clang-format-14 \
clangd-12 \
Copy link
Contributor

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?

Copy link
Member Author

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.

// NOTE: Information tree, to be deleted after implementation
// Planning scene -> World (getWorld, WorldConstPtr)
// objectIds -> World.getObjectIds()
// Object -> World.getObject(objectIds)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete?

@@ -248,29 +253,83 @@ 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 ...");
Copy link
Contributor

Choose a reason for hiding this comment

The 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

RigidTransformd(pose),
std::make_unique<Sphere>(
objectptr->radius), object));
RCLCPP_INFO(getLogger(), "Sphere");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

@kamiradi
Copy link
Member Author

kamiradi commented Aug 18, 2024

@sea-bass @sjahr So I may have celebrated to soon,
drake_scene_graph_planning_scene

There seems to be some thing I'm missing when it comes to reading the poses of the objects within planning scene into the scene_graph. Is there a transformation I'm missing between the robot and the world. As far as the scene_graph is concerned, I make the robot spawn at world origin. There could be an initial transformation that I am missing?

@sea-bass
Copy link
Contributor

Is there a transformation I'm missing between the robot and the world. As far as the scene_graph is concerned, I make the robot spawn at world origin. There could be an initial transformation that I am missing?

You could check the TF widget in RViz to see if there is something amiss there? But as far as world-robot transform is concerned, this should anyways come from the URDF and I would be surprised if this was it.

As another thing to look form maybe the scene objects are expressed with some other transform relative to world? @sjahr would know this better.

@sea-bass
Copy link
Contributor

Actually from the screenshot it just seems like no transforms at all are being applied to the boxes in the Drake scene graph. Everything is at the origin with identity transform, far as I can tell?

@kamiradi
Copy link
Member Author

I think the poses of individual "boxes" (four in this case) w.r.t the collision object frame of reference may be correct. I think there is some global transformation that is missing here. If that makes sense?

@kamiradi
Copy link
Member Author

Is there a transformation I'm missing between the robot and the world. As far as the scene_graph is concerned, I make the robot spawn at world origin. There could be an initial transformation that I am missing?

You could check the TF widget in RViz to see if there is something amiss there? But as far as world-robot transform is concerned, this should anyways come from the URDF and I would be surprised if this was it.

As another thing to look form maybe the scene objects are expressed with some other transform relative to world? @sjahr would know this better.

Yup I was thinking that it could be the second reason. Maybe somewhere in the planning scene there is object level pose as well?

@sjahr
Copy link
Contributor

sjahr commented Aug 19, 2024

Is there a transformation I'm missing between the robot and the world. As far as the scene_graph is concerned, I make the robot spawn at world origin. There could be an initial transformation that I am missing?

You could check the TF widget in RViz to see if there is something amiss there? But as far as world-robot transform is concerned, this should anyways come from the URDF and I would be surprised if this was it.

As another thing to look form maybe the scene objects are expressed with some other transform relative to world? @sjahr would know this better.

Not sure about that because it works with the MoveIt planning scene, so I guess all transform should be known. Does the function you added fix the issue @kamiradi ?

@kamiradi
Copy link
Member Author

The function I added, changes Moveit/ROS coordinate system to Drake. I thought this would, but it didn't. I'll try printing the positions and debugging.

@kamiradi
Copy link
Member Author

All right good news, the pose object coming in from the planning scene itself has pose.x, y, z = 0.0. Can you point me towards where in moveit's planning scene the object markers are being set. Because in RViZ it visualises it correctly, so maybe I can use whichever pose to do the same here?

@kamiradi
Copy link
Member Author

kamiradi commented Aug 20, 2024

drake_scene_plan2
drake_scene_plan

Ok, solved! There was indeed an object pose that I was missing.

@kamiradi kamiradi requested review from sjahr and sea-bass August 20, 2024 07:54
@kamiradi kamiradi marked this pull request as ready for review August 20, 2024 07:57
Copy link
Contributor

@sjahr sjahr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I'll test it before our meeting and I have some small clean-up comments and then this is good to go

@@ -248,33 +249,113 @@ void KTOptPlanningContext::transcribePlanningScene(const planning_scene::Plannin
}
if (object == OCTOMAP_NS)
{
RCLCPP_ERROR(getLogger(), "skipping octomap for now ...");
RCLCPP_INFO(getLogger(), "Octomap not supported for now ... ");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RCLCPP_INFO(getLogger(), "Octomap not supported for now ... ");
RCLCPP_WARN(getLogger(), "Octomap not supported for now ... ");

{
RCLCPP_WARN(getLogger(), "Cone not supported in drake");
break;
}
Copy link
Contributor

Choose a reason for hiding this comment

The 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

default:
{
  RCLCPP_WARN(getLogger(), "Shape TYPE conversation to drake is not implemented");
}

}
}
}

RigidTransformd KTOptPlanningContext::convertToDrakeFrame(const Eigen::Affine3d& ros_pose)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the whole function since it is not needed?

README.md Outdated
Comment on lines 63 to 66
Tips for when inside the container

# Can be added to the entrypoint
git config --global --add safe.directory /root/workspace/src/moveit_drake/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I already added this to the entrypoint!

@@ -160,7 +160,7 @@ void KTOptPlanningContext::solve(planning_interface::MotionPlanResponse& res)
visualizer_->ForcedPublish(vis_context);

// Without these sleeps, the visualizer won't give you time to load your browser
std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<int>(params_.trajectory_time_step * 1000.0)));
std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<int>(params_.trajectory_time_step * 10000.0)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you wanting to merge with this?

I had an idea which I could try -- basically have the motion planning terminate but starting the visualization separately in a thread so Meshcat doesn't die instantly, but also doesn't hold up the actual planning?

Not for this PR, but at least the delay should be reduced

@@ -228,6 +228,7 @@ void KTOptPlanningContext::setRobotDescription(std::string robot_description)

void KTOptPlanningContext::transcribePlanningScene(const planning_scene::PlanningScene& planning_scene)
{
// Transcribed the planning scene into a drake scene graph
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Transcribed the planning scene into a drake scene graph
// Transcribe the planning scene into a drake scene graph

Copy link
Contributor

@sjahr sjahr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge once SebC's comments are addressed 😄

@sjahr sjahr merged commit c2ff3b1 into moveit:main Aug 20, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants