mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-07 08:23:56 -04:00
SITL: added RC input from FlightAxis
use the interlink controller for input for 6 channels
This commit is contained in:
parent
3897e03d39
commit
3b0cd9f101
@ -296,6 +296,8 @@ void Aircraft::fill_fdm(struct sitl_fdm &fdm) const
|
||||
fdm.battery_current = battery_current;
|
||||
fdm.rpm1 = rpm1;
|
||||
fdm.rpm2 = rpm2;
|
||||
fdm.rcin_chan_count = rcin_chan_count;
|
||||
memcpy(fdm.rcin, rcin, rcin_chan_count*sizeof(float));
|
||||
}
|
||||
|
||||
uint64_t Aircraft::get_wall_time_us() const
|
||||
|
@ -119,6 +119,8 @@ protected:
|
||||
float battery_current = 0;
|
||||
float rpm1 = 0;
|
||||
float rpm2 = 0;
|
||||
uint8_t rcin_chan_count = 0;
|
||||
float rcin[8];
|
||||
|
||||
uint64_t time_now_us;
|
||||
|
||||
|
@ -66,8 +66,11 @@ void FlightAxis::parse_reply(const char *reply)
|
||||
}
|
||||
p += strlen(keytable[i].key) + 1;
|
||||
keytable[i].ref = atof(p);
|
||||
// this assumes key order
|
||||
reply = p;
|
||||
// this assumes key order and allows us to decode arrays
|
||||
p = strchr(p, '>');
|
||||
if (p != nullptr) {
|
||||
reply = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,6 +299,14 @@ void FlightAxis::update(const struct sitl_input &input)
|
||||
battery_current = state.m_batteryCurrentDraw_AMPS;
|
||||
rpm1 = state.m_propRPM;
|
||||
rpm2 = state.m_heliMainRotorRPM;
|
||||
|
||||
/*
|
||||
the interlink interface doesn't seem to support more than 6 channels
|
||||
*/
|
||||
for (uint8_t i=0; i<6; i++) {
|
||||
rcin[i] = state.rcin[i];
|
||||
}
|
||||
rcin_chan_count = 6;
|
||||
|
||||
update_position();
|
||||
time_now_us = (state.m_currentPhysicsTime_SEC - initial_time_s)*1.0e6;
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
}
|
||||
|
||||
struct state {
|
||||
double rcin[8];
|
||||
double m_airspeed_MPS;
|
||||
double m_altitudeASL_MTR;
|
||||
double m_altitudeAGL_MTR;
|
||||
@ -94,6 +95,14 @@ public:
|
||||
const char *key;
|
||||
double &ref;
|
||||
} keytable[num_keys] = {
|
||||
{ "item", state.rcin[0] },
|
||||
{ "item", state.rcin[1] },
|
||||
{ "item", state.rcin[2] },
|
||||
{ "item", state.rcin[3] },
|
||||
{ "item", state.rcin[4] },
|
||||
{ "item", state.rcin[5] },
|
||||
{ "item", state.rcin[6] },
|
||||
{ "item", state.rcin[7] },
|
||||
{ "m-airspeed-MPS", state.m_airspeed_MPS },
|
||||
{ "m-altitudeASL-MTR", state.m_altitudeASL_MTR },
|
||||
{ "m-altitudeAGL-MTR", state.m_altitudeAGL_MTR },
|
||||
|
@ -23,6 +23,8 @@ struct sitl_fdm {
|
||||
double battery_current; // Amps
|
||||
double rpm1; // main prop RPM
|
||||
double rpm2; // secondary RPM
|
||||
uint8_t rcin_chan_count;
|
||||
float rcin[8]; // RC input 0..1
|
||||
};
|
||||
|
||||
// number of rc output channels
|
||||
|
Loading…
Reference in New Issue
Block a user