9 #include <Ivy/ivyloop.h>
12 #include "generated/airframe.h"
21 #include "generated/settings.h"
22 #include "pprzlink/dl_protocol.h"
37 static void on_WORLD_ENV(IvyClientPtr app __attribute__((unused)),
38 void *user_data __attribute__((unused)),
39 int argc,
char *argv[]);
42 static void on_DL_SETTING(IvyClientPtr app __attribute__((unused)),
43 void *user_data __attribute__((unused)),
44 int argc,
char *argv[]);
60 const char *agent_name = AIRFRAME_NAME
"_NPS";
61 const char *ready_msg = AIRFRAME_NAME
"_NPS Ready";
62 IvyInit(agent_name, ready_msg, NULL, NULL, NULL, NULL);
65 IvyBindMsg(
on_WORLD_ENV, NULL,
"^(\\S*) WORLD_ENV (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)");
68 IvyBindMsg(
on_DL_SETTING, NULL,
"^(\\S*) DL_SETTING (\\S*) (\\S*) (\\S*)");
71 const char *default_ivy_bus =
"224.255.255.255";
73 const char *default_ivy_bus =
"127.255.255.255";
75 if (ivy_bus == NULL) {
76 IvyStart(default_ivy_bus);
95 void *user_data __attribute__((unused)),
96 int argc,
char *argv[])
98 if (argc < 6) {
return; }
102 wind.
x = atof(argv[1]);
103 wind.
y = atof(argv[2]);
104 wind.
z = atof(argv[3]);
137 int pid = (int)getpid();
140 ivyPtr = IvyBindMsg(
on_WORLD_ENV, NULL,
"^%d_%d (\\S*) WORLD_ENV (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)", pid,
seq);
144 memcpy(&fdm_ivy, &
fdm,
sizeof(
struct NpsFdm));
146 IvySendMsg(
"nps %d_%d WORLD_ENV_REQ %f %f %f %f %f %f",
164 return AP_LAUNCH - 1;
167 static const char ap_launch[] =
"aut_lau";
168 char *ap_settings[NB_SETTING] = SETTINGS_NAMES_SHORT;
173 if (strcmp(ap_settings[
idx],ap_launch) == 0) {
183 void *user_data __attribute__((unused)),
184 int argc,
char *argv[])
186 if (argc < 3) {
return; }
188 if (atoi(argv[1]) != AC_ID) {
198 float value = atof(argv[3]);
200 if (!datalink_enabled) {
201 DlSetting(index, value);
205 printf(
"setting %d %f\n", index, value);
228 memcpy(&fdm_ivy, fdm_data,
sizeof(
fdm));
229 memcpy(&sensors_ivy, sensors_data,
sizeof(
sensors));
235 IvySendMsg(
"%d NPS_RATE_ATTITUDE %f %f %f %f %f %f",
243 IvySendMsg(
"%d NPS_POS_LLH %f %f %f %f %f %f %f %f %f",
254 IvySendMsg(
"%d NPS_SPEED_POS %f %f %f %f %f %f %f %f %f",
265 IvySendMsg(
"%d NPS_GYRO_BIAS %f %f %f",
275 IvySendMsg(
"%d NPS_SENSORS_SCALED %f %f %f %f %f %f",
284 IvySendMsg(
"%d NPS_WIND %f %f %f",
Common code for AP and FBW telemetry.
Device independent GPS code (interface)
void double_quat_vmult(struct DoubleVect3 *v_out, struct DoubleQuat *q, struct DoubleVect3 *v_in)
#define RATE_FLOAT_OF_BFP(_ai)
double alt
in meters above WGS84 reference ellipsoid
void nps_atmosphere_set_wind_ned(double wind_north, double wind_east, double wind_down)
Atmosphere model (pressure, wind) for NPS.
struct NedCoor_d ltpprz_ecef_vel
velocity in ltppprz frame, wrt ECEF frame
struct NedCoor_d ltpprz_pos
struct LlaCoor_d lla_pos_pprz
struct NedCoor_d ltpprz_ecef_accel
accel in ltppprz frame, wrt ECEF frame
struct DoubleEulers ltp_to_body_eulers
struct DoubleQuat ltp_to_body_quat
struct DoubleRates body_ecef_rotvel
struct LlaCoor_d lla_pos_geoc
struct DoubleVect3 wind
velocity in m/s in NED
struct NpsFdm fdm
Holds all necessary NPS FDM state information.
struct LlaCoor_d lla_pos_geod
void * ivy_main_loop(void *data)
static pthread_mutex_t ivy_mutex
static void on_DL_SETTING(IvyClientPtr app, void *user_data, int argc, char *argv[])
void nps_ivy_send_WORLD_ENV_REQ(void)
static void on_WORLD_ENV(IvyClientPtr app, void *user_data, int argc, char *argv[])
bool nps_ivy_send_world_env
static int ap_launch_index
void nps_ivy_display(struct NpsFdm *fdm_data, struct NpsSensors *sensors_data)
void nps_ivy_init(char *ivy_bus)
int find_launch_index(void)
void nps_update_launch_from_dl(uint8_t value)
void nps_set_time_factor(float time_factor)
pthread_mutex_t fdm_mutex
struct DoubleVect3 neutral
struct DoubleVect3 bias_random_walk_value
struct DoubleVect3 bias_initial
struct NpsSensorGyro gyro
struct NpsSensorAccel accel
Paparazzi double precision floating point algebra.
Paparazzi floating point algebra.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.