Skip to content
This repository has been archived by the owner on Nov 13, 2017. It is now read-only.

Allow KinematicBase to have RobotModel passed in to save loading time #216

Closed
wants to merge 3 commits into from
Closed

Allow KinematicBase to have RobotModel passed in to save loading time #216

wants to merge 3 commits into from

Conversation

davetcoleman
Copy link
Member

This allows some IK solvers, including the default KDL solver in MoveIt!, to load much faster by passing in a pre-loaded robot model instead of loading and parsing one from the parameter server each time an IK solver is initialized. This is important because multiple IK solvers are loaded, typically one for each planning group and again for each MoveIt! node. This does not currently improve loading time of IKFast solvers, however, because those robot models must be converted to Collada format and parsed by openrave.

Changes:

  • Passes a pointer to a RobotModel, or a Null pointer for backwards compatibility.
  • Deprecated initialize() function that does not use RobotModel
  • Added getParentModelPtr() to joint model group
  • Added boost::enable_shared_from_this to allow the shared pointer to be recieved by objects that only have its raw pointer

Additionally, KinematicsBase is now forward declaring RobotState and RobotModel, so @isucan suggested:

To resolve cyclic dependency between libs, we should probably put everything in moveit_core into one lib.

I have not done this yet, but am thinking I could create a new library moveit_core that includes moveit_robot_model, moveit_robot_state, and moveit_kinematics_base. Thoughts? It still currently compiles without this last change though.

const std::string& base_frame,
const std::string& tip_frame,
double search_discretization,
const moveit::core::RobotModel* robot_model)
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be a smart pointer rather than a raw one?

Copy link
Member Author

Choose a reason for hiding this comment

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

Kinematic plugins are loaded within the RobotModel constructor, so it is impossible to use a RobotModel smart pointer. I instead have to use enable_shared_from_this to get the smart pointer later. This feature was very tricky to implement.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah that does make sense...

@mikeferguson
Copy link
Contributor

Does this break compilation or use of existing IKFast plugins? If not, +1 from me.

@davetcoleman
Copy link
Member Author

It does not break IKFast plugins, at least at compile time. I should probably do some more runtime testing

* @param robot_model - intended to replace reliance on robot_description, this allows the URDF to be loaded much quicker
* @return True if initialization was successful, false otherwise
*/
virtual bool initialize(const std::string& robot_description,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like this new function - if we don't need robot description (since we have robot model), we should not need to pass it in. I would redesign this to just use a RobotModel ptr (with group name and search discretization).

Copy link
Member Author

Choose a reason for hiding this comment

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

See comments for moveit_ros PR

Copy link
Contributor

Choose a reason for hiding this comment

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

another way to do this could be to have the new initialize function be simply: initialize(robot_model, search_discretization, group_name) - make it return false by default, check on that in kinematics_plugin loader and try the other (older) initialize function then. This way things will stay cleaner and separated and we won't break anyone using the old initialize function (yet). For ROS-J, I would honestly prefer writing a new plugin with an attempt to keep the base class as it is (as far as possible) - bandaging an old plugin can get painful after a while.

@sachinchitta
Copy link
Contributor

I don't use IKFast plugins as much but are there tests for those plugins? I would prefer this PR to be accompanied by tests implemented for those plugins first. Also, make sure that the tests that are already there for the PR2 pass (which you might have checked already). Changes in this particular component of MoveIt! affect everything else so its important to be careful.

@davetcoleman
Copy link
Member Author

I do not believe there are tests for IKFast plugins, and I am not very motivated to create them since I also do not currently use IKFast (though I do help maintain the package).

I haven't run PR2 tests yet, will do.

@davetcoleman
Copy link
Member Author

I ran the PR2 tests and they do pass.

@davetcoleman
Copy link
Member Author

One issue with this PR I currently have - when compiling I now always get a deprecated warning because I have the new function by default calling the old function (for compatibility):

/home/dave/ros/ws_moveit/src/moveit_core/kinematics_base/include/moveit/kinematics_base/kinematics_base.h:339:98: warning: virtual bool kinematics::KinematicsBase::initialize(const string&, const string&, const string&, const string&, double) is deprecated (declared at /ho
me/dave/ros/ws_moveit/src/moveit_core/kinematics_base/include/moveit/kinematics_base/kinematics_base.h:313) [-Wdeprecated-declarations]
return initialize(robot_description, group_name, base_frame, tip_frame, search_discretization);

Is there a way to suppress the warning for that one instance?

@sachinchitta
Copy link
Contributor

I have tried this PR and it broke MoveIt! in ways I could not understand - all the planning plugins disappeared. I agree that we need a way to initialize MoveIt! classes using a robot model passed in but this PR does not do it the right way.

@davetcoleman
Copy link
Member Author

@sachinchitta I do not understand why you closed this PR when you agree MoveIt! needs this functionality. Even though this PR did not get addressed for an entire year doesn't mean its bad.

  • Could you explain more clearly what errors you experienced and maybe include some command line output?
  • I'd also be curious to know what you think the right way is to do this PR?

When I first created this PR I put in a lot of effort to make this backwards compatible, I tested it with several different IK solvers, and I ran the entire MoveIt! test suite. I've been using this feature for a year now in my own MoveIt fork and have had no issues.

I did just merge it with the latest jade and the basic MoveIt demo.launch is not working, likely because the recent KinematicBase multi-solution changes. I could address this. But if I fix it will there be support in getting it merged in or will you close it in another year?

@sachinchitta
Copy link
Contributor

I closed it because of the reasons mentioned when I tested it. These are the basic interaction tests I always do before merging any PR (not exhaustive):

Startup a demo.launch for a robot that I have (e.g. moveit_examples here has a Fanuc: https://github.com/sachinchitta/moveit_examples)

  • move the robot around and make sure that works
  • choose a start and goal position, change the planner to RRTConnect and create and visualize a plan

In this PR's case, all the planners disappeared. I did spend a bunch of time trying to figure it out - note that I have pulled in other PRs and updated them myself where I thought the functionality was useful and important - e.g. moveit/moveit_ros#625.

I think this functionality is important and very significant but it feels ad-hoc and weird to have RobotModel use kinematics base as a building block and vice-versa. I would prefer it if we rethink the relationship between the two in a more fundamental way - I think robot model should offer some kinematics solvers by default internally and expose a plugin model for other types of solvers.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants