@@ -114,15 +114,13 @@ void CollisionRobotDistanceField::initialize(
114
114
planning_scene_.reset (new planning_scene::PlanningScene (robot_model_));
115
115
116
116
const std::vector<const moveit::core::JointModelGroup*>& jmg = robot_model_->getJointModelGroups ();
117
- for (std::vector< const moveit::core::JointModelGroup*>::const_iterator it = jmg. begin (); it != jmg. end (); it++ )
117
+ for (const moveit::core::JointModelGroup* jm : jmg)
118
118
{
119
- const moveit::core::JointModelGroup* jm = *it;
120
-
121
119
std::map<std::string, bool > updated_group_entry;
122
120
std::vector<std::string> links = jm->getUpdatedLinkModelsWithGeometryNames ();
123
- for (unsigned int i = 0 ; i < links. size (); i++ )
121
+ for (const std::string& link : links)
124
122
{
125
- updated_group_entry[links[i] ] = true ;
123
+ updated_group_entry[link ] = true ;
126
124
}
127
125
in_group_update_map_[jm->getName ()] = updated_group_entry;
128
126
state.updateLinkTransforms ();
@@ -279,19 +277,18 @@ bool CollisionRobotDistanceField::getSelfCollisions(const collision_detection::C
279
277
if (coll)
280
278
{
281
279
res.collision = true ;
282
- for (unsigned int j = 0 ; j < colls. size (); j++ )
280
+ for (unsigned int col : colls)
283
281
{
284
282
collision_detection::Contact con;
285
283
if (is_link)
286
284
{
287
- con.pos = gsr->link_body_decompositions_ [i]->getSphereCenters ()[colls[j] ];
285
+ con.pos = gsr->link_body_decompositions_ [i]->getSphereCenters ()[col ];
288
286
con.body_type_1 = collision_detection::BodyTypes::ROBOT_LINK;
289
287
con.body_name_1 = gsr->dfce_ ->link_names_ [i];
290
288
}
291
289
else
292
290
{
293
- con.pos =
294
- gsr->attached_body_decompositions_ [i - gsr->dfce_ ->link_names_ .size ()]->getSphereCenters ()[colls[j]];
291
+ con.pos = gsr->attached_body_decompositions_ [i - gsr->dfce_ ->link_names_ .size ()]->getSphereCenters ()[col];
295
292
con.body_type_1 = collision_detection::BodyTypes::ROBOT_ATTACHED;
296
293
con.body_name_1 = gsr->dfce_ ->attached_body_names_ [i - gsr->dfce_ ->link_names_ .size ()];
297
294
}
@@ -302,7 +299,7 @@ bool CollisionRobotDistanceField::getSelfCollisions(const collision_detection::C
302
299
con.body_name_2 = " self" ;
303
300
res.contact_count ++;
304
301
res.contacts [std::pair<std::string, std::string>(con.body_name_1 , con.body_name_2 )].push_back (con);
305
- gsr->gradients_ [i].types [colls[j] ] = SELF;
302
+ gsr->gradients_ [i].types [col ] = SELF;
306
303
}
307
304
gsr->gradients_ [i].collision = true ;
308
305
@@ -867,23 +864,22 @@ DistanceFieldCacheEntryPtr CollisionRobotDistanceField::generateDistanceFieldCac
867
864
{
868
865
const std::vector<const moveit::core::JointModel*>& child_joint_models =
869
866
dfce->state_ ->getJointModelGroup (dfce->group_name_ )->getActiveJointModels ();
870
- for (unsigned int i = 0 ; i < child_joint_models. size (); i++ )
867
+ for (const moveit::core::JointModel* child_joint_model : child_joint_models)
871
868
{
872
- updated_map[child_joint_models[i] ->getName ()] = true ;
873
- ROS_DEBUG_STREAM (" Joint " << child_joint_models[i] ->getName () << " has been added to updated list" );
869
+ updated_map[child_joint_model ->getName ()] = true ;
870
+ ROS_DEBUG_STREAM (" Joint " << child_joint_model ->getName () << " has been added to updated list" );
874
871
}
875
872
}
876
873
877
874
const std::vector<std::string>& state_variable_names = state.getVariableNames ();
878
- for (std::vector<std::string>::const_iterator name_iter = state_variable_names.begin ();
879
- name_iter != state_variable_names.end (); name_iter++)
875
+ for (const std::string& state_variable_name : state_variable_names)
880
876
{
881
- double val = state.getVariablePosition (*name_iter );
877
+ double val = state.getVariablePosition (state_variable_name );
882
878
dfce->state_values_ .push_back (val);
883
- if (updated_map.count (*name_iter ) == 0 )
879
+ if (updated_map.count (state_variable_name ) == 0 )
884
880
{
885
881
dfce->state_check_indices_ .push_back (dfce->state_values_ .size () - 1 );
886
- ROS_DEBUG_STREAM (" Non-group joint " << *name_iter << " will be checked for state changes" );
882
+ ROS_DEBUG_STREAM (" Non-group joint " << state_variable_name << " will be checked for state changes" );
887
883
}
888
884
}
889
885
@@ -899,9 +895,9 @@ DistanceFieldCacheEntryPtr CollisionRobotDistanceField::generateDistanceFieldCac
899
895
std::vector<PosedBodyPointDecompositionPtr> non_group_link_decompositions;
900
896
std::vector<PosedBodyPointDecompositionVectorPtr> non_group_attached_body_decompositions;
901
897
const std::map<std::string, bool >& updated_group_map = in_group_update_map_.find (group_name)->second ;
902
- for (unsigned int i = 0 ; i < robot_model_->getLinkModelsWithCollisionGeometry (). size (); i++ )
898
+ for (const moveit::core::LinkModel* link_model : robot_model_->getLinkModelsWithCollisionGeometry ())
903
899
{
904
- std::string link_name = robot_model_-> getLinkModelsWithCollisionGeometry ()[i] ->getName ();
900
+ const std::string& link_name = link_model ->getName ();
905
901
const moveit::core::LinkModel* link_state = dfce->state_ ->getLinkModel (link_name);
906
902
if (updated_group_map.find (link_name) != updated_group_map.end ())
907
903
{
@@ -914,10 +910,10 @@ DistanceFieldCacheEntryPtr CollisionRobotDistanceField::generateDistanceFieldCac
914
910
915
911
std::vector<const moveit::core::AttachedBody*> attached_bodies;
916
912
dfce->state_ ->getAttachedBodies (attached_bodies, link_state);
917
- for (unsigned int j = 0 ; j < attached_bodies. size (); j++ )
913
+ for (const moveit::core::AttachedBody* attached_body : attached_bodies)
918
914
{
919
915
non_group_attached_body_decompositions.push_back (
920
- getAttachedBodyPointDecomposition (attached_bodies[j] , resolution_));
916
+ getAttachedBodyPointDecomposition (attached_body , resolution_));
921
917
}
922
918
}
923
919
dfce->distance_field_ .reset (new distance_field::PropagationDistanceField (
@@ -930,16 +926,18 @@ DistanceFieldCacheEntryPtr CollisionRobotDistanceField::generateDistanceFieldCac
930
926
// now we need to actually set the points
931
927
// TODO - deal with shifted robot
932
928
EigenSTL::vector_Vector3d all_points;
933
- for (unsigned int i = 0 ; i < non_group_link_decompositions.size (); i++)
929
+ for (collision_detection::PosedBodyPointDecompositionPtr& non_group_link_decomposition :
930
+ non_group_link_decompositions)
934
931
{
935
- all_points.insert (all_points.end (), non_group_link_decompositions[i] ->getCollisionPoints ().begin (),
936
- non_group_link_decompositions[i] ->getCollisionPoints ().end ());
932
+ all_points.insert (all_points.end (), non_group_link_decomposition ->getCollisionPoints ().begin (),
933
+ non_group_link_decomposition ->getCollisionPoints ().end ());
937
934
}
938
935
939
- for (unsigned int i = 0 ; i < non_group_attached_body_decompositions.size (); i++)
936
+ for (collision_detection::PosedBodyPointDecompositionVectorPtr& non_group_attached_body_decomposition :
937
+ non_group_attached_body_decompositions)
940
938
{
941
- all_points.insert (all_points.end (), non_group_attached_body_decompositions[i] ->getCollisionPoints ().begin (),
942
- non_group_attached_body_decompositions[i] ->getCollisionPoints ().end ());
939
+ all_points.insert (all_points.end (), non_group_attached_body_decomposition ->getCollisionPoints ().begin (),
940
+ non_group_attached_body_decomposition ->getCollisionPoints ().end ());
943
941
}
944
942
945
943
dfce->distance_field_ ->addPointsToField (all_points);
@@ -952,20 +950,20 @@ DistanceFieldCacheEntryPtr CollisionRobotDistanceField::generateDistanceFieldCac
952
950
void CollisionRobotDistanceField::addLinkBodyDecompositions (double resolution)
953
951
{
954
952
const std::vector<const moveit::core::LinkModel*>& link_models = robot_model_->getLinkModelsWithCollisionGeometry ();
955
- for (unsigned int i = 0 ; i < link_models. size (); i++ )
953
+ for (const moveit::core::LinkModel* link_model : link_models)
956
954
{
957
- if (link_models[i] ->getShapes ().empty ())
955
+ if (link_model ->getShapes ().empty ())
958
956
{
959
- ROS_WARN (" No collision geometry for link model %s though there should be" , link_models[i] ->getName ().c_str ());
957
+ ROS_WARN (" No collision geometry for link model %s though there should be" , link_model ->getName ().c_str ());
960
958
continue ;
961
959
}
962
960
963
- ROS_DEBUG (" Generating model for %s" , link_models[i] ->getName ().c_str ());
964
- BodyDecompositionConstPtr bd (new BodyDecomposition (link_models[i] ->getShapes (),
965
- link_models[i] ->getCollisionOriginTransforms (), resolution,
966
- getLinkPadding (link_models[i] ->getName ())));
961
+ ROS_DEBUG (" Generating model for %s" , link_model ->getName ().c_str ());
962
+ BodyDecompositionConstPtr bd (new BodyDecomposition (link_model ->getShapes (),
963
+ link_model ->getCollisionOriginTransforms (), resolution,
964
+ getLinkPadding (link_model ->getName ())));
967
965
link_body_decomposition_vector_.push_back (bd);
968
- link_body_decomposition_index_map_[link_models[i] ->getName ()] = link_body_decomposition_vector_.size () - 1 ;
966
+ link_body_decomposition_index_map_[link_model ->getName ()] = link_body_decomposition_vector_.size () - 1 ;
969
967
}
970
968
}
971
969
@@ -1043,27 +1041,26 @@ void CollisionRobotDistanceField::addLinkBodyDecompositions(
1043
1041
ROS_ASSERT_MSG (robot_model_, " RobotModelPtr is invalid" );
1044
1042
const std::vector<const moveit::core::LinkModel*>& link_models = robot_model_->getLinkModelsWithCollisionGeometry ();
1045
1043
1046
- for (unsigned int i = 0 ; i < link_models. size (); i++ )
1044
+ for (const moveit::core::LinkModel* link_model : link_models)
1047
1045
{
1048
- if (link_models[i] ->getShapes ().empty ())
1046
+ if (link_model ->getShapes ().empty ())
1049
1047
{
1050
- ROS_WARN_STREAM (" Skipping model generation for link " << link_models[i] ->getName ()
1048
+ ROS_WARN_STREAM (" Skipping model generation for link " << link_model ->getName ()
1051
1049
<< " since it contains no geometries" );
1052
1050
continue ;
1053
1051
}
1054
1052
1055
- BodyDecompositionPtr bd (new BodyDecomposition (link_models[i]->getShapes (),
1056
- link_models[i]->getCollisionOriginTransforms (), resolution,
1057
- getLinkPadding (link_models[i]->getName ())));
1053
+ BodyDecompositionPtr bd (new BodyDecomposition (link_model->getShapes (), link_model->getCollisionOriginTransforms (),
1054
+ resolution, getLinkPadding (link_model->getName ())));
1058
1055
1059
- ROS_DEBUG (" Generated model for %s" , link_models[i] ->getName ().c_str ());
1056
+ ROS_DEBUG (" Generated model for %s" , link_model ->getName ().c_str ());
1060
1057
1061
- if (link_spheres.find (link_models[i] ->getName ()) != link_spheres.end ())
1058
+ if (link_spheres.find (link_model ->getName ()) != link_spheres.end ())
1062
1059
{
1063
- bd->replaceCollisionSpheres (link_spheres.find (link_models[i] ->getName ())->second , Eigen::Isometry3d::Identity ());
1060
+ bd->replaceCollisionSpheres (link_spheres.find (link_model ->getName ())->second , Eigen::Isometry3d::Identity ());
1064
1061
}
1065
1062
link_body_decomposition_vector_.push_back (bd);
1066
- link_body_decomposition_index_map_[link_models[i] ->getName ()] = link_body_decomposition_vector_.size () - 1 ;
1063
+ link_body_decomposition_index_map_[link_model ->getName ()] = link_body_decomposition_vector_.size () - 1 ;
1067
1064
}
1068
1065
ROS_DEBUG_STREAM (__FUNCTION__ << " Finished " );
1069
1066
}
0 commit comments