Apply a User-defined Force on a Solid Node in Webots

410 Views Asked by At

I have been trying to add a 5KN force on the solid node named 'LLarm' on a robot in Webots from a matlab code using this function:

void wb_supervisor_node_add_force('LLarm', 5000, true)

but i get this error: Undefined function 'void' for input arguments of type 'char'. Error in atlas_matlab (line 12) void wb_supervisor_node_add_force('LLarm', 5000, true) Error in launcher (line 161) eval(WEBOTS_CONTROLLER_NAME);

1

There are 1 best solutions below

0
On

The force is described as a 3-dimensional vector, along the X, Y, and Z axes, see here:
https://cyberbotics.com/doc/reference/supervisor?tab-language=matlab#wb_supervisor_node_add_force

You have to get a reference to the Solid node, see here:
https://cyberbotics.com/doc/reference/supervisor?tab-language=matlab#wb_supervisor_node_get_from_def

Finally, your code should look something like this:

node_ref = wb_supervisor_node_get_from_def('LLARM_DEF'); % Set DEF for your solid
wb_supervisor_node_add_force(node_ref, [x, y, z], true);