@@ -518,7 +518,6 @@ bool JointTrajectoryInterface::calc_velocity(const motoman_msgs::DynamicJointsGr
518
518
return true ;
519
519
}
520
520
521
- robot_groups_[pt.group_number ].get_joint_names ();
522
521
for (size_t i = 0 ; i < robot_groups_[pt.group_number ].get_joint_names ().size (); ++i)
523
522
{
524
523
const std::string &jnt_name = robot_groups_[pt.group_number ].get_joint_names ()[i];
@@ -727,12 +726,32 @@ bool JointTrajectoryInterface::is_valid(const motoman_msgs::DynamicJointTrajecto
727
726
void JointTrajectoryInterface::jointStateCB (
728
727
const sensor_msgs::JointStateConstPtr &msg)
729
728
{
729
+ if (msg->name .size () != this ->all_joint_names_ .size ())
730
+ return ;
731
+
732
+ // compare all names, reject message if a name is not in both lists
733
+ for (size_t i=0 ; i<msg->name .size (); i++)
734
+ if (std::find (msg->name .begin (), msg->name .end (), this ->all_joint_names_ [i]) == msg->name .end ())
735
+ return ;
736
+
730
737
this ->cur_joint_pos_ = *msg;
731
738
}
732
739
733
740
void JointTrajectoryInterface::jointStateCB (
734
741
const sensor_msgs::JointStateConstPtr &msg, int robot_id)
735
742
{
743
+ if (msg->name .size () != this ->robot_groups_ [robot_id].get_joint_names ().size ())
744
+ {
745
+ return ;
746
+ }
747
+
748
+ // compare all names, reject message if a name is not in both lists
749
+ for (size_t i=0 ; i<msg->name .size (); i++)
750
+ {
751
+ if (std::find (msg->name .begin (), msg->name .end (), this ->robot_groups_ [robot_id].get_joint_names ()[i]) == msg->name .end ())
752
+ return ;
753
+ }
754
+
736
755
this ->cur_joint_pos_map_ [robot_id] = *msg;
737
756
}
738
757
0 commit comments