I have been experimenting with different fitness functions for my Webots robot simulation (in short: I'm using genetic algorithm to evolve interesting behaviour).

The idea I have now is to reward/punish Aibo based on its speed of movement. The movement is performed by setting new joint position, and currently it results in jerky random movements. I have been looking at the nodes available in Webots, but apart from GPS node (which is not available in Aibo) I couldn't find anything relevant.

What I want to achieve is to measure the distance from previous location to current location after each movement. How can I do this?


2 Answers 2


Some years ago I have used the supervisor to know the position of a simulated Khepera robot in Webots 4. The main components of the C code was the following:


  #define STEP 64

  NodeRef robot_node;
  float robot_data[4]={0,0,0,0};

Getting the node named Khepera:


Getting data from the node in every STEP milliseconds:


All the above was called before the main cycle of the supervisor. The main cycle contained a robot_step(STEP); call to let the system fill the elements of the robot data structure (x,y,z,head coordinates) regularly.

Again it was Webots 4 may be there are better ways in Webots 7 to fulfill the task but it could be a starting point.

  • $\begingroup$ I don't think this has changed much since version 4. I'm programming in Java so method names are a little different, but retrieving translation via supervisor looks very similar. Thank you! $\endgroup$ Commented Feb 11, 2013 at 8:42

I went to the source (Cyberbotics) and got these 2 solutions:

  • Aibo has no GPS. And it's not straight forward to add it, because its node hierachy is hidden behind the prototype mechanism. The definition of the Aibo if however open-source: $WEBOTS/resources/projects/robots/aibo/protos/Aibo_ERS7.proto GPS can be added to the project (into the protos path) and modified as we wish. Adding GPS is as simple as adding a GPS node inside the direct children of the Robot node.

  • A supervisor allows to query the scene tree. This includes getting the position of the Aibo. This solution is clearer. The following example shows a supervisor retrieving information from the scene tree: $WEBOTS/projects/samples/devices/worlds/supervisor.wbt

  • $\begingroup$ This post refers to an older Webots version, but in newer version of Webots it is now simpler to add a GPS to a the Aibo robot. For example there are now these two different options: 1. the AiboErs7 PROTO model has two fields (named headSlot and extensionSlot) specifically meant to extend the base model with new devices. 2. from the context menu, that appears right clicking on the robot, it is possible to expand the PROTO node and convert it to base nodes (using the options "Convert Root to Base Node(s).." or "Convert to Base Node(s)..") $\endgroup$ Commented Dec 12, 2022 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.