@@ -254,6 +254,7 @@ bool JointTrajectoryController<SegmentImpl, HardwareInterface>::init(HardwareInt
254
254
// Initialize members
255
255
joints_.resize (n_joints);
256
256
angle_wraparound_.resize (n_joints);
257
+ is_linear_.resize (n_joints);
257
258
for (unsigned int i = 0 ; i < n_joints; ++i)
258
259
{
259
260
// Joint handle
@@ -267,13 +268,16 @@ bool JointTrajectoryController<SegmentImpl, HardwareInterface>::init(HardwareInt
267
268
268
269
// Whether a joint is continuous (ie. has angle wraparound)
269
270
angle_wraparound_[i] = urdf_joints[i]->type == urdf::Joint::CONTINUOUS;
271
+ is_linear_[i] = urdf_joints[i]->type == urdf::Joint::PRISMATIC;
270
272
const std::string not_if = angle_wraparound_[i] ? " " : " non-" ;
273
+ const std::string linear = is_linear_[i] ? " linear " : " " ;
271
274
272
- ROS_DEBUG_STREAM_NAMED (name_, " Found " << not_if << " continuous joint '" << joint_names_[i] << " ' in '" <<
275
+ ROS_DEBUG_STREAM_NAMED (name_, " Found " << not_if << " continuous " << linear << " joint '" << joint_names_[i] << " ' in '" <<
273
276
this ->getHardwareInterfaceType () << " '." );
274
277
}
275
278
276
279
assert (joints_.size () == angle_wraparound_.size ());
280
+ assert (joints_.size () == is_linear_.size ());
277
281
ROS_DEBUG_STREAM_NAMED (name_, " Initialized controller '" << name_ << " ' with:" <<
278
282
" \n - Number of joints: " << getNumberOfJoints () <<
279
283
" \n - Hardware interface type: '" << this ->getHardwareInterfaceType () << " '" <<
@@ -770,7 +774,14 @@ updateStates(const ros::Time& sample_time, const Trajectory* const traj)
770
774
desired_state_.velocity [joint_index] = desired_joint_state_.velocity [0 ];
771
775
desired_state_.acceleration [joint_index] = desired_joint_state_.acceleration [0 ]; ;
772
776
773
- state_joint_error_.position [0 ] = angles::shortest_angular_distance (current_state_.position [joint_index],desired_joint_state_.position [0 ]);
777
+ if (is_linear_[joint_index])
778
+ {
779
+ state_joint_error_.position [0 ] = desired_joint_state_.position [0 ] - current_state_.position [joint_index];
780
+ }
781
+ else
782
+ {
783
+ state_joint_error_.position [0 ] = angles::shortest_angular_distance (current_state_.position [joint_index],desired_joint_state_.position [0 ]);
784
+ }
774
785
state_joint_error_.velocity [0 ] = desired_joint_state_.velocity [0 ] - current_state_.velocity [joint_index];
775
786
state_joint_error_.acceleration [0 ] = 0.0 ;
776
787
0 commit comments