Search code examples
webots

Is there any api for setting the initial position and rotation of a specific robot in webots


I'm programming with a robot such as robotis op2.For some reasons, I want to set the initial position and rotation of the robot with the code rather than directly click the scene tree to change the field. Can i change the position (such as (0, 0.5, 0.1)) with any API ?

thanks


Solution

  • You should create a supervisor robot and use the wb_supervisor_field_set_sf_vec3f() function to change the position of the robot. Similarly the rotation can be changed using wb_supervisor_field_set_sf_rotation(). An example of this is provided here.