1) the joint space parametrization. Sometimes, e.g., kuka arms, we have > 2pi range per joint. even close to 4pi. This is defined in the URDF as a revolute but not continuous joint, and all of this gets translated into a subset of R^7.
The reason I am mentioning this is that when IK solutions are produced, if we get solutions where a joint is 2pi away from the current state, the motion plan can get very weird.
2) actual smoothing (this is the more likely culprit).
- In the request for computing a motion plan there is the number of plans to generate (num_planning_attempts). If this number is >1, multiple plans are generated and hybridized -- combined so that shortest part of each is used to make the shortest plan possible.
In the pick&place pipeline, the plan_stage uses one single plan. To get better plans, we need to add a param for this value, possibly exposed in the pick & place params, and set this to something like 3 - 5.
Once we have this in, the chance of getting a bad plan is much less.
- The time spent for smoothing can be increased. In fact, I sometimes hack the code and simply call the OMPL routines for smoothing multiple times. If we just call those routines a few times, tweak the time spent on the different types of shortening / smoothing (see PathSimplifier class in OMPL), we can get very high quality solutions. This is not a parameter either, and a little code needs to be written to expose more of the OMPL functionality for smoothing.
3) Used algorithm. We can use RRT* for instance, to generate a short path from the beginning. That might be a bit slow, but it would be worth running different OMPL planners in paralel. Unfortunately that is not exposed in MoveIt -- the same planner is run in parallel, although OMPL supports running different planners in parallel (ParallelPlan class).
Ioan