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 function to Introspection class to retrieve all solutions #510

Closed
wants to merge 1 commit into from

Conversation

Abishalini
Copy link
Contributor

Currently, the way to retrieve solutions is to use the get_solution service, where you can send one solution ID as a request and get the corresponding solution.

In this PR, I have added a function to get the entire solution ID and solution map.
This would be useful for another introspection tool we are building at PickNik.

Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

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

I deliberatively decided against providing a (ROS) accessor to all solutions, because the amount of data to transfer is rather big for complex tasks.
In the interactive introspection with rviz, users need to select individual solutions anyway, such that the communication overhead can be limited to a single solution.

Could you motivate, why such a function is needed?
You also didn't expose the function as a ROS service yet. How do you plan to use it?

@Abishalini
Copy link
Contributor Author

I wanted to create a database of all the MTC tasks so that we can go back to analyze previous solutions. So I need to access all the solutions in one go. I am not sure if I should instead call the get_solution service multiple time to get all the solutions. Also, the get_solution service is unique for each task. I think the task ID is appended to the service's name. In this case, I cannot use the service to get solutions for older tasks since the services get_solution_task_id are destroyed when a newer task is run.

Since you mentioned the solutions data can be large, I will analyze the performance in a bit.

I don't plan to use ROS service to get the task information and solutions. This is how I'm using this currently

// Get task description
moveit_task_constructor_msgs::msg::TaskDescription task_description;
task.introspection().fillTaskDescription(task_description);

// Get task statistics
moveit_task_constructor_msgs::msg::TaskStatistics task_statistics;
task.introspection().fillTaskStatistics(task_statistics);

// Get solution id and solutions map
const auto solutions_map = task.introspection().getAllSolutions();

@rhaschke
Copy link
Contributor

If you don't want to use a ROS API to access solutions, why do you need the function at all? You can simply access all solutions directly:
https://github.com/ros-planning/moveit_task_constructor/blob/a90557279ca306fc30d39ec463af401022314b17/core/include/moveit/task_constructor/task.h#L139

I cannot use the service to get solutions for older tasks since the services get_solution_task_id are destroyed when a newer task is run.

Solutions are erased when you reset the task. If you don't do that, you can still access them ;-)

@Abishalini
Copy link
Contributor Author

Please correct me if I'm wrong. It looks like calling solutions() would return the successful solutions of the overall task.
How would I access the successful and failed solutions of each stage?

@rhaschke
Copy link
Contributor

How would I access the successful and failed solutions of each stage?

Just use the method failures():
https://github.com/ros-planning/moveit_task_constructor/blob/a90557279ca306fc30d39ec463af401022314b17/core/include/moveit/task_constructor/task.h#L139-L140

Note, that each sub stage provides these methods as well (to access solutions/failures of a particular stage):
https://github.com/ros-planning/moveit_task_constructor/blob/a90557279ca306fc30d39ec463af401022314b17/core/include/moveit/task_constructor/stage.h#L227-L228

@Abishalini Abishalini closed this Jan 8, 2024
@Abishalini Abishalini deleted the pr-retreive-all-solutions branch January 8, 2024 21:03
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.

2 participants