mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-12 06:47:36 +08:00
use shared pointer
This commit is contained in:
committed by
Mathieu Bresciani
parent
00cd720a66
commit
f13f2f8452
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user