@@ -116,27 +116,36 @@ class DebugEvaluateJointStates
116
116
// q(i) = msg->position[i];
117
117
// q_dot(i) = msg->velocity[i];
118
118
// }
119
- for (unsigned int i = 0 ; i < chain_.getNrOfJoints (); i++)
119
+ for (unsigned int i = 0 ; i < chain_.getNrOfSegments (); i++)
120
120
{
121
- std::string joint_name = chain_.getSegment (i).getJoint ().getName ();
122
- if (std::find (msg->name .begin (), msg->name .end (), joint_name) != msg->name .end ())
121
+ KDL::Joint joint = chain_.getSegment (i).getJoint ();
122
+ std::string joint_name = joint.getName ();
123
+ if (joint.getType () == KDL::Joint::None)
123
124
{
124
- unsigned int index = std::distance (msg->name .begin (), std::find (msg->name .begin (), msg->name .end (), joint_name));
125
- q (index) = msg->position [index];
126
- q_dot (index) = msg->velocity [index];
125
+ ROS_DEBUG_STREAM (" Skip fixed Joint '" << joint_name);
126
+ continue ;
127
127
}
128
- else
128
+ else
129
129
{
130
- ROS_ERROR_STREAM (" Joint '" << joint_name << " ' not found in JointStates" );
131
- return ;
130
+ if (std::find (msg->name .begin (), msg->name .end (), joint_name) != msg->name .end ())
131
+ {
132
+ unsigned int index = std::distance (msg->name .begin (), std::find (msg->name .begin (), msg->name .end (), joint_name));
133
+ q (index) = msg->position [index];
134
+ q_dot (index) = msg->velocity [index];
135
+ }
136
+ else
137
+ {
138
+ ROS_ERROR_STREAM (" Joint '" << joint_name << " ' not found in JointStates" );
139
+ return ;
140
+ }
132
141
}
133
142
}
134
143
135
144
// / compute current twist
136
145
std::vector< KDL::FrameVel > v_FrameVel;
137
146
KDL::JntArrayVel jntArrayVel = KDL::JntArrayVel (q, q_dot);
138
- v_FrameVel.resize (chain_.getNrOfJoints ());
139
- if (p_fksolver_vel_->JntToCart (jntArrayVel, v_FrameVel, chain_.getNrOfJoints ()) >= 0 )
147
+ v_FrameVel.resize (chain_.getNrOfSegments ());
148
+ if (p_fksolver_vel_->JntToCart (jntArrayVel, v_FrameVel, chain_.getNrOfSegments ()) >= 0 )
140
149
{
141
150
// last entry is twist of tip_link
142
151
geometry_msgs::Twist twist_msg;
@@ -146,7 +155,7 @@ class DebugEvaluateJointStates
146
155
// recursively calculate FrameVel magnitudes
147
156
sensor_msgs::JointState magnitude_msg;
148
157
magnitude_msg.header .stamp = msg->header .stamp ;
149
- for (unsigned int i = 0 ; i < chain_.getNrOfJoints (); i++)
158
+ for (unsigned int i = 0 ; i < chain_.getNrOfSegments (); i++)
150
159
{
151
160
magnitude_msg.name .push_back (chain_.getSegment (i).getName ());
152
161
magnitude_msg.velocity .push_back (v_FrameVel[i].GetTwist ().vel .Norm ());
0 commit comments