In the loop function file:
Code: Select all
void CLoopFunctions::Init(TConfigurationNode& t_node) {
/*
* Create the foot-bot and get a reference to its battery
*/
m_pcFootBot = new CFootBotEntity(
"fb", // entity id
"fdc" // controller id as set in the XML
);
AddEntity(*m_pcFootBot);
m_pcBattery = &dynamic_cast<CBatteryEquippedEntity&>(m_pcFootBot->GetBatterySensorEquippedEntity());
// m_pcDischargeModelMotion = new CBatteryDischargeModelMotion();
// m_pcDischargeModelTime = new CBatteryDischargeModelTime();
m_pcDischargeModelTimeMotion = new CBatteryDischargeModelTimeMotion();
m_pcDischargeModelTimeMotion->SetBattery(m_pcBattery);
m_pcDischargeModelTimeMotion->SetDelta(0.01);
m_pcDischargeModelTimeMotion->SetPosFactor(0.3);
m_pcDischargeModelTimeMotion->SetOrientFactor(0.2);
m_pcDischargeModelTimeMotion->operator()();
m_pcBattery->SetAvailableCharge(0.01);
}
In the controller file:
Code: Select all
void Init(TConfigurationNode& t_node){
m_pcBattery = GetSensor <CBatteryDefaultSensor >("battery");
m_pcBattery->Update();
}
void ControlStep()
{
const CCI_BatterySensor::SReading & tBatteryReads = m_pcBattery->GetReading();
Real timeleft = tBatteryReads.AvailableCharge;
std::cout<<" TimeLeft:" << timeleft <<"\n";
}