@@ -421,8 +421,6 @@ void simple_grasp()
421421 1. In absence of gravity, the fingers close and squeeze the object.
422422 2. Gravity is progressively turned on. The object stays between the fingers due to Coulomb friction coefficient slightly larger than the sticking threshold.
423423 3. The friction coefficient is reduced to slightly below the sticking threshold. The object slides between the fingers.
424-
425- This scene also shows how to anonymous lambdas to scope the script code, which is an option to avoid global variables.
426424 */
427425
428426 stark::Settings settings = stark::Settings ();
@@ -448,43 +446,35 @@ void simple_grasp()
448446 simulation.interactions ->contact ->set_global_params (
449447 stark::EnergyFrictionalContact::GlobalParams ()
450448 .set_default_contact_thickness (contact_thickness)
451- .set_friction_stick_slide_threshold (0.001 ) // Tighther threshold for more accurate frictional forces
449+ .set_friction_stick_slide_threshold (0.001 ) // Tighter threshold for more accurate frictional forces
452450 .set_min_contact_stiffness (1e7 )
453451 );
454452
455453 // Object
456- auto [obj, obj_c] = [&]()
457- {
458- auto params = stark::Volume::Params::Soft_Rubber ();
459- params.inertia .density = mass/std::pow (d, 3 );
460- params.strain .elasticity_only = true ; // We don't need material damping nor strain limiting for this scene
461- params.strain .youngs_modulus = 2e3 ;
462- auto [V, T, H] = simulation.presets ->deformables ->add_volume_grid (" deformable" , { d, d, d }, { n, n, n }, params);
463- return std::make_tuple ( H, H.contact );
464- }();
454+ stark::Volume::Params obj_params = stark::Volume::Params::Soft_Rubber ();
455+ obj_params.inertia .density = mass/std::pow (d, 3 );
456+ obj_params.strain .elasticity_only = true ; // We don't need material damping nor strain limiting for this scene
457+ obj_params.strain .youngs_modulus = 2e3 ;
458+ auto [V_obj, T_obj, obj] = simulation.presets ->deformables ->add_volume_grid (" deformable" , { d, d, d }, { n, n, n }, obj_params);
459+ auto obj_c = obj.contact ;
465460
466461 // Hand
467- auto [hand, hand_c] = [&]()
468- {
469- auto [V, C, H] = simulation.presets ->rigidbodies ->add_box (" hand" , mass, { 3 *d, 3 *d, 3 *d });
470- H.rigidbody .set_translation ({ 0.0 , -(3 * hd + hd + gap), 0.0 });
471- return std::make_tuple (H.rigidbody , H.contact );
472- }();
462+ auto [V_hand, C_hand, H_hand] = simulation.presets ->rigidbodies ->add_box (" hand" , mass, { 3 *d, 3 *d, 3 *d });
463+ H_hand.rigidbody .set_translation ({ 0.0 , -(3 * hd + hd + gap), 0.0 });
464+ auto hand = H_hand.rigidbody ;
465+ auto hand_c = H_hand.contact ;
473466
474467 // Fingers
475468 const Eigen::Vector3d fingers_size = { 0.5 *d, 2 *d, 2 *d };
476- auto [left_finger, left_finger_c] = [&]()
477- {
478- auto [V, C, H] = simulation.presets ->rigidbodies ->add_box (" hand" , mass, fingers_size);
479- H.rigidbody .set_translation ({ -(hd + 0.5 * hd + gap), -gap, 0.0 });
480- return std::make_tuple (H.rigidbody , H.contact );
481- }();
482- auto [right_finger, right_finger_c] = [&]()
483- {
484- auto [V, C, H] = simulation.presets ->rigidbodies ->add_box (" hand" , mass, fingers_size);
485- H.rigidbody .set_translation ({ (hd + 0.5 * hd + gap), -gap, 0.0 });
486- return std::make_tuple (H.rigidbody , H.contact );
487- }();
469+ auto [V_lf, C_lf, H_lf] = simulation.presets ->rigidbodies ->add_box (" hand" , mass, fingers_size);
470+ H_lf.rigidbody .set_translation ({ -(hd + 0.5 * hd + gap), -gap, 0.0 });
471+ auto left_finger = H_lf.rigidbody ;
472+ auto left_finger_c = H_lf.contact ;
473+
474+ auto [V_rf, C_rf, H_rf] = simulation.presets ->rigidbodies ->add_box (" hand" , mass, fingers_size);
475+ H_rf.rigidbody .set_translation ({ (hd + 0.5 * hd + gap), -gap, 0.0 });
476+ auto right_finger = H_rf.rigidbody ;
477+ auto right_finger_c = H_rf.contact ;
488478
489479 // Disable collisions
490480 simulation.interactions ->contact ->disable_collision (hand_c, left_finger_c);
0 commit comments