how to have the same ur5 trajectory on rviz and on real robotic arm
Hi,
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 therviz
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++) {
jointVals.push_back(refVals[j]);
}
move_group.setJointValueTarget(jointVals);
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 ...
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.