Skip to content

Battery Model Tutorial

acschang edited this page Jul 20, 2020 · 4 revisions

Batteries are modeled as a linear countdown. The countdown for the UGVs (X1 & X2) is 90 minutes of simulation time, and 20 minutes for the UAVs (X3 & X4). Once the countdown reaches zero, a robot will no longer be able to move.

Batteries will drain at a constant rate (power_load) while the vehicle's joints are actuated.

  • In the case of a UGV, battery depletion will only occur when a command is applied on the cmd_vel topic.
  • In the case of a UAV, constant battery depletion will begin after the UAV velocity controller is activated by publishing a velocity command on the cmd_vel topic.
    • To stop battery depletion of the UAV, stop sending commands to cmd_vel then disable the UAV velocity controller by publishing False to the velocity_controller/enable topic. Disabling the UAV velocity controller will halt the vehicle's rotors so ensure the UAV is landed before disabling the controller.
    • To reactivate the velocity controller controller, publish True on the velocity_controller/enable topic. Battery depletion will not resume until a new velocity command is published on the cmd_vel topic.

The current battery state for each robot can be obtained through topic <robot name>/battery_state, which publishes sensor_msgs/BatteryState. Message fields to keep an eye on:

  • power_supply_status, which can be:
    • 4 for POWER_SUPPLY_STATUS_FULL, while it hasn't started discharging
    • 2 for POWER_SUPPLY_STATUS_DISCHARGING, while it is discharging
  • percentage, which goes from 1.0 (full) to 0.0 (empty)

To tune the battery_plugin module to have a specific amount of battery life, start with parameters of a battery_plugin with a known amount of battery life (i.e. X1/X2 parameters for 90 minutes or X3/X4 for 20 minutes) then adjust the power_load parameter.

  • To tune the battery_plugin module from the X1/X2 to have 60 minutes of battery life one would adjust the power_load parameter as follows:
    • The default for power_load is 6.6 for 90 minutes. 90 minutes/60 minutes * 6.6 = 9.9 for the power_load parameter to reach 60 minutes of battery life.