Energy consumption webots motor

253 views Asked by At

i´m using webots and i have a robot. The point is that i want to see consumption's motors of the robot. I have seen this in documentation webots https://cyberbotics.com/doc/reference/motor#energy-consumption. I have actived this note, battery, and i have tried to see it like another field, for example position. But battery field always is 0. I dont know what I try next. I think the documents is a little poor.

In fact, I didnt have succes implementing this. Anyone know how to do this?

Thank you

1

There are 1 answers

2
David Mansolino On

The first thing to do is to sepcify 3 components in the 'battery' field of your robot node:

this field should contain three values: the first one corresponds to the present energy level of the robot in Joules (J), the second is the maximum energy the robot can hold in Joules, and the third is the energy recharge speed in Watts ([W]=[J]/[s])

https://cyberbotics.com/doc/reference/robot#field-summary

Then from the controller, you should use the robot/battery API to enable the sensors and retrieve the battery state:

These functions allow you to measure the present energy level of the robot battery. First, it is necessary to enable battery sensor measurements by calling the wb_robot_battery_sensor_enable function. The sampling_period parameter is expressed in milliseconds and defines how frequently measurements are performed. After the battery sensor is enabled a value can be read from it by calling the wb_robot_battery_sensor_get_value function. The returned value corresponds to the present energy level of the battery expressed in Joules (J), if the battery field is empty, this function will return -1.0.

https://cyberbotics.com/doc/reference/robot#wb_robot_battery_sensor_enable

You can find an example of battery simulation available directly by default in Webots:

https://www.cyberbotics.com/doc/guide/samples-devices#battery-wbt