PX4 Firmware
PX4 Autopilot Software http://px4.io
ReplayEkf2.hpp
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2016-2019 PX4 Development Team. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * 3. Neither the name PX4 nor the names of its contributors may be
16  * used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  ****************************************************************************/
33 
34 #pragma once
35 
36 #include "Replay.hpp"
37 
38 namespace px4
39 {
40 
41 /**
42  * @class ReplayEkf2
43  * replay specialization for Ekf2 replay
44  */
45 class ReplayEkf2 : public Replay
46 {
47 public:
48 protected:
49 
50  void onEnterMainLoop() override;
51  void onExitMainLoop() override;
52 
53  uint64_t handleTopicDelay(uint64_t next_file_time, uint64_t timestamp_offset) override;
54 
55  /**
56  * handle ekf2 topic publication in ekf2 replay mode
57  * @param sub
58  * @param data
59  * @param replay_file file currently replayed (file seek position should be considered arbitrary after this call)
60  * @return true if published, false otherwise
61  */
62  bool handleTopicUpdate(Subscription &sub, void *data, std::ifstream &replay_file) override;
63 
64  void onSubscriptionAdded(Subscription &sub, uint16_t msg_id) override;
65 
66 private:
67 
68  bool publishEkf2Topics(const ekf2_timestamps_s &ekf2_timestamps, std::ifstream &replay_file);
69 
70  /**
71  * find the next message for a subscription that matches a given timestamp and publish it
72  * @param timestamp in 0.1 ms
73  * @param msg_id
74  * @param replay_file file currently replayed (file seek position should be considered arbitrary after this call)
75  * @return true if timestamp found and published
76  */
77  bool findTimestampAndPublish(uint64_t timestamp, uint16_t msg_id, std::ifstream &replay_file);
78 
80 
81  static constexpr uint16_t msg_id_invalid = 0xffff;
82 
91 
92  int _topic_counter = 0;
93 };
94 
95 } //namespace px4
uint16_t _vehicle_visual_odometry_msg_id
Definition: ReplayEkf2.hpp:90
bool findTimestampAndPublish(uint64_t timestamp, uint16_t msg_id, std::ifstream &replay_file)
find the next message for a subscription that matches a given timestamp and publish it ...
Definition: ReplayEkf2.cpp:182
replay specialization for Ekf2 replay
Definition: ReplayEkf2.hpp:45
bool publishEkf2Topics(const ekf2_timestamps_s &ekf2_timestamps, std::ifstream &replay_file)
Definition: ReplayEkf2.cpp:144
Parses an ULog file and replays it in 'real-time'.
Definition: Replay.hpp:58
uint16_t _vehicle_magnetometer_msg_id
Definition: ReplayEkf2.hpp:89
void onEnterMainLoop() override
called when entering the main replay loop
Definition: ReplayEkf2.cpp:213
uint8_t * data
Definition: dataman.cpp:149
bool handleTopicUpdate(Subscription &sub, void *data, std::ifstream &replay_file) override
handle ekf2 topic publication in ekf2 replay mode
Definition: ReplayEkf2.cpp:59
void onExitMainLoop() override
called when exiting the main replay loop
Definition: ReplayEkf2.cpp:219
uint16_t _gps_msg_id
Definition: ReplayEkf2.hpp:85
static constexpr uint16_t msg_id_invalid
Definition: ReplayEkf2.hpp:81
uint16_t _vehicle_air_data_msg_id
Definition: ReplayEkf2.hpp:88
uint16_t _airspeed_msg_id
Definition: ReplayEkf2.hpp:83
int _vehicle_attitude_sub
Definition: ReplayEkf2.hpp:79
uint16_t _optical_flow_msg_id
Definition: ReplayEkf2.hpp:86
uint64_t handleTopicDelay(uint64_t next_file_time, uint64_t timestamp_offset) override
handle delay until topic can be published.
Definition: ReplayEkf2.cpp:249
Definition: bst.cpp:62
void onSubscriptionAdded(Subscription &sub, uint16_t msg_id) override
called when a new subscription is added
Definition: ReplayEkf2.cpp:107
uint16_t _sensor_combined_msg_id
Definition: ReplayEkf2.hpp:87
uint16_t _distance_sensor_msg_id
Definition: ReplayEkf2.hpp:84