Replies: 1 comment 2 replies
-
There are different functions depending whether this information must be accessed in a normal controller, in a Supervisor controller or in a physics plugin. All the functions described below will return the 3D position in meters and expressed in the global (world) coordinate system. Clearly, the position of a robot can also be approximated by using odometry or SLAM techniques. This is usually more realistic because most robots don't have a GPS and therefore have no mean of precisely determining their position. You will find more info about odometry and SLAM techniques in Cyberbotics' Robot Curriculum. Get Position in Controller CodeTo get the position of a robot in the robot's controller code: add a GPS node to the robot, then use the wb_robot_get_device, wb_gps_enable and wb_gps_get_values functions. Note that the GPS's resolution field must be 0 (the default), otherwise the results will be noisy. You will find more info about the GPS node and functions in the Reference Manual. Note that the GPS can also be placed on a robot's part (arm, foot, etc.) to get the world/global coordinates of that particular part. Get Position in Supervisor Code
A simulation example that shows both the GPS and the Supervisor APIs techniques is included in the Webots installation, you just need to open this world: "WEBOTS_HOME/projects/samples/devices/worlds/gps.wbt". Get Position in Physics Plugin CodeIn the physics plugin you can use ODE's dBodyGetPosition function. Note that this function returns the position of the center of mass of the body: this may be different from the center of the Solid. Please find a description of ODE functions here. |
Beta Was this translation helpful? Give feedback.
-
I need to get programmatically the position of a robot or an object in Webots.
How can I achieve that?
Beta Was this translation helpful? Give feedback.
All reactions