diff --git a/examples/Importers/ImportURDFDemo/UrdfParser.cpp b/examples/Importers/ImportURDFDemo/UrdfParser.cpp index f656e4fde..a37e610ed 100644 --- a/examples/Importers/ImportURDFDemo/UrdfParser.cpp +++ b/examples/Importers/ImportURDFDemo/UrdfParser.cpp @@ -1163,6 +1163,17 @@ bool UrdfParser::parseDeformable(UrdfModel& model, tinyxml2::XMLElement* config, } deformable.m_friction = urdfLexicalCast(friction_xml->Attribute("value")); } + + XMLElement* repulsion_xml = config->FirstChildElement("repulsion_stiffness"); + if (repulsion_xml) + { + if (!repulsion_xml->Attribute("value")) + { + logger->reportError("repulsion_stiffness element must have value attribute"); + return false; + } + deformable.m_repulsionStiffness = urdfLexicalCast(repulsion_xml->Attribute("value")); + } XMLElement* spring_xml = config->FirstChildElement("spring"); if (spring_xml) diff --git a/examples/Importers/ImportURDFDemo/UrdfParser.h b/examples/Importers/ImportURDFDemo/UrdfParser.h index 9b99bc36f..d873e4d30 100644 --- a/examples/Importers/ImportURDFDemo/UrdfParser.h +++ b/examples/Importers/ImportURDFDemo/UrdfParser.h @@ -225,6 +225,7 @@ struct UrdfDeformable double m_mass; double m_collisionMargin; double m_friction; + double m_repulsionStiffness; SpringCoeffcients m_springCoefficients; LameCoefficients m_corotatedCoefficients; @@ -234,7 +235,7 @@ struct UrdfDeformable std::string m_simFileName; btHashMap m_userData; - UrdfDeformable() : m_mass(1.), m_collisionMargin(0.02), m_friction(1.), m_visualFileName(""), m_simFileName("") + UrdfDeformable() : m_mass(1.), m_collisionMargin(0.02), m_friction(1.), m_repulsionStiffness(0.5), m_visualFileName(""), m_simFileName("") { } }; diff --git a/examples/SharedMemory/PhysicsClientC_API.cpp b/examples/SharedMemory/PhysicsClientC_API.cpp index 1ec54f498..b76c3466f 100644 --- a/examples/SharedMemory/PhysicsClientC_API.cpp +++ b/examples/SharedMemory/PhysicsClientC_API.cpp @@ -404,6 +404,15 @@ B3_SHARED_API int b3LoadSoftBodySetCollisionHardness(b3SharedMemoryCommandHandle return 0; } +B3_SHARED_API int b3LoadSoftBodySetRepulsionStiffness(b3SharedMemoryCommandHandle commandHandle, double stiffness) +{ + struct SharedMemoryCommand* command = (struct SharedMemoryCommand*)commandHandle; + b3Assert(command->m_type == CMD_LOAD_SOFT_BODY); + command->m_loadSoftBodyArguments.m_repulsionStiffness = stiffness; + command->m_updateFlags |= LOAD_SOFT_BODY_SET_REPULSION_STIFFNESS; + return 0; +} + B3_SHARED_API int b3LoadSoftBodySetSelfCollision(b3SharedMemoryCommandHandle commandHandle, int useSelfCollision) { struct SharedMemoryCommand* command = (struct SharedMemoryCommand*)commandHandle; diff --git a/examples/SharedMemory/PhysicsClientC_API.h b/examples/SharedMemory/PhysicsClientC_API.h index 7c52708a3..b3d077a28 100644 --- a/examples/SharedMemory/PhysicsClientC_API.h +++ b/examples/SharedMemory/PhysicsClientC_API.h @@ -648,7 +648,8 @@ extern "C" B3_SHARED_API int b3LoadSoftBodyAddGravityForce(b3SharedMemoryCommandHandle commandHandle, double gravityX, double gravityY, double gravityZ); B3_SHARED_API int b3LoadSoftBodySetCollisionHardness(b3SharedMemoryCommandHandle commandHandle, double collisionHardness); B3_SHARED_API int b3LoadSoftBodySetSelfCollision(b3SharedMemoryCommandHandle commandHandle, int useSelfCollision); - B3_SHARED_API int b3LoadSoftBodyUseFaceContact(b3SharedMemoryCommandHandle commandHandle, int useFaceContact); + B3_SHARED_API int b3LoadSoftBodyRepulsionStiffness(b3SharedMemoryCommandHandle commandHandle, double stiffness); + B3_SHARED_API int b3LoadSoftBodyUseFaceContact(b3SharedMemoryCommandHandle commandHandle, int useFaceContact); B3_SHARED_API int b3LoadSoftBodySetFrictionCoefficient(b3SharedMemoryCommandHandle commandHandle, double frictionCoefficient); B3_SHARED_API int b3LoadSoftBodyUseBendingSprings(b3SharedMemoryCommandHandle commandHandle, int useBendingSprings, double bendingStiffness); diff --git a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp index e1807e354..48ecba31f 100644 --- a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp +++ b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp @@ -8226,6 +8226,10 @@ void constructUrdfDeformable(const struct SharedMemoryCommand& clientCmd, UrdfDe { deformable.m_friction = loadSoftBodyArgs.m_frictionCoeff; } + if (clientCmd.m_updateFlags & LOAD_SOFT_BODY_SET_REPULSION_STIFFNESS) + { + deformable.m_repulsionStiffness = loadSoftBodyArgs.m_repulsionStiffness; + } #endif } @@ -8443,6 +8447,7 @@ bool PhysicsServerCommandProcessor::processDeformable(const UrdfDeformable& defo psb->setCollisionFlags(0); psb->setTotalMass(deformable.m_mass); psb->setSelfCollision(useSelfCollision); + psb->setSpringStiffness(deformable.m_repulsionStiffness); } #endif //SKIP_DEFORMABLE_BODY #ifndef SKIP_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD diff --git a/examples/SharedMemory/SharedMemoryCommands.h b/examples/SharedMemory/SharedMemoryCommands.h index c0d00ac72..af6cb907b 100644 --- a/examples/SharedMemory/SharedMemoryCommands.h +++ b/examples/SharedMemory/SharedMemoryCommands.h @@ -497,17 +497,18 @@ enum EnumLoadSoftBodyUpdateFlags LOAD_SOFT_BODY_UPDATE_MASS = 1<<2, LOAD_SOFT_BODY_UPDATE_COLLISION_MARGIN = 1<<3, LOAD_SOFT_BODY_INITIAL_POSITION = 1<<4, - LOAD_SOFT_BODY_INITIAL_ORIENTATION = 1<<5, - LOAD_SOFT_BODY_ADD_COROTATED_FORCE = 1<<6, - LOAD_SOFT_BODY_ADD_MASS_SPRING_FORCE = 1<<7, - LOAD_SOFT_BODY_ADD_GRAVITY_FORCE = 1<<8, - LOAD_SOFT_BODY_SET_COLLISION_HARDNESS = 1<<9, - LOAD_SOFT_BODY_SET_FRICTION_COEFFICIENT = 1<<10, - LOAD_SOFT_BODY_ADD_BENDING_SPRINGS = 1<<11, - LOAD_SOFT_BODY_ADD_NEOHOOKEAN_FORCE = 1<<12, - LOAD_SOFT_BODY_USE_SELF_COLLISION = 1<<13, - LOAD_SOFT_BODY_USE_FACE_CONTACT = 1<<14, - LOAD_SOFT_BODY_SIM_MESH = 1<<15, + LOAD_SOFT_BODY_INITIAL_ORIENTATION = 1<<5, + LOAD_SOFT_BODY_ADD_COROTATED_FORCE = 1<<6, + LOAD_SOFT_BODY_ADD_MASS_SPRING_FORCE = 1<<7, + LOAD_SOFT_BODY_ADD_GRAVITY_FORCE = 1<<8, + LOAD_SOFT_BODY_SET_COLLISION_HARDNESS = 1<<9, + LOAD_SOFT_BODY_SET_FRICTION_COEFFICIENT = 1<<10, + LOAD_SOFT_BODY_ADD_BENDING_SPRINGS = 1<<11, + LOAD_SOFT_BODY_ADD_NEOHOOKEAN_FORCE = 1<<12, + LOAD_SOFT_BODY_USE_SELF_COLLISION = 1<<13, + LOAD_SOFT_BODY_USE_FACE_CONTACT = 1<<14, + LOAD_SOFT_BODY_SIM_MESH = 1<<15, + LOAD_SOFT_BODY_SET_REPULSION_STIFFNESS = 1<<16, }; enum EnumSimParamInternalSimFlags @@ -540,6 +541,7 @@ struct LoadSoftBodyArgs double m_NeoHookeanDamping; int m_useFaceContact; char m_simFileName[MAX_FILENAME_LENGTH]; + double m_repulsionStiffness; }; struct b3LoadSoftBodyResultArgs