Paparazzi UAS  v5.12_stable-4-g9b43e9b
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
nps_fdm_gazebo.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Tom van Dijk
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
29 // The transition from Gazebo 7 to 8 deprecates a large number of functions.
30 // Ignore these errors for now...
31 #pragma GCC diagnostic push
32 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
33 
34 #include <cstdio>
35 #include <cstdlib>
36 #include <string>
37 #include <iostream>
38 
39 #include <gazebo/gazebo.hh>
40 #include <gazebo/common/common.hh>
41 #include <gazebo/physics/physics.hh>
42 #include <gazebo/sensors/sensors.hh>
43 #include <gazebo/gazebo_config.h>
44 
45 extern "C" {
46 #include <sys/time.h>
47 
48 #include "nps_fdm.h"
50 
51 #include "generated/airframe.h"
52 #include "autopilot.h"
53 
54 #ifdef NPS_SIMULATE_VIDEO
58 #include "mcu_periph/sys_time.h"
59 #endif
60 }
61 
62 using namespace std;
63 
64 #ifndef NPS_GAZEBO_WORLD
65 #define NPS_GAZEBO_WORLD "ardrone.world"
66 #endif
67 #ifndef NPS_GAZEBO_AC_NAME
68 #define NPS_GAZEBO_AC_NAME "paparazzi_uav"
69 #endif
70 
71 // Add video handling functions if req'd.
72 #ifdef NPS_SIMULATE_VIDEO
73 static void init_gazebo_video(void);
74 static void gazebo_read_video(void);
75 static void read_image(
76  struct image_t *img,
77  gazebo::sensors::CameraSensorPtr cam);
78 struct gazebocam_t {
79  gazebo::sensors::CameraSensorPtr cam;
80  gazebo::common::Time last_measurement_time;
81 };
82 static struct gazebocam_t gazebo_cams[VIDEO_THREAD_MAX_CAMERAS] =
83 { { NULL, 0 } };
84 #endif
85 
87 struct NpsFdm fdm;
88 
89 // Pointer to Gazebo data
90 static bool gazebo_initialized = false;
91 static gazebo::physics::ModelPtr model = NULL;
92 
93 // Helper functions
94 static void init_gazebo(void);
95 static void gazebo_read(void);
96 static void gazebo_write(double commands[], int commands_nb);
97 
98 // Conversion routines
99 inline struct EcefCoor_d to_pprz_ecef(ignition::math::Vector3d ecef_i)
100 {
101  struct EcefCoor_d ecef_p;
102  ecef_p.x = ecef_i.X();
103  ecef_p.y = ecef_i.Y();
104  ecef_p.z = ecef_i.Z();
105  return ecef_p;
106 }
107 
108 inline struct NedCoor_d to_pprz_ned(ignition::math::Vector3d global)
109 {
110  struct NedCoor_d ned;
111  ned.x = global.Y();
112  ned.y = global.X();
113  ned.z = -global.Z();
114  return ned;
115 }
116 
117 inline struct LlaCoor_d to_pprz_lla(ignition::math::Vector3d lla_i)
118 {
119  struct LlaCoor_d lla_p;
120  lla_p.lat = lla_i.X();
121  lla_p.lon = lla_i.Y();
122  lla_p.alt = lla_i.Z();
123  return lla_p;
124 }
125 
126 inline struct DoubleVect3 to_pprz_body(gazebo::math::Vector3 body_g)
127 {
128  struct DoubleVect3 body_p;
129  body_p.x = body_g.x;
130  body_p.y = -body_g.y;
131  body_p.z = -body_g.z;
132  return body_p;
133 }
134 
135 inline struct DoubleRates to_pprz_rates(gazebo::math::Vector3 body_g)
136 {
137  struct DoubleRates body_p;
138  body_p.p = body_g.x;
139  body_p.q = -body_g.y;
140  body_p.r = -body_g.z;
141  return body_p;
142 }
143 
144 inline struct DoubleEulers to_pprz_eulers(gazebo::math::Quaternion quat)
145 {
146  struct DoubleEulers eulers;
147  eulers.psi = -quat.GetYaw() - M_PI / 2;
148  eulers.theta = -quat.GetPitch();
149  eulers.phi = quat.GetRoll();
150  return eulers;
151 }
152 
153 inline struct DoubleVect3 to_pprz_ltp(gazebo::math::Vector3 xyz)
154 {
155  struct DoubleVect3 ltp;
156  ltp.x = xyz.y;
157  ltp.y = xyz.x;
158  ltp.z = -xyz.z;
159  return ltp;
160 }
161 
162 // External functions, interface with Paparazzi's NPS as declared in nps_fdm.h
163 
168 void nps_fdm_init(double dt)
169 {
170  fdm.init_dt = dt; // JSBsim specific
171  fdm.curr_dt = dt; // JSBsim specific
172  fdm.nan_count = 0; // JSBsim specific
173 }
174 
182  bool launch __attribute__((unused)),
183  double *commands,
184  int commands_nb)
185 {
186  // Initialize Gazebo if req'd.
187  // Initialization is peformed here instead of in nps_fdm_init because:
188  // - Video devices need to added at this point. Video devices have not been
189  // added yet when nps_fdm_init is called.
190  // - nps_fdm_init runs on a different thread then nps_fdm_run_step, which
191  // causes problems with Gazebo.
192  if (!gazebo_initialized) {
193  init_gazebo();
194  gazebo_read();
195 #ifdef NPS_SIMULATE_VIDEO
196  init_gazebo_video();
197 #endif
198  gazebo_initialized = true;
199  }
200 
201  // Update the simulation for a single timestep.
202  gazebo::runWorld(model->GetWorld(), 1);
203  gazebo::sensors::run_once();
204  gazebo_write(commands, commands_nb);
205  gazebo_read();
206 #ifdef NPS_SIMULATE_VIDEO
207  gazebo_read_video();
208 #endif
209 }
210 
211 // TODO Atmosphere functions have not been implemented yet.
212 // Starting at version 8, Gazebo has its own atmosphere and wind model.
214  double speed __attribute__((unused)),
215  double dir __attribute__((unused)))
216 {
217 }
218 
220  double wind_north __attribute__((unused)),
221  double wind_east __attribute__((unused)),
222  double wind_down __attribute__((unused)))
223 {
224 }
225 
227  double wind_speed __attribute__((unused)),
228  int turbulence_severity __attribute__((unused)))
229 {
230 }
231 
234  double temp __attribute__((unused)),
235  double h __attribute__((unused)))
236 {
237 }
238 
239 // Internal functions
251 static void init_gazebo(void)
252 {
253  string gazebo_home = "/conf/simulator/gazebo/";
254  string pprz_home(getenv("PAPARAZZI_HOME"));
255  string gazebodir = pprz_home + gazebo_home;
256  cout << "Gazebo directory: " << gazebodir << endl;
257 
258  if (!gazebo::setupServer(0, NULL)) {
259  cout << "Failed to start Gazebo, exiting." << endl;
260  std::exit(-1);
261  }
262 
263  cout << "Add Paparazzi model path: " << gazebodir + "models/" << endl;
264  gazebo::common::SystemPaths::Instance()->AddModelPaths(
265  gazebodir + "models/");
266 
267  cout << "Load world: " << gazebodir + "world/" + NPS_GAZEBO_WORLD << endl;
268  gazebo::physics::WorldPtr world = gazebo::loadWorld(
269  gazebodir + "world/" + NPS_GAZEBO_WORLD);
270  if (!world) {
271  cout << "Failed to open world, exiting." << endl;
272  std::exit(-1);
273  }
274 
275  cout << "Get pointer to aircraft: " << NPS_GAZEBO_AC_NAME << endl;
276  model = world->GetModel(NPS_GAZEBO_AC_NAME);
277  if (!model) {
278  cout << "Failed to find '" << NPS_GAZEBO_AC_NAME << "', exiting."
279  << endl;
280  std::exit(-1);
281  }
282 
283  // Initialize sensors
284  gazebo::sensors::run_once(true);
285  gazebo::sensors::run_threads();
286  gazebo::runWorld(world, 1);
287  cout << "Sensors initialized..." << endl;
288 
289  cout << "Gazebo initialized successfully!" << endl;
290 }
291 
300 static void gazebo_read(void)
301 {
302  gazebo::physics::WorldPtr world = model->GetWorld();
303  gazebo::math::Pose pose = model->GetWorldPose(); // In LOCAL xyz frame
304  gazebo::math::Vector3 vel = model->GetWorldLinearVel();
305  gazebo::math::Vector3 accel = model->GetWorldLinearAccel();
306  gazebo::math::Vector3 ang_vel = model->GetWorldAngularVel();
307  gazebo::common::SphericalCoordinatesPtr sphere =
308  world->GetSphericalCoordinates();
309  gazebo::math::Quaternion local_to_global_quat(0, 0,
310  -sphere->HeadingOffset().Radian());
311 
312  /* Fill FDM struct */
313  fdm.time = world->GetSimTime().Double();
314 
315  // init_dt: unused
316  // curr_dt: unused
317  // on_ground: unused
318  // nan_count: unused
319 
320  /* position */
322  sphere->PositionTransform(pose.pos.Ign(),
323  gazebo::common::SphericalCoordinates::LOCAL,
324  gazebo::common::SphericalCoordinates::ECEF));
326  sphere->PositionTransform(pose.pos.Ign(),
327  gazebo::common::SphericalCoordinates::LOCAL,
328  gazebo::common::SphericalCoordinates::GLOBAL));
330  sphere->PositionTransform(pose.pos.Ign(),
331  gazebo::common::SphericalCoordinates::LOCAL,
332  gazebo::common::SphericalCoordinates::SPHERICAL));
333  fdm.hmsl = pose.pos.z;
334  /* debug positions */
335  fdm.lla_pos_pprz = fdm.lla_pos; // Don't really care...
338  fdm.agl = pose.pos.z; // TODO Measure with sensor
339 
340  /* velocity */
342  sphere->VelocityTransform(vel.Ign(),
343  gazebo::common::SphericalCoordinates::LOCAL,
344  gazebo::common::SphericalCoordinates::ECEF));
345  fdm.body_ecef_vel = to_pprz_body(pose.rot.RotateVectorReverse(vel)); // Note: unused
347  sphere->VelocityTransform(vel.Ign(),
348  gazebo::common::SphericalCoordinates::LOCAL,
349  gazebo::common::SphericalCoordinates::GLOBAL));
351 
352  /* acceleration */
354  sphere->VelocityTransform(accel.Ign(),
355  gazebo::common::SphericalCoordinates::LOCAL,
356  gazebo::common::SphericalCoordinates::ECEF)); // Note: unused
357  fdm.body_ecef_accel = to_pprz_body(pose.rot.RotateVectorReverse(accel));
359  sphere->VelocityTransform(accel.Ign(),
360  gazebo::common::SphericalCoordinates::LOCAL,
361  gazebo::common::SphericalCoordinates::GLOBAL)); // Note: unused
363  fdm.body_inertial_accel = fdm.body_ecef_accel; // Approximate, unused.
365  pose.rot.RotateVectorReverse(accel.Ign() - world->Gravity()));
366 
367  /* attitude */
368  // ecef_to_body_quat: unused
369  fdm.ltp_to_body_eulers = to_pprz_eulers(local_to_global_quat * pose.rot);
373 
374  /* angular velocity */
375  fdm.body_ecef_rotvel = to_pprz_rates(pose.rot.RotateVectorReverse(ang_vel));
376  fdm.body_inertial_rotvel = fdm.body_ecef_rotvel; // Approximate
377 
378  /* angular acceleration */
379  // body_ecef_rotaccel: unused
380  // body_inertial_rotaccel: unused
381  /* misc */
383  sphere->VelocityTransform(-1 * world->Gravity(),
384  gazebo::common::SphericalCoordinates::LOCAL,
385  gazebo::common::SphericalCoordinates::GLOBAL)); // unused
387  sphere->VelocityTransform(world->MagneticField(),
388  gazebo::common::SphericalCoordinates::LOCAL,
389  gazebo::common::SphericalCoordinates::GLOBAL));
390 
391  /* atmosphere */
392 #if GAZEBO_MAJOR_VERSION >= 8 && 0 // TODO implement
393 
394 #else
395  // Gazebo versions < 8 do not have atmosphere or wind support
396  // Use placeholder values. Valid for low altitude, low speed flights.
397  fdm.wind = {.x = 0, .y = 0, .z = 0};
398  fdm.pressure_sl = 101325; // Pa
399 
400  fdm.airspeed = 0;
401  fdm.pressure = fdm.pressure_sl; // Pa
403  fdm.temperature = 20.0; // C
404  fdm.aoa = 0; // rad
405  fdm.sideslip = 0; // rad
406 #endif
407  /* flight controls: unused */
408  fdm.elevator = 0;
409  fdm.flap = 0;
410  fdm.left_aileron = 0;
411  fdm.right_aileron = 0;
412  fdm.rudder = 0;
413  /* engine: unused */
414  fdm.num_engines = 0;
415 }
416 
434 static void gazebo_write(double commands[], int commands_nb)
435 {
436  const string names[] = NPS_ACTUATOR_NAMES;
437  const double thrusts[] = { NPS_ACTUATOR_THRUSTS };
438  const double torques[] = { NPS_ACTUATOR_TORQUES };
439 
440  for (int i = 0; i < commands_nb; ++i) {
441  double thrust = autopilot.motors_on ? thrusts[i] * commands[i] : 0.0;
442  double torque = autopilot.motors_on ? torques[i] * commands[i] : 0.0;
443  gazebo::physics::LinkPtr link = model->GetLink(names[i]);
444  link->AddRelativeForce(gazebo::math::Vector3(0, 0, thrust));
445  link->AddRelativeTorque(gazebo::math::Vector3(0, 0, torque));
446  // cout << "Motor '" << link->GetName() << "': thrust = " << thrust
447  // << " N, torque = " << torque << " Nm" << endl;
448  }
449 }
450 
451 #ifdef NPS_SIMULATE_VIDEO
452 
466 static void init_gazebo_video(void)
467 {
468  gazebo::sensors::SensorManager *mgr =
469  gazebo::sensors::SensorManager::Instance();
470 
471  cout << "Initializing cameras..." << endl;
472  // Loop over cameras registered in video_thread_nps
473  for (int i = 0; i < VIDEO_THREAD_MAX_CAMERAS && cameras[i] != NULL; ++i) {
474  // Find link in gazebo model
475  cout << "Setting up '" << cameras[i]->dev_name << "'... ";
476  gazebo::physics::LinkPtr link = model->GetLink(cameras[i]->dev_name);
477  if (!link) {
478  cout << "ERROR: Link '" << cameras[i]->dev_name << "' not found!"
479  << endl;
480  ;
481  continue;
482  }
483  // Get a pointer to the sensor using its full name
484  if (link->GetSensorCount() != 1) {
485  cout << "ERROR: Link '" << link->GetName()
486  << "' should only contain 1 sensor!" << endl;
487  continue;
488  }
489  string name = link->GetSensorName(0);
490  gazebo::sensors::CameraSensorPtr cam = static_pointer_cast
491  < gazebo::sensors::CameraSensor > (mgr->GetSensor(name));
492  if (!cam) {
493  cout << "ERROR: Could not get pointer to '" << name << "'!" << endl;
494  continue;
495  }
496  // Activate sensor
497  cam->SetActive(true);
498  // Add to list of cameras
499  gazebo_cams[i].cam = cam;
500  gazebo_cams[i].last_measurement_time = cam->LastMeasurementTime();
501  // Copy video_config settings from Gazebo's camera
502  cameras[i]->output_size.w = cam->ImageWidth();
503  cameras[i]->output_size.h = cam->ImageHeight();
504  cameras[i]->sensor_size.w = cam->ImageWidth();
505  cameras[i]->sensor_size.h = cam->ImageHeight();
506  cameras[i]->crop.w = cam->ImageWidth();
507  cameras[i]->crop.h = cam->ImageHeight();
508  cameras[i]->fps = cam->UpdateRate();
509  cout << "ok" << endl;
510  }
511 }
512 
521 static void gazebo_read_video(void)
522 {
523  for (int i = 0; i < VIDEO_THREAD_MAX_CAMERAS; ++i) {
524  gazebo::sensors::CameraSensorPtr &cam = gazebo_cams[i].cam;
525  // Skip unregistered or unfound cameras
526  if (cam == NULL) { continue; }
527  // Skip if not updated
528  // Also skip when LastMeasurementTime() is zero (workaround)
529  if (cam->LastMeasurementTime() == gazebo_cams[i].last_measurement_time
530  || cam->LastMeasurementTime() == 0) { continue; }
531  // Grab image, convert and send to video thread
532  struct image_t img;
533  read_image(&img, cam);
534  cv_run_device(cameras[i], &img);
535  // Free image buffer after use.
536  image_free(&img);
537  // Keep track of last update time.
538  gazebo_cams[i].last_measurement_time = cam->LastMeasurementTime();
539  }
540 }
541 
552 static void read_image(
553  struct image_t *img,
554  gazebo::sensors::CameraSensorPtr cam)
555 {
556  image_create(img, cam->ImageWidth(), cam->ImageHeight(), IMAGE_YUV422);
557  // Convert Gazebo's *RGB888* image to Paparazzi's YUV422
558  const uint8_t *data_rgb = cam->ImageData();
559  uint8_t *data_yuv = (uint8_t *)(img->buf);
560  for (int x = 0; x < img->w; ++x) {
561  for (int y = 0; y < img->h; ++y) {
562  int idx_rgb = 3 * (img->w * y + x);
563  int idx_yuv = 2 * (img->w * y + x);
564  int idx_px = img->w * y + x;
565  if (idx_px % 2 == 0) { // Pick U or V
566  data_yuv[idx_yuv] = -0.148 * data_rgb[idx_rgb]
567  - 0.291 * data_rgb[idx_rgb + 1]
568  + 0.439 * data_rgb[idx_rgb + 2] + 128; // U
569  } else {
570  data_yuv[idx_yuv] = 0.439 * data_rgb[idx_rgb]
571  - 0.368 * data_rgb[idx_rgb + 1]
572  - 0.071 * data_rgb[idx_rgb + 2] + 128; // V
573  }
574  data_yuv[idx_yuv + 1] = 0.257 * data_rgb[idx_rgb]
575  + 0.504 * data_rgb[idx_rgb + 1]
576  + 0.098 * data_rgb[idx_rgb + 2] + 16; // Y
577  }
578  }
579  // Fill miscellaneous fields
580  gazebo::common::Time ts = cam->LastMeasurementTime();
581  img->ts.tv_sec = ts.sec;
582  img->ts.tv_usec = ts.nsec / 1000.0;
583  img->pprz_ts = ts.Double() * 1e6;
584  img->buf_idx = 0; // unused
585 }
586 #endif
587 
588 #pragma GCC diagnostic pop // Ignore -Wdeprecated-declarations
double agl
Definition: nps_fdm.h:61
double z
in meters
struct NedCoor_d to_pprz_ned(ignition::math::Vector3d global)
double time
Definition: nps_fdm.h:46
vector in North East Down coordinates Units: meters
struct NedCoor_d ltpprz_ecef_accel
accel in ltppprz frame, wrt ECEF frame
Definition: nps_fdm.h:81
struct LlaCoor_d lla_pos_geoc
Definition: nps_fdm.h:60
void nps_fdm_set_temperature(double temp, double h)
Set temperature in degrees Celcius at given height h above MSL.
struct DoubleVect3 body_inertial_accel
acceleration in body frame, wrt ECI inertial frame
Definition: nps_fdm.h:84
struct crop_t crop
Cropped area definition.
Definition: video_device.h:47
struct DoubleRates body_ecef_rotvel
Definition: nps_fdm.h:97
void nps_fdm_run_step(bool launch, double *commands, int commands_nb)
Update the simulation state.
uint16_t h
The height.
Definition: image.h:75
uint16_t h
height of the cropped area
Definition: image.h:83
euler angles
double phi
in radians
float left_aileron
Definition: nps_fdm.h:121
struct img_size_t output_size
Output image size.
Definition: video_device.h:45
static gazebo::physics::ModelPtr model
struct EcefCoor_d to_pprz_ecef(ignition::math::Vector3d ecef_i)
void image_free(struct image_t *img)
Free the image.
Definition: image.c:63
struct NedCoor_d ltp_ecef_accel
acceleration in LTP frame, wrt ECEF frame
Definition: nps_fdm.h:76
double psi
in radians
double lat
in radians
double alt
in meters above WGS84 reference ellipsoid
angular rates
struct NpsFdm fdm
Holds all necessary NPS FDM state information.
static struct video_config_t * cameras[VIDEO_THREAD_MAX_CAMERAS]
Definition: video_thread.c:69
void image_create(struct image_t *img, uint16_t width, uint16_t height, enum image_type type)
Create a new image.
Definition: image.c:38
Definition: image.h:43
double q
in rad/s^2
double theta
in radians
struct LlaCoor_d lla_pos_pprz
Definition: nps_fdm.h:58
vector in Latitude, Longitude and Altitude
char * dev_name
path to device
Definition: video_device.h:48
struct DoubleRates body_inertial_rotvel
Definition: nps_fdm.h:101
double r
in rad/s^2
void nps_fdm_init(double dt)
Set JSBsim specific fields that are not used for Gazebo.
int nan_count
Definition: nps_fdm.h:50
void nps_fdm_set_wind_ned(double wind_north, double wind_east, double wind_down)
uint32_t pprz_ts
The timestamp in us since system startup.
Definition: image.h:49
struct DoubleEulers ltp_to_body_eulers
Definition: nps_fdm.h:92
struct NedCoor_d ltp_ecef_vel
velocity in LTP frame, wrt ECEF frame
Definition: nps_fdm.h:74
struct DoubleEulers to_pprz_eulers(gazebo::math::Quaternion quat)
struct pprz_autopilot autopilot
Global autopilot structure.
Definition: autopilot.c:50
double pressure_sl
pressure at sea level in Pascal
Definition: nps_fdm.h:114
Definition: nps_fdm.h:44
double x
in meters
struct NedCoor_d ltpprz_pos
Definition: nps_fdm.h:54
double hmsl
Definition: nps_fdm.h:56
uint16_t w
Width of the cropped area.
Definition: image.h:82
struct DoubleRates to_pprz_rates(gazebo::math::Vector3 body_g)
struct LlaCoor_d to_pprz_lla(ignition::math::Vector3d lla_i)
struct DoubleVect3 to_pprz_body(gazebo::math::Vector3 body_g)
struct EcefCoor_d ecef_ecef_vel
velocity in ECEF frame, wrt ECEF frame
Definition: nps_fdm.h:64
uint8_t buf_idx
Buffer index for V4L2 freeing.
Definition: image.h:51
double airspeed
equivalent airspeed in m/s
Definition: nps_fdm.h:109
Image helper functions like resizing, color filter, converters...
double y
in meters
struct DoubleVect3 body_accel
acceleration in body frame as measured by an accelerometer (incl.
Definition: nps_fdm.h:87
double x
in meters
double pressure
current (static) atmospheric pressure in Pascal
Definition: nps_fdm.h:110
static void gazebo_write(double commands[], int commands_nb)
Write actuator commands to Gazebo.
float elevator
Definition: nps_fdm.h:119
void nps_fdm_set_turbulence(double wind_speed, int turbulence_severity)
Architecture independent timing functions.
void double_quat_of_eulers(struct DoubleQuat *q, struct DoubleEulers *e)
float right_aileron
Definition: nps_fdm.h:122
struct img_size_t sensor_size
Original sensor size.
Definition: video_device.h:46
double init_dt
Definition: nps_fdm.h:47
uint16_t w
Image width.
Definition: image.h:45
uint32_t num_engines
Definition: nps_fdm.h:126
Computer vision framework for onboard processing.
uint16_t h
Image height.
Definition: image.h:46
struct DoubleVect3 wind
velocity in m/s in NED
Definition: nps_fdm.h:107
void * buf
Image buffer (depending on the image_type)
Definition: image.h:53
struct LlaCoor_d lla_pos_geod
Definition: nps_fdm.h:59
double dynamic_pressure
dynamic pressure in Pascal
Definition: nps_fdm.h:112
vector in EarthCenteredEarthFixed coordinates
This header gives NPS access to the list of added cameras.
#define NPS_GAZEBO_AC_NAME
double curr_dt
Definition: nps_fdm.h:48
int fps
Target FPS.
Definition: video_device.h:56
Core autopilot interface common to all firmwares.
struct LlaCoor_d lla_pos
Definition: nps_fdm.h:55
struct DoubleVect3 body_ecef_vel
velocity in body frame, wrt ECEF frame
Definition: nps_fdm.h:69
static void init_gazebo(void)
Set up a Gazebo server.
void cv_run_device(struct video_config_t *device, struct image_t *img)
Definition: cv.c:162
static void h(const real32_T x[7], const real32_T q[4], real32_T y[6])
double temperature
current temperature in degrees Celcius
Definition: nps_fdm.h:113
bool motors_on
motor status
Definition: autopilot.h:62
unsigned char uint8_t
Definition: types.h:14
pprz_t commands[COMMANDS_NB]
Storage of intermediate command values.
Definition: commands.c:30
struct timeval ts
The timestamp of creation.
Definition: image.h:47
struct DoubleQuat ltpprz_to_body_quat
Definition: nps_fdm.h:93
double lon
in radians
struct EcefCoor_d ecef_pos
Definition: nps_fdm.h:53
UYVY format (uint16 per pixel)
Definition: image.h:36
struct DoubleVect3 body_ecef_accel
acceleration in body frame, wrt ECEF frame
Definition: nps_fdm.h:71
struct DoubleVect3 ltp_g
Definition: nps_fdm.h:104
double z
in meters
#define VIDEO_THREAD_MAX_CAMERAS
Definition: video_thread.c:65
float rudder
Definition: nps_fdm.h:123
void nps_fdm_set_wind(double speed, double dir)
static void gazebo_read(void)
Read Gazebo's simulation state and store the results in the fdm struct used by NPS.
Paparazzi double precision floating point algebra.
struct NedCoor_d ltpprz_ecef_vel
velocity in ltppprz frame, wrt ECEF frame
Definition: nps_fdm.h:79
#define NPS_GAZEBO_WORLD
double p
in rad/s^2
struct DoubleVect3 to_pprz_ltp(gazebo::math::Vector3 xyz)
static bool gazebo_initialized
float flap
Definition: nps_fdm.h:120
uint16_t w
The width.
Definition: image.h:74
struct DoubleQuat ltp_to_body_quat
Definition: nps_fdm.h:91
double sideslip
sideslip angle in rad
Definition: nps_fdm.h:116
double y
in meters
struct EcefCoor_d ecef_ecef_accel
acceleration in ECEF frame, wrt ECEF frame
Definition: nps_fdm.h:66
struct DoubleEulers ltpprz_to_body_eulers
Definition: nps_fdm.h:94
double aoa
angle of attack in rad
Definition: nps_fdm.h:115
struct DoubleVect3 ltp_h
Definition: nps_fdm.h:105