Ask Your Question
1

How to save and replay a trajectory generated with moveit

asked 2017-09-20 23:14:26 -0500

ani gravatar image

updated 2017-09-20 23:16:59 -0500

Hi all,

I am using moveit's move_group_interface in C++ to generate a trajectory between two NamedTargets for Youbot. Everything works fine including visualization in RViz. However, on repeated execution, the trajectories look slightly different for the same set of targets. So, my question is: Is there any way one can save a trajectory so that it can be reused later on? I have tried saving the "plan.trajectory_", but it doesn't seem to work. Details of current setup is given below.

Robot: Youbot
Planner: OMPL/RRTkConfigDefault
Interface: moveit/move_group_interface in C++
Logic/Sequence Used:
1. Set Start State to Current State
2. Set a Named Target
3. Visualize the plan in Rviz
4. Execute the plan

Thanks

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2018-01-02 08:37:09 -0500

pk gravatar image

You can write a script to save the generated plan. When you command a target position in MoveIt!, you can access the trajectory using moveit::planning_interface::MoveGroup::Plan (API). You can save this trajectory as a YAML file and read it next time you are executing the motion, use this Plan for execution. Unfortunately, there is no available function which performs this action.

edit flag offensive delete link more

Comments

in case you're wondering how to save a yaml file https://stackoverflow.com/questions/1...

NYs gravatar imageNYs ( 2018-01-03 08:28:22 -0500 )edit

Is there a reference for dumping yaml in c++?

pranavb104 gravatar imagepranavb104 ( 2019-01-21 04:56:18 -0500 )edit
1

answered 2018-01-04 07:59:57 -0500

NYs gravatar image

updated 2018-01-04 08:01:05 -0500

Got this working for python on UR5 in Gazebo

import yaml
import os

plan = group.plan()

file_path = os.path.join(os.path.expanduser('~'), 'saved_trajectories', 'plan.yaml')
with open(file_path, 'w') as file_save:
    yaml.dump(plan, file_save, default_flow_style=True)

with open(file_path, 'r') as file_open:
    loaded_plan = yaml.load(file_open)

group.execute(loaded_plan)
edit flag offensive delete link more

Comments

Is there a reference for dumping yaml in c++?

pranavb104 gravatar imagepranavb104 ( 2019-01-21 04:56:26 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2017-09-20 23:14:26 -0500

Seen: 1,063 times

Last updated: Jan 04 '18