ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
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 image NYs  ( 2018-01-03 08:28:22 -0500 )edit

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

pranavb104 gravatar image pranavb104  ( 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 image pranavb104  ( 2019-01-21 04:56:26 -0500 )edit

Is there a way to save the trajectory using RViz?

Diliban gravatar image Diliban  ( 2021-01-08 06:23:17 -0500 )edit

Question Tools

2 followers

Stats

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

Seen: 3,693 times

Last updated: Jan 04 '18