7#include <argos3/core/simulator/simulator.h>
8#include <argos3/core/simulator/entity/embodied_entity.h>
9#include <argos3/core/simulator/entity/composable_entity.h>
10#include <argos3/plugins/simulator/entities/battery_equipped_entity.h>
88 if(
Abs(fDiff) > 1e-6) {
95 m_sReading.TimeLeft = std::numeric_limits<Real>::infinity();
114 "battery",
"default",
115 "Adhavan Jayabalan [jadhu94@gmail.com]",
117 "A generic battery level sensor.",
119 "This sensor returns the current battery level of a robot. This sensor\n"
120 "can be used with any robot, since it accesses only the body component. In\n"
121 "controllers, you must include the ci_battery_sensor.h header.\n\n"
123 "This sensor is enabled by default.\n\n"
125 "REQUIRED XML CONFIGURATION\n\n"
128 " <my_controller ...>\n"
132 " <battery implementation=\"default\" />\n"
136 " </my_controller>\n"
138 " </controllers>\n\n"
140 "OPTIONAL XML CONFIGURATION\n\n"
142 "It is possible to add uniform noise to the sensor, thus matching the\n"
143 "characteristics of a real robot better. You can add noise through the\n"
144 "attribute 'noise_range' as follows:\n\n"
147 " <my_controller ...>\n"
151 " <battery implementation=\"default\"\n"
152 " noise_range=\"-0.3:0.4\" />\n"
156 " </my_controller>\n"
158 " </controllers>\n\n",
float Real
Collects all ARGoS code.
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
#define REGISTER_SENSOR(CLASSNAME, LABEL, IMPLEMENTATION, AUTHOR, VERSION, BRIEF_DESCRIPTION, LONG_DESCRIPTION, STATUS)
Registers a new sensor model inside ARGoS.
The namespace containing all the ARGoS related code.
void GetNodeAttributeOrDefault(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer, const T &t_default)
Returns the value of a node's attribute, or the passed default value.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
T Abs(const T &t_v)
Returns the absolute value of the passed argument.
virtual void Enable()
Enables updating of sensor information in the event loop.
virtual void Init(TConfigurationNode &t_node)
Initializes the sensor from the XML configuration tree.
Basic class for an entity that contains other entities.
CEntity & GetComponent(const std::string &str_component)
Returns the component with the passed string label.
This entity is a link to a body in the physics engine.
static Real GetSimulationClockTick()
Returns the simulation clock tick.
The exception that wraps all errors in ARGoS.
static CRNG * CreateRNG(const std::string &str_category)
Creates a new RNG inside the given category.
CBatteryEquippedEntity * m_pcBatteryEntity
Reference to battery sensor equipped entity associated to this sensor.
virtual void Reset()
Resets the sensor to the state it had just after Init().
virtual void Init(TConfigurationNode &t_tree)
Initializes the sensor from the XML configuration tree.
CRange< Real > m_cNoiseRange
Noise range on battery level.
CEmbodiedEntity * m_pcEmbodiedEntity
Reference to embodied entity associated to this sensor.
bool m_bAddNoise
Whether to add noise or not.
CRandom::CRNG * m_pcRNG
Random number generator.
virtual void SetRobot(CComposableEntity &c_entity)
Sets the entity associated to this sensor.
virtual void Update()
Updates the state of the entity associated to this sensor, if the sensor is currently enabled.