I need to fix one part of my robot to the static environment. Can this be done in Webots? I'm using R2022b.
1 Answer
Yes it is possible, you have two solutions:
If you want to modify your robot such that one part is always pinned to the static environment, you could remove the
Physicsnode from the topRobotnode.Then you can add
Physicsnodes only in the parts that you want.This is what is done in this example with the
staticBaseoption: the base is static but the robotic arm have physics.If you do not want to modify your robot or want to only immobilize your robot temporary, you can do it with a physics plugin. You can add a physics plugin with the
File / New / New Physics Plugin...menu item. In the plugin code, you must simply add an ODE fixed joint between the dBodyID of the robot part and the static environment. This can be implemented like this:#include <ode/ode.h> #include <plugins/physics.h> void webots_physics_init() { // get body of the robot part dBodyID body = dWebotsGetBodyFromDEF("MY_ROBOT_PART"); // get the matching world dWorldID world = dBodyGetWorld(body); // the joint group ID is 0 to allocate the joint normally dJointID joint = dJointCreateFixed(world, 0); // attach robot part to the static environment: 0 dJointAttach(joint, body, 0); // fix now: remember current position and rotation dJointSetFixed(joint); } void webots_physics_step() { // nothing to do } void webots_physics_cleanup() { // nothing to do }You will find the description of Webots physics plugin API here. You will find the description about the ODE functions on this page.