Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inverse Kinematics Service update #18

Merged
merged 1 commit into from
Oct 27, 2017
Merged

Conversation

IanTheEngineer
Copy link
Contributor

This update adds the SNS IK solver as the backbone of the IK service inside the Kinematics class. Updates include:

  • Added sns_ik_lib as a dependency
  • Acceleration Limits to be added to the parameter server
  • Distinguishes between the endpoint tips and gravity compensation tips (to properly account for gravity)
  • Adds the servicePositionIK ROS Service

Copy link

@rethink-forrest rethink-forrest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks mostly there.

@@ -0,0 +1,12 @@
robot_config:
joint_config:
joint_acceleration_limit:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anyway of specifying units here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! Comments are supported. Will do

std::unique_ptr<KDL::ChainIdSolver_RNE> gravity_solver;
std::unique_ptr<sns_ik::SNS_IK> ik_solver;
/*std::unique_ptr<KDL::ChainFDSolverTau> fk_eff_solver; TODO(imcmahon)
std::unique_ptr<KDL::ChainIkSolverVel_pinv> ik_solver_vel;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A velocity IK solver should be simple to add via SNS, or did you want to save this for future work.

std::unique_ptr<sns_ik::SNS_IK> ik_solver;
/*std::unique_ptr<KDL::ChainFDSolverTau> fk_eff_solver; TODO(imcmahon)
std::unique_ptr<KDL::ChainIkSolverVel_pinv> ik_solver_vel;
std::unique_ptr<KDL::ChainIkSolverPos_NR_JL> ik_solver_pos;*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SHS IK solver replaces this.

@@ -122,6 +128,11 @@ bool servicePositionIK(intera_core_msgs::SolvePositionIK::Request& req,
*/
bool computePositionFK(const Kinematics& kin, const KDL::JntArray& jnt_pos, geometry_msgs::Pose& result);

bool computePositionIK(const Kinematics& kin, const geometry_msgs::Pose& cart_pose,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There function parameters need to be documented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -20,13 +20,16 @@
to launching sawyer_world -->
<arg name="load_robot_description" default="true"/>
<param if="$(arg load_robot_description)" name="robot_description"
command="$(find xacro)/xacro --inorder $(find sawyer_description)/urdf/sawyer.urdf.xacro gazebo:=true"/>
command="$(find xacro)/xacro --inorder $(find sawyer_description)/urdf/sawyer.urdf.xacro gazebo:=true electric_gripper:=$(arg electric_gripper)"/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check line length.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

{
seed_modes.push_back(req.seed_mode);
}
for(size_t j=0; j<seed_modes.size(); j++)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a vector for seed_modes is really confusing. There are only two options here, with SEED_AUTO trying both. I feel like there is a better way of structuring this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Restructured the flow on this to be more intuitive, though it will function the same.

else // (req.seed_mode == req.SEED_CURRENT)
{
std::shared_ptr<const sensor_msgs::JointState> joint_state;
joint_state_buffer_.get(joint_state);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this measured or reference joint states?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are only measured joint states in sim. Though I could consider adding reference.

}
}

if (!computePositionIK(kinematic_chain_map_[req.tip_names[i]], req.pose_stamp[i].pose, jnt_nullspace_bias, jnt_seed, jnt_result))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check line length

/* if (jointsInCollision(kinematic_chain_map_[req.tip_names[i]], jnt_result))
{
res.result_type[i] = res.IK_IN_COLLISION;
} TODO(imcmahon) Utilize FCL for collision checking

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a issue filed for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed: #19

req.seed_angles[i].name.size() == req.seed_angles[i].position.size())
{

jointStatePositionToKDL(req.seed_angles[i], kinematic_chain_map_[req.tip_names[i]], jnt_seed);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only search kinematic_chain_map_ once for req.tip_names[i].

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this isn't actually a search, but directly accessing the hash of a mapped variable. I can't easily copy this to a variable as most of the contents are stored in a unique_ptr variable, which cannot be copied without transferring ownership.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under the hood, getting any element from a map requires a search based on the hash. You might also want to be caution that the [] will create a new element if one doesn't already exist for the desired key.
http://www.cplusplus.com/reference/map/map/operator[]/

You could also store the map iterator if your worried about copying objects.

Copy link
Contributor Author

@IanTheEngineer IanTheEngineer Oct 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way the code is currently structured, no element is accessed without already existing. It is possible that the code could be misused in the future though. The unique_ptrs cannot be copied. I'm not particularly inclined to optimize around the hash lookup costs, but I think your iterator idea is an excellent one. I'll explore that thought.

(res.result_type[i] == res.IK_FAILED || res.result_type[i] == res.IK_IN_COLLISION)
)
)
{
std::shared_ptr<const sensor_msgs::JointState> joint_state;
joint_state_buffer_.get(joint_state);
if (joint_state.get())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Print warning if joint_state doesn't exist.

Copy link

@rethink-forrest rethink-forrest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

seed_modes.push_back(req.SEED_CURRENT);
}
else
if (req.seed_mode == req.SEED_USER || req.seed_mode == req.SEED_AUTO)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks much cleaner.

This update adds the SNS IK solver as the backbone of the IK service
inside the Kinematics class. Updates include:

- Added sns_ik_lib as a dependency
- Acceleration Limits to be added to the parameter server
- Distinguishes between the endpoint tips and gravity compensation tips
  (to properly account for gravity)
- Adds the servicePositionIK ROS Service
@IanTheEngineer IanTheEngineer merged commit a084be6 into development Oct 27, 2017
@IanTheEngineer IanTheEngineer deleted the kinematics_update branch October 30, 2017 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants