Page 1 of 1

Issue of battery sensor in the "DischargeModelTimeMotion" model

Posted: Mon Aug 10, 2020 3:55 pm
by Ryan
Hey, I tried to add the footbot in the loopfunction file. And I tried to set the battery sensor in the model of "DischargeModelTimeMotion". But it seems that the value of TimeLeft has no change. How can I fix it?

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"; }