Dear community,
I planned a path by setting joint states which i found by reading the "joint state publisher" UI from RViz. Now when i plan the path my robot does some weird rotations. This is shown in the video i added. Can i add maximum allowed rotations of a joint somewhere?
When i set a start and goal state in rviz itself and not in my C++ program the path is pretty good.
How can i optimize the path it finds?
A second question is: how can i visualize the attached object during movement and the resulting position? The shape is of type shape_msgs::SolidPrimitive (BOX).
Part of my code:
std::vector<double> group_variable_values1;
group.getCurrentState()->copyJointGroupPositions(group.getCurrentState()->getRobotModel()->getJointModelGroup(group.getName()), group_variable_values1);
group_variable_values1[0] = 0;
group_variable_values1[1] = -0.42;
group_variable_values1[2] = -1.36;
group_variable_values1[3] = 3.16;
group_variable_values1[4] = 1.32;
group_variable_values1[5] = 1.63;
group.setJointValueTarget(group_variable_values1);
success = group.plan(my_plan);
ROS_INFO("Visualizing plan 1 (joint space goal) %s",success?"":"FAILED");
/* Sleep to give Rviz time to visualize the plan. */
sleep(5.0);
group.execute(my_plan);
/* set the last position as the new start position
robot_state::RobotState start_state(*group.getCurrentState());
const robot_state::JointModelGroup *joint_model_group =
start_state.getJointModelGroup(group.getName());
start_state.setJointGroupPositions(joint_model_group, group_variable_values1);
group.setStartState(start_state);
/* Now, let's attach the collision object to the robot. */
ROS_INFO("Attach the object to the robot");
group.attachObject("box2");
/* Sleep to give Rviz time to show the object attached (different color). */
sleep(4.0);
// Planning to a joint-space goal
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//
// Second position
// First get the current set of joint values for the group.
std::vector<double> group_variable_values2;
group.getCurrentState()->copyJointGroupPositions(group.getCurrentState()->getRobotModel()->getJointModelGroup(group.getName()), group_variable_values2);
/* Now, let's modify one of the joints, plan to the new joint space goal and visualize the plan.*/
group_variable_values2[0] = -1.54;
group_variable_values2[1] = -0.46;
group_variable_values2[2] = -1.97;
group_variable_values2[3] = -3.14;
group_variable_values2[4] = 0.73;
group_variable_values2[5] = -1.54;
group.setJointValueTarget(group_variable_values2);
success = group.plan(my_plan);
ROS_INFO("Visualizing plan 1 (joint space goal) %s",success?"":"FAILED");
/* Sleep to give Rviz time to visualize the plan. */
sleep(5.0);
group.execute(my_plan);
/* Now, let's detach the collision object to the robot. */
ROS_INFO("Detach the object from the robot");
group.detachObject("box2");
/* Sleep to give Rviz time to show the object detached. */
sleep(4.0);
Kind regards
Joris