You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
0 B
34 lines
0 B
5 years ago
|
#include "sensor.h"
|
||
|
|
||
|
namespace sensor_simulator
|
||
|
{
|
||
5 years ago
|
|
||
|
Sensor::Sensor(Ekf* ekf)
|
||
|
{
|
||
|
_ekf = ekf;
|
||
|
}
|
||
|
|
||
|
Sensor::~Sensor()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void Sensor::update(uint32_t time)
|
||
|
{
|
||
|
if(should_send(time))
|
||
|
{
|
||
|
send(time);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
bool Sensor::should_send(uint32_t time)
|
||
|
{
|
||
|
return _is_running && is_time_to_send(time);
|
||
|
}
|
||
|
|
||
|
bool Sensor::is_time_to_send(uint32_t time)
|
||
|
{
|
||
|
return (time >= _time_last_data_sent) && ((time - _time_last_data_sent) >= _update_period);
|
||
|
}
|
||
5 years ago
|
|
||
|
} // namespace sensor_simulator
|