9 #include <Ivy/ivyloop.h>
12 #include "generated/airframe.h"
21 #include "generated/settings.h"
22 #include "pprzlink/dl_protocol.h"
29 #include NPS_SENSORS_PARAMS
38 static void on_WORLD_ENV(IvyClientPtr app __attribute__((unused)),
39 void *user_data __attribute__((unused)),
40 int argc __attribute__((unused)),
char *argv[]);
43 static void on_DL_SETTING(IvyClientPtr app __attribute__((unused)),
44 void *user_data __attribute__((unused)),
45 int argc __attribute__((unused)),
char *argv[]);
61 const char *agent_name = AIRFRAME_NAME
"_NPS";
62 const char *ready_msg = AIRFRAME_NAME
"_NPS Ready";
63 IvyInit(agent_name, ready_msg, NULL, NULL, NULL, NULL);
66 IvyBindMsg(
on_WORLD_ENV, NULL,
"^(\\S*) WORLD_ENV (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)");
69 IvyBindMsg(
on_DL_SETTING, NULL,
"^(\\S*) DL_SETTING (\\S*) (\\S*) (\\S*)");
72 const char *default_ivy_bus =
"224.255.255.255";
74 const char *default_ivy_bus =
"127.255.255.255";
76 if (ivy_bus == NULL) {
77 IvyStart(default_ivy_bus);
96 void *user_data __attribute__((unused)),
97 int argc __attribute__((unused)),
char *argv[])
101 wind.
x = atof(argv[1]);
102 wind.
y = atof(argv[2]);
103 wind.
z = atof(argv[3]);
133 int pid = (int)getpid();
136 ivyPtr = IvyBindMsg(
on_WORLD_ENV, NULL,
"^%d_%d (\\S*) WORLD_ENV (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)", pid,
seq);
140 memcpy(&fdm_ivy, &
fdm,
sizeof(
struct NpsFdm));
142 IvySendMsg(
"nps %d_%d WORLD_ENV_REQ %f %f %f %f %f %f",
157 static const char ap_launch[] =
"aut_lau";
158 char *ap_settings[NB_SETTING] = SETTINGS_NAMES_SHORT;
163 if (strcmp(ap_settings[
idx],ap_launch) == 0) {
171 void *user_data __attribute__((unused)),
172 int argc __attribute__((unused)),
char *argv[])
174 if (atoi(argv[1]) != AC_ID) {
184 float value = atof(argv[3]);
185 if (!datalink_enabled) {
186 DlSetting(index, value);
189 printf(
"setting %d %f\n", index, value);
208 memcpy (&fdm_ivy, fdm_data,
sizeof(
struct NpsFdm));
211 memcpy (&sensors_ivy, sensors_data,
sizeof(
struct NpsSensors));
213 IvySendMsg(
"%d NPS_RATE_ATTITUDE %f %f %f %f %f %f",
221 IvySendMsg(
"%d NPS_POS_LLH %f %f %f %f %f %f %f %f %f",
232 IvySendMsg(
"%d NPS_SPEED_POS %f %f %f %f %f %f %f %f %f",
243 IvySendMsg(
"%d NPS_GYRO_BIAS %f %f %f",
253 IvySendMsg(
"%d NPS_SENSORS_SCALED %f %f %f %f %f %f",
262 IvySendMsg(
"%d NPS_WIND %f %f %f",