ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

how to have the same ur5 trajectory on rviz and on real robotic arm

asked 2021-02-26 10:36:19 -0600

zahid990170 gravatar image

updated 2021-03-01 07:09:06 -0600


I want to save a trajectory found in MoveIt in a file, and then load the data from the file and execute the same trajectory. At certain times, we noticed that a certain trajectory found and played in rviz, took a different path when executed on the real robotic arm. Since, workspace of the robotic arm had some physical constraints in place, it was not possible to carry out the deviated trajectory execution. Hence, the robotic arm had to be emergency stopped using the red button on the panel. This question has several parts. The initial part of the question is as follows:

  • since the planners are random sampling based planners, it is possible that a different path may be found on the rviz simulator and later on the real robotic arm?
  • The first point in the trajectory (composed of joint angles), was all zeros i.e. [0,0,0,0,0,0]. It can be verified in the rviz simulator. The simulation starts and we see the robotic arm in the lying down position.
  • My understanding is that while the goal configuration / goal pose is the same in rviz simulator and on the real robotic arm, the start state is the current state. In rviz it is [0,0,0,0,0,0] whereas on the real robotic arm it is extracted from the joint angles of the current position of the robotic arm.
  • This means that inherently, the trajectories will be different when tested in rviz and when run on the real robotic arm because start state is different.

Is there a way to fix a start state in rviz that correspond to the initial pose of our robotic arm? will this guarantee that trajectories found on the simulator and the arm will be the same.

edit to the question

I am using move_group_interface and I use the relevant APIs to plan and execute simple goals (pose goal or a joint-space goal). I write a simple launch file which sort of replicates the functionality that comes within demo.launch. In this launch file, I invoke my motion planning node. In rviz, I see the trajectory followed by the ur5. At the startup, the arm appears lying down, and then it follows the path to the desired goal pose. Concerning the initial configuration was all zeros [0,0,0,0,0,0], I checked this, in my code.

std::vector<double> jointVals;
// a joint-space target
double refVals[] =  {-3.05938765, -1.2903219, 1.662077, -0.36599554, -1.484228, 3.14752677};
for (int j=0; j<6; j++) {
  success = (move_group.plan(my_plan) == moveit::planning_interface::MoveItErrorCode::SUCCESS);

I can retrieve the trajectory my_plan.trajectory_ and inspect the points. I will try setting a different start configuration, and check the results.

I will try to test this in a collision-free environments (no obstacles). I have not yet loaded (from a file) and executed any trajectories yet. But I can save the trajectory points. I have a follow ... (more)

edit retag flag offensive close merge delete


Please click the checkmark to accept the answer if your question is solved, so the post is out of the queue. Also, please formulate a question that can be answered instead of a general topic (i.e. "How to set start state in Rviz?" instead of "ur5 trajectory on rviz"). The site works better that way.

fvd gravatar image fvd  ( 2021-03-01 07:05:01 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-02-28 00:01:21 -0600

fvd gravatar image

updated 2021-02-28 00:01:50 -0600

Your question is confusing. Yes, you can set the start state for your planning request in Rviz (via the Start State: drop-down menu in the Planning tab of the MotionPlanning plugin which you are surely using inside Rviz) and in your code (e.g. setStartState or setStartStateToCurrentState in the move_group_interface. No, that does not guarantee that the same solution comes out of the random-sampling-based planner. But it seems that your real question is something else.

Some thoughts you might want to consider:

  • Loading a previously calculated trajectory and immediately executing it is unsafe if you don't know if your environment has changed, or you calculated with less constraints than the robot you want to execute the trajectory on. You should check that the trajectory is collision-free in your current scene, e.g. with the isPathValid function of the PlanningScene class.
  • Are you actually saving and loading trajectories, or only goals? How do you load and "play" the trajectory in rviz?
  • Did the trajectory contain all zeroes in the first point when you first calculated it?

Also, Rviz only visualizes, it does not simulate, so I assume by "rviz simulator" you mean the controllers and scene that MoveIt starts up via demo.launch.

edit flag offensive delete link more


thank you @fvd for your answer. I have edited my question to make it a bit more clear. Also, please refer to this question that is in connection with the above. thanks

zahid990170 gravatar image zahid990170  ( 2021-03-01 07:02:44 -0600 )edit

Question Tools



Asked: 2021-02-26 10:36:19 -0600

Seen: 129 times

Last updated: Mar 01 '21