use shared pointer

This commit is contained in:
kamilritz
2019-12-16 09:04:35 +01:00
committed by Mathieu Bresciani
parent 00cd720a66
commit f13f2f8452
14 changed files with 78 additions and 49 deletions
+6 -5
View File
@@ -40,6 +40,7 @@
#include "EKF/ekf.h"
#include <math.h>
#include <memory>
namespace sensor_simulator
{
@@ -48,14 +49,14 @@ class Sensor
{
public:
Sensor(Ekf* ekf);
Sensor(std::shared_ptr<Ekf> ekf);
virtual ~Sensor();
void update(uint32_t time);
void setRate(uint32_t rate){ _update_period = uint32_t(1000000)/rate; }
bool isRunning(){ return _is_running; }
bool isRunning() const { return _is_running; }
void start(){ _is_running = true; }
@@ -63,17 +64,17 @@ public:
protected:
Ekf* _ekf;
std::shared_ptr<Ekf> _ekf;
// time in microseconds
uint32_t _update_period;
uint32_t _time_last_data_sent{0};
bool _is_running{false};
bool should_send(uint32_t time);
bool should_send(uint32_t time) const;
// Checks that the right amount time passed since last send data to fulfill rate
bool is_time_to_send(uint32_t time);
bool is_time_to_send(uint32_t time) const;
// call set*Data function of Ekf
virtual void send(uint32_t time) = 0;