Simulator: refactored mavlink additions

QuRT does not support UDP so moved the mavlink specific code
to a new file that is not built for the qurt target

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2015-05-11 19:25:11 -07:00
parent 2f434eb395
commit d0bf4ab449
4 changed files with 384 additions and 354 deletions
+18 -23
View File
@@ -51,8 +51,8 @@
#include <uORB/uORB.h>
#include <v1.0/mavlink_types.h>
#include <v1.0/common/mavlink.h>
#include <sys/socket.h>
#ifndef __PX4_QURT
#include <sys/socket.h>
#include <netinet/in.h>
#endif
@@ -165,18 +165,18 @@ private:
_accel(1),
_mpu(1),
_baro(1),
_sensor_combined_pub(-1),
_sensor_combined_pub(-1)
#ifndef __PX4_QURT
,
_manual_control_sp_pub(-1),
_actuator_outputs_sub(-1),
_vehicle_attitude_sub(-1),
_sensor{},
_manual_control_sp{},
_actuators{},
_attitude{},
_interval(1000)
{
_buf = new unsigned char [_buflen];
}
_attitude{}
#endif
{}
~Simulator() { _instance=NULL; }
#ifndef __PX4_QURT
@@ -196,6 +196,12 @@ private:
orb_advert_t _gyro_pub;
orb_advert_t _mag_pub;
orb_advert_t _sensor_combined_pub;
// class methods
void publishSensorsCombined();
#ifndef __PX4_QURT
// uORB publisher handlers
orb_advert_t _manual_control_sp_pub;
// uORB subscription handlers
@@ -208,29 +214,18 @@ private:
struct actuator_outputs_s _actuators;
struct vehicle_attitude_s _attitude;
// udp socket data
struct sockaddr_in _myaddr;
int _fd;
unsigned char _buf[200];
hrt_abstime _time_last;
struct sockaddr_in _srcaddr;
socklen_t _addrlen = sizeof(_srcaddr);
int _fd;
const int _buflen = 200;
const int _port = 14550;
unsigned char *_buf;
hrt_abstime _time_last;
int _interval;
// class methods
int setup_udp_socket();
void do_subscriptions();
void poll_topics();
void publishSensorsCombined();
void fill_sensors_from_imu_msg(struct sensor_combined_s *sensor, mavlink_highres_imu_t *imu);
void fill_manual_control_sp_msg(struct manual_control_setpoint_s *manual, mavlink_manual_control_t *man_msg);
void handle_message(mavlink_message_t *msg);
void send_data();
void send_mavlink_message(const uint8_t msgid, const void *msg, uint8_t component_ID);
void pack_actuator_message(mavlink_message_t *msg);
void send_mavlink_message(const uint8_t msgid, const void *msg, uint8_t component_ID);
static void *sending_trampoline(void *);
void send();
#endif
};