ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
You don't have to specify positions all the time, but make sure to resize the variables, Have a look at following implementation,
control_msgs::FollowJointTrajectoryGoal goal;
goal.trajectory.joint_names.push_back("shoulder_pan_joint");
goal.trajectory.joint_names.push_back("shoulder_lift_joint");
goal.trajectory.joint_names.push_back("elbow_joint");
goal.trajectory.joint_names.push_back("wrist_1_joint");
goal.trajectory.joint_names.push_back("wrist_2_joint");
goal.trajectory.joint_names.push_back("wrist_3_joint");
goal.trajectory.points.resize(1); // important
goal.trajectory.points[0].effort.resize(N_JOINT);
goal.trajectory.points[0].positions.resize(N_JOINT);
goal.trajectory.points[0].velocities.resize(N_JOINT);
goal.trajectory.points[0].accelerations.resize(N_JOINT);
for(size_t i = 0; i < N_JOINT; i++)
{
goal.trajectory.points[0].effort[i] = tau(i,0);
goal.trajectory.points[0].positions[i] = 0;
goal.trajectory.points[0].velocities[i] = 0;
goal.trajectory.points[0].accelerations[i] = 0;
}
goal.trajectory.points[0].time_from_start = ros::Duration(1.0);
goal.trajectory.header.frame_id = "base_Link";
goal.trajectory.header.stamp = ros::Time::now()+ ros::Duration(0.001);
traj_client_->sendGoalAndWait(goal, ros::Duration(0,0), ros::Duration(0,0));