webots-physics
Webots Physics Skill
Use this skill to configure and debug rigid body physics behavior in Webots using ODE-backed simulation primitives and parameters.
Do not cover basic world building workflow in this skill; route that work to webots-world-building.
Do not cover motor control API usage in this skill; route that work to webots-actuators.
Scope
- Configure global simulation behavior from
WorldInfophysics fields. - Configure mass, inertia, and center of mass with
Physics. - Configure and tune joint constraints and passive dynamics.
- Configure collision shapes and contact material interactions.
- Configure damping and fluid interaction fields.
- Implement advanced custom dynamics through physics plugins.
- Tune runtime performance while preserving required simulation fidelity.
ODE Engine Fundamentals
Webots uses the Open Dynamics Engine (ODE) for rigid body dynamics.
Control global physics from WorldInfo:
basicTimeStep: simulation step in milliseconds. Lower value increases numerical accuracy and stability, with higher CPU cost. Higher value improves runtime speed, with lower stability and precision.ERP(Error Reduction Parameter):[0, 1]coefficient controlling how aggressively constraint error is corrected each step.CFM(Constraint Force Mixing): softening term for constraints. Higher values generally make constraints softer and can improve stability in difficult contact scenes.gravity: global gravitational acceleration vector.
Use conservative baseline values first, then tune one parameter at a time.
Physics Node
Use Physics on each dynamic Solid to define mass properties.
Physics {
density 1000 # kg/m^3 (use -1 if specifying mass directly)
mass 0.5 # kg (use -1 if using density)
centerOfMass [0 0 0] # local coordinates
inertiaMatrix [ # optional: Ixx Iyy Izz, Ixy Ixz Iyz
0.001 0.001 0.001
0 0 0
]
}
Apply these rules:
- Use either
densityormass; set the other to-1. - If both are omitted or left at default unresolved values, derive mass properties from
boundingObjectgeometry. - Set
centerOfMassandinertiaMatrixexplicitly when simulation fidelity matters (robot balance, high-speed motion, manipulation).
Joint Types
Model articulated mechanisms with Webots joint nodes.
HingeJoint (revolute, most common)
Use for single-axis rotational motion.
HingeJoint {
jointParameters HingeJointParameters {
position 0 # initial angle (rad)
axis 0 1 0 # rotation axis
anchor 0 0 0 # anchor point
minStop -1.57 # joint limits
maxStop 1.57
springConstant 0 # spring behavior
dampingConstant 0 # damping
}
device [
RotationalMotor { name "motor1" maxVelocity 10 maxTorque 5 }
PositionSensor { name "sensor1" }
Brake { name "brake1" }
]
endPoint Solid { ... }
}
SliderJoint (prismatic)
Use for single-axis linear motion.
- Follow the same structural pattern as
HingeJoint. - Interpret
JointParameters.positionin meters. - Use
axisas translation direction andanchoras reference point.
Hinge2Joint (universal, 2 DOF)
Use for two rotational degrees of freedom around two axes.
- Configure first axis through
HingeJointParameters. - Configure second axis through
JointParameters. - Tune stops and damping on both axes to avoid unstable cross-coupling.
BallJoint (spherical, 3 DOF)
Use for free rotation around one point.
- Use
BallJointParametersto defineanchor. - Apply damping and stop constraints through node-specific fields when needed.
Collision Detection
Use boundingObject to define collision geometry.
- Prefer simple primitives (
Box,Sphere,Cylinder,Capsule) for best performance. - Use
IndexedFaceSet/Meshcollision only where geometric fidelity is required. - Combine primitives in a
Groupto build efficient compound collision shapes. - Treat nested child
Solidnodes without intermediateJointas a fused rigid body.
ContactProperties
Define material pair interaction in WorldInfo.contactProperties.
WorldInfo {
contactProperties [
ContactProperties {
material1 "rubber"
material2 "asphalt"
coulombFriction [1.0] # friction coefficient
bounce 0.2 # bounciness (0-1)
bounceVelocity 0.1 # min velocity for bounce
softCFM 0.001 # contact softness
softERP 0.2
}
]
}
- Match
material1/material2against eachSolid.contactMaterialvalue. - Fall back to default contact friction/response when no pair matches.
- Use
softCFM/softERPto stabilize high-contact scenes and stacked bodies.
Damping
Use Damping for passive energy dissipation.
Damping {
linear 0.5 # linear velocity damping
angular 0.5 # angular velocity damping
}
- Increase linear damping to reduce translational drift/oscillation.
- Increase angular damping to suppress spin and joint ringing.
Fluid Dynamics
Use Fluid and ImmersionProperties to model buoyancy and drag.
- Define fluid volume and physical coefficients in a
Fluidnode. - Define per-body fluid interaction in
ImmersionPropertieson eachSolid. - Account for Archimedes' thrust (buoyancy), drag forces, fluid density, and viscosity.
- Validate center of mass and collision geometry when tuning submerged behavior.
Physics Plugin (Advanced)
Use a physics plugin for custom force models and direct ODE access.
- Implement plugin callbacks in C:
webots_physics_init,webots_physics_step,webots_physics_cleanup. - Access ODE bodies and joints directly from plugin-side APIs.
- Use for custom effects such as wind fields, tethers, bespoke force laws, and prototype soft-body approximations.
- Build and load as platform shared library (
.so,.dll,.dylib).
Performance Optimization
- Increase
basicTimeStepto improve speed, accepting reduced accuracy. - Set
WorldInfo.optimalThreadCountfor multi-threaded physics execution. - Configure
physicsDisableTimeto sleep idle objects and reduce solver work. - Prefer primitive collision shapes and avoid unnecessary mesh-mesh contacts.
- Reduce contact workload through
ContactProperties.maxContactJointswhen scenes are contact-heavy.
Workflow
- Establish baseline world parameters (
basicTimeStep,ERP,CFM,gravity). - Validate each dynamic
Solidmass and inertia setup. - Validate joint type and axis/anchor alignment against mechanism kinematics.
- Validate collision geometry simplicity and correctness.
- Tune
ContactPropertiesfor friction, restitution, and softness. - Add damping and fluid parameters only as needed.
- Use plugin-level customization only when built-in fields cannot express required dynamics.
- Profile and tune runtime cost after behavior correctness is achieved.
Reference File
Use references/physics_reference.md for field-level node reference, callback signatures, and ODE object mapping details.
More from bowtiedswan/webots-skills
webots-advanced
Use this skill for advanced Webots topics: ROS/ROS2 integration, transfer to real robots, numerical optimization, extern robot controllers, TCP/IP interfacing, performance optimization, known bugs/workarounds, plugin development (controller/robot window), building Webots from source, and multi-robot coordination. Triggers on: webots ROS, ROS2, webots_ros2, transfer to robot, extern controller, TCP/IP, optimization, known bugs, plugin, multi-robot, numerical optimization.
1webots-actuators
Use this skill when working with any Webots actuator - RotationalMotor, LinearMotor, Brake, LED, Display, Emitter, Speaker, Pen, Propeller, Connector, Muscle, or Track. Covers motor control modes (position, velocity, torque), actuator configuration, and command patterns. Triggers on: webots motor, setPosition, setVelocity, actuator, LED, display, emitter, propeller, brake, speaker, track.
1webots-proto
Use this skill when creating, modifying, or using PROTO nodes in Webots - reusable parameterized node templates for robots, objects, or environments. Covers PROTO definition syntax, field types, IS keyword, procedural PROTOs with JavaScript, scoping rules, and design guidelines. Triggers on: webots proto, .proto file, PROTO definition, IS keyword, parameterized node, reusable robot, procedural proto, custom node.
1webots-sensors
Use this skill when working with any Webots sensor - Camera, Lidar, DistanceSensor, GPS, Gyro, Accelerometer, InertialUnit, Compass, TouchSensor, RangeFinder, Radar, LightSensor, PositionSensor, Receiver, or Altimeter. Covers sensor configuration, enable/disable, reading values, and processing sensor data. Triggers on: webots sensor, camera, lidar, distance sensor, GPS, gyro, accelerometer, IMU, touch sensor, range finder, radar.
1webots-core
Use this skill when working with the Webots robotics simulation platform for installation, project setup, understanding core concepts (world files, nodes, scene tree, Robot/MjData equivalent), or basic simulation workflows. Triggers on: webots, robotics simulation, .wbt files, scene tree, WorldInfo, Viewpoint, simulation step, wb_robot_step.
1webots-humans-assets
Use this skill when adding human models, pedestrians, animated characters, or environment assets (furniture, buildings, nature, vehicles) to a Webots simulation. Covers CharacterSkin for animated humans, Pedestrian for walking models, BVH animation playback, C3D motion capture, and the complete object/environment asset library. Triggers on: webots human, pedestrian, CharacterSkin, BVH animation, furniture, environment, objects, assets, indoor, outdoor, buildings.
1