File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ class RobotInfo
5656 std::vector<VariableInfo> variables;
5757 std::vector<size_t > activeVariables;
5858 std::vector<moveit::core::JointModel::JointType> variable_joint_types;
59+ std::vector<bool > has_bounds;
5960 moveit::core::RobotModelConstPtr robot_model;
6061
6162 __attribute__ ((always_inline)) static inline double clamp2 (double v, double lo, double hi)
@@ -97,6 +98,7 @@ class RobotInfo
9798 info.max_velocity_rcp = info.max_velocity > 0.0 ? 1.0 / info.max_velocity : 0.0 ;
9899
99100 variables.push_back (info);
101+ has_bounds.push_back (bounded);
100102 }
101103
102104 for (size_t ivar = 0 ; ivar < model->getVariableCount (); ivar++)
@@ -120,6 +122,7 @@ class RobotInfo
120122
121123 inline bool isRevolute (size_t variable_index) const { return variable_joint_types[variable_index] == moveit::core::JointModel::REVOLUTE; }
122124 inline bool isPrismatic (size_t variable_index) const { return variable_joint_types[variable_index] == moveit::core::JointModel::PRISMATIC; }
125+ inline bool hasBounds (size_t variable_index) const { return has_bounds[variable_index]; }
123126 inline double getMaxVelocity (size_t i) const { return variables[i].max_velocity ; }
124127 inline double getMaxVelocityRcp (size_t i) const { return variables[i].max_velocity_rcp ; }
125128};
Original file line number Diff line number Diff line change @@ -582,8 +582,8 @@ struct BioIKKinematicsPlugin : kinematics::KinematicsBase {
582582 if (robot_info.isRevolute (ivar) &&
583583 robot_model->getMimicJointModels ().empty ()) {
584584 auto r = problem.initial_guess [ivar];
585- auto lo = robot_info.getMin (ivar);
586- auto hi = robot_info.getMax (ivar);
585+ auto lo = robot_info.getClipMin (ivar);
586+ auto hi = robot_info.getClipMax (ivar);
587587
588588 // move close to initial guess
589589 if (r < v - M_PI || r > v + M_PI) {
@@ -609,10 +609,14 @@ struct BioIKKinematicsPlugin : kinematics::KinematicsBase {
609609 v = hi;
610610 }
611611 state[ivar] = v;
612- }
613612
614- // wrap angles
615- robot_model->enforcePositionBounds (state.data ());
613+ // wrap angles that are bounded
614+ if (robot_info.hasBounds (ivar))
615+ {
616+ auto * joint_model = robot_model->getJointOfVariable (ivar);
617+ joint_model->enforcePositionBounds (state.data () + ivar, joint_model->getVariableBounds ());
618+ }
619+ }
616620
617621 // map result to jointgroup variables
618622 {
You can’t perform that action at this time.
0 commit comments