()
| 279 | |
| 280 | |
| 281 | def test_frame_collision(): |
| 282 | import coal |
| 283 | |
| 284 | fr_name1 = "larm_shoulder2_body" |
| 285 | fr_id1 = model.getFrameId(fr_name1) |
| 286 | joint_id = model.frames[fr_id1].parentJoint |
| 287 | |
| 288 | fr_name2 = "rleg_elbow_body" |
| 289 | fr_id2 = model.getFrameId(fr_name2) |
| 290 | joint_id2 = model.frames[fr_id2].parentJoint |
| 291 | |
| 292 | frame_SE3 = pin.SE3.Random() |
| 293 | frame_SE3_bis = pin.SE3.Random() |
| 294 | alpha = np.random.rand() |
| 295 | beta = np.random.rand() |
| 296 | gamma = np.random.rand() |
| 297 | delta = np.random.rand() |
| 298 | |
| 299 | geometry = pin.buildSampleGeometryModelHumanoid(model) |
| 300 | ig_frame = geometry.addGeometryObject( |
| 301 | pin.GeometryObject( |
| 302 | "frame", |
| 303 | parent_joint=joint_id, |
| 304 | parent_frame=fr_id1, |
| 305 | placement=frame_SE3, |
| 306 | collision_geometry=coal.Capsule(alpha, gamma), |
| 307 | ) |
| 308 | ) |
| 309 | |
| 310 | ig_frame2 = geometry.addGeometryObject( |
| 311 | pin.GeometryObject( |
| 312 | "frame2", |
| 313 | parent_joint=joint_id2, |
| 314 | parent_frame=fr_id2, |
| 315 | placement=frame_SE3_bis, |
| 316 | collision_geometry=coal.Capsule(beta, delta), |
| 317 | ) |
| 318 | ) |
| 319 | geometry.addCollisionPair(pin.CollisionPair(ig_frame, ig_frame2)) |
| 320 | gdata = geometry.createData() |
| 321 | |
| 322 | space = manifolds.MultibodyConfiguration(model) |
| 323 | ndx = space.ndx |
| 324 | x0 = space.neutral() |
| 325 | d = np.random.randn(space.ndx) * 0.1 |
| 326 | d[6:] = 0.0 |
| 327 | x0 = space.integrate(x0, d) |
| 328 | u0 = np.zeros(nu) |
| 329 | q0 = x0[:nq] |
| 330 | |
| 331 | pin.forwardKinematics(model, rdata, q0) |
| 332 | pin.updateGeometryPlacements(model, rdata, geometry, gdata, q0) |
| 333 | pin.computeDistance(geometry, gdata, 0) |
| 334 | norm = gdata.distanceResults[0].min_distance |
| 335 | |
| 336 | fun = aligator.FrameCollisionResidual(ndx, nu, model, geometry, 0) |
| 337 | |
| 338 | fdata = fun.createData() |
nothing calls this directly
no test coverage detected