Browse Source

AP_IRLock_SITL: correct packet timestamp

mission-4.1.18
Pierre Kancir 8 years ago committed by Francisco Ferreira
parent
commit
83c7217911
  1. 11
      libraries/AP_IRLock/AP_IRLock_SITL.cpp
  2. 2
      libraries/AP_IRLock/AP_IRLock_SITL.h

11
libraries/AP_IRLock/AP_IRLock_SITL.cpp

@ -62,19 +62,18 @@ bool AP_IRLock_SITL::update() @@ -62,19 +62,18 @@ bool AP_IRLock_SITL::update()
// receive packet from Gazebo IRLock plugin
irlock_packet pkt;
const int wait_ms = 0;
size_t s = sock.recv(&pkt, sizeof(irlock_packet), wait_ms);
ssize_t s = sock.recv(&pkt, sizeof(irlock_packet), wait_ms);
bool new_data = false;
// fprintf(stderr, "sitl %d %d\n", i, _num_targets);
if (s == sizeof(irlock_packet) && pkt.timestamp/1000 > _last_timestamp) {
if (s == sizeof(irlock_packet) && pkt.timestamp > _last_timestamp) {
// fprintf(stderr, " posx %f posy %f sizex %f sizey %f\n", pkt.pos_x, pkt.pos_y, pkt.size_x, pkt.size_y);
_target_info.timestamp = pkt.timestamp / 1000;
_target_info.timestamp = pkt.timestamp;
_target_info.pos_x = pkt.pos_x;
_target_info.pos_y = pkt.pos_y;
_target_info.size_x = pkt.size_x;
_target_info.size_y = pkt.size_y;
_last_timestamp = pkt.timestamp/1000;
_last_timestamp = pkt.timestamp;
_last_update_ms = _last_timestamp;
new_data = true;
}

2
libraries/AP_IRLock/AP_IRLock_SITL.h

@ -27,7 +27,7 @@ private: @@ -27,7 +27,7 @@ private:
reply packet sent from simulator to ArduPilot
*/
struct irlock_packet {
uint64_t timestamp;
uint64_t timestamp; // in miliseconds
uint16_t num_targets;
float pos_x;
float pos_y;

Loading…
Cancel
Save