sea-bass / pyroboplan

Educational Python library for manipulator motion planning
https://pyroboplan.readthedocs.io
MIT License
216 stars 22 forks source link

Collision avoidance constraints in trajectory optimization #49

Closed sea-bass closed 2 months ago

sea-bass commented 3 months ago

This PR adds collision avoidance to kinematic trajectory optimization, per these resources:

It seems to correctly enforce the constraint (traj opt won't succeed unless the waypoints/collocation points are collision free), but it doesn't work that well when the initial guess is in collision...

I suspect the same HPP-FCL Limitation where we're not getting the collision distance points is at play here... so I'm inclined to merge this as-is and fix once Pinocchio 3.0 is out.

github-actions[bot] commented 3 months ago

Coverage

Coverage Report
FileStmtsMissCoverMissing
pyroboplan
   __init__.py00100% 
pyroboplan/core
   __init__.py00100% 
   planning_context.py880%1, 4, 9, 13–15, 17–18
   utils.py1341291%78–79, 81–84, 86–87, 228–229, 531, 542
pyroboplan/ik
   __init__.py00100% 
   differential_ik.py961386%158–159, 168–169, 197, 203, 209, 212, 250, 256–257, 262, 273
   nullspacecomponents.py350100% 
pyroboplan/models
   __init_\.py00100% 
   panda.py450100% 
   twodof.py80100% 
   utils.py50100% 
pyroboplan/planning
   __init_\.py00100% 
   cartesian_planner.py92594%115, 139, 143–144, 207
   graph.py130496%58, 103, 195, 261
   graph_search.py53296%57, 135
   path_shortcutting.py48197%121
   prm.py1072576%109, 144, 206–209, 235–236, 242–243, 268–269, 273–274, 326–329, 332, 335, 343–345, 349–350
   rrt.py1482682%152–153, 162–163, 186–187, 190, 198, 263, 359, 407–409, 413–414, 418–421, 424, 427, 435–437, 440, 443
   utils.py470100% 
pyroboplan/trajectory
   __init__.py00100% 
   polynomial.py1523974%148, 150–151, 153–155, 157–159, 162–185, 188, 191, 194, 203, 230, 299
   trajectory_optimization.py1830100% 
   trapezoidal_velocity.py1683380%283–284, 329, 331–335, 337–338, 341–359, 362–364, 373
pyroboplan/visualization
   __init__.py00100% 
   meshcat_utils.py211338%40–41, 43, 45, 57, 81–82, 109, 131–134, 136
TOTAL148018187% 

Tests Skipped Failures Errors Time
95 0 :zzz: 0 :x: 0 :fire: 29.954s :stopwatch:
sea-bass commented 3 months ago

How much more do you want to poke at this?

I don't know... it really doesn't work well enough for me to be happy with it, but at the same time I've been seriously spinning my wheels and am close to giving up and just merging what is there.

sea-bass commented 3 months ago

I added a fallback that I'm more satisfied with in the "optimize RRT path example". It will now do:

  1. Plan an RRT
  2. Try do a full optimization using the RRT waypoints only as initial conditions
  3. If 2. fails, do another optimization, this time constraining the RRT waypoints and only optimizing trajectory segments in between them.