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>
19 static CRange<Real> UNIT(0.0f, 1.0f);
25 m_pcEmbodiedEntity(nullptr),
26 m_pcBatteryEntity(nullptr),
88 if(
Abs(fDiff) > 1e-6) {
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",
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
float Real
Collects all ARGoS code.
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.
REGISTER_SENSOR(CEPuckProximityDefaultSensor, "epuck_proximity", "default", "Danesh Tarapore [daneshtarapore@gmail.com]", "1.0", "The E-Puck proximity sensor.", "This sensor accesses the epuck proximity sensor. For a complete description\n" "of its usage, refer to the ci_epuck_proximity_sensor.h interface. For the XML\n" "configuration, refer to the default proximity sensor.\n", "Usable")
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.
void Enable()
Enables the entity.
static Real GetSimulationClockTick()
Returns the simulation clock tick.
The exception that wraps all errors in ARGoS.
void TruncValue(T &t_value) const
static CRNG * CreateRNG(const std::string &str_category)
Creates a new RNG inside the given category.
CRadians Uniform(const CRange< CRadians > &c_range)
Returns a random value from a uniform distribution.
Real AvailableCharge
Available charge, between 0 and 1.
Real TimeLeft
Time left in seconds.
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.
Real GetFullCharge() const
Real GetAvailableCharge() const