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

Add parameter default_planning_scene to load planning scene geometry on startup #2949

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion moveit_ros/move_group/src/move_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,26 @@ int main(int argc, char** argv)
const auto moveit_cpp = std::make_shared<moveit_cpp::MoveItCpp>(nh, moveit_cpp_options);
const auto planning_scene_monitor = moveit_cpp->getPlanningSceneMonitorNonConst();

if (planning_scene_monitor->getPlanningScene())
if (auto ps = planning_scene_monitor->getPlanningScene())
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that ps is never used, would make sense to revert this change?

{
if (nh->has_parameter("default_planning_scene"))
Copy link
Contributor

Choose a reason for hiding this comment

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

I am a bit concerned about tying this to only the existence of the parameter. How about checking whether or not the parameter is set.

const auto default_planning_scene_file = std::string();
nh->get_parameter_or("default_planning_scene", default_planning_scene_file, std::string());
// Maybe add function to validate the string pattern if it actually representing  path
if(validateFilePath(default_planning_scene_file))
{
...
}

{
std::string path = nh->get_parameter("default_planning_scene").as_string();
std::fstream file_stream;
file_stream.open(path, std::fstream::in);
planning_scene_monitor::LockedPlanningSceneRW locked_ps(planning_scene_monitor);
if (!file_stream.is_open() || !locked_ps->loadGeometryFromStream(file_stream))
{
RCLCPP_ERROR(nh->get_logger(), std::string("Failed to load the planning scene geometry from the file specified "
"by the `default_planning_scene` parameter. The "
"`default_planning_scene` parameter was set to ")
.append(path)
.append(".")
.c_str());

return 0;
}
}
bool debug = false;
for (int i = 1; i < argc; ++i)
{
Expand Down
Loading