2018-03-07 21:25:44 -04:00
|
|
|
/*
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
simple particle sensor simulation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "SIM_Aircraft.h"
|
|
|
|
|
2018-03-25 23:54:05 -03:00
|
|
|
#include <SITL/SITL.h>
|
|
|
|
|
2018-03-07 21:25:44 -04:00
|
|
|
#include <AP_HAL/utility/RingBuffer.h>
|
|
|
|
|
|
|
|
namespace SITL {
|
|
|
|
|
|
|
|
class Vicon {
|
|
|
|
public:
|
|
|
|
|
|
|
|
Vicon();
|
|
|
|
|
|
|
|
// update state
|
|
|
|
void update(const Location &loc, const Vector3f &position, const Quaternion &attitude);
|
|
|
|
|
|
|
|
// return fd on which data from the device can be read, and data
|
|
|
|
// to the device can be written
|
|
|
|
int fd() { return fd_their_end; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2018-03-25 23:54:05 -03:00
|
|
|
SITL *_sitl;
|
|
|
|
|
2018-03-07 21:25:44 -04:00
|
|
|
// TODO: make these parameters:
|
|
|
|
const uint8_t system_id = 17;
|
|
|
|
const uint8_t component_id = 18;
|
|
|
|
|
|
|
|
// we share channels with the ArduPilot binary!
|
2018-03-31 06:05:23 -03:00
|
|
|
const mavlink_channel_t mavlink_ch = (mavlink_channel_t)(MAVLINK_COMM_0+5);
|
2018-03-07 21:25:44 -04:00
|
|
|
|
|
|
|
int fd_their_end;
|
|
|
|
int fd_my_end;
|
|
|
|
|
2018-05-14 00:53:32 -03:00
|
|
|
uint64_t last_observation_usec;
|
|
|
|
uint64_t time_send_us;
|
|
|
|
uint64_t time_offset_us;
|
|
|
|
mavlink_message_t obs_msg;
|
|
|
|
|
2018-03-07 21:25:44 -04:00
|
|
|
struct obs_elements {
|
|
|
|
uint32_t time_ms; // measurement timestamp (msec)
|
|
|
|
Vector3f position;
|
|
|
|
Quaternion attitude;
|
|
|
|
};
|
|
|
|
|
|
|
|
void update_vicon_position_estimate(const Location &loc,
|
|
|
|
const Vector3f &position,
|
|
|
|
const Quaternion &attitude);
|
|
|
|
|
|
|
|
void maybe_send_heartbeat();
|
|
|
|
uint32_t last_heartbeat_ms;
|
|
|
|
|
2018-03-25 23:54:05 -03:00
|
|
|
bool init_sitl_pointer();
|
2018-03-07 21:25:44 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|