sil_board.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Daniel Koch, James Jackson and Gary Ellingson, BYU MAGICC Lab.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * * Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * * Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #include <ros/ros.h>
34 #include <fstream>
35 
36 #include <iostream>
37 
38 namespace rosflight_sim
39 {
41 
43 {
45 }
46 
47 constexpr double rad2Deg(double x)
48 {
49  return 180.0 / M_PI * x;
50 }
51 constexpr double deg2Rad(double x)
52 {
53  return M_PI / 180.0 * x;
54 }
55 
56 void SIL_Board::gazebo_setup(gazebo::physics::LinkPtr link,
57  gazebo::physics::WorldPtr world,
58  gazebo::physics::ModelPtr model,
59  ros::NodeHandle *nh,
60  std::string mav_type)
61 {
62  link_ = link;
63  world_ = world;
64  model_ = model;
65  nh_ = nh;
66  mav_type_ = mav_type;
67 
68  std::string bind_host = nh->param<std::string>("gazebo_host", "localhost");
69  int bind_port = nh->param<int>("gazebo_port", 14525);
70  std::string remote_host = nh->param<std::string>("ROS_host", "localhost");
71  int remote_port = nh->param<int>("ROS_port", 14520);
72 
73  set_ports(bind_host, bind_port, remote_host, remote_port);
74  gzmsg << "ROSflight SIL Conneced to " << remote_host << ":" << remote_port << " from " << bind_host << ":"
75  << bind_port << "\n";
76 
77  // Get Sensor Parameters
78  gyro_stdev_ = nh->param<double>("gyro_stdev", 0.13);
79  gyro_bias_range_ = nh->param<double>("gyro_bias_range", 0.15);
80  gyro_bias_walk_stdev_ = nh->param<double>("gyro_bias_walk_stdev", 0.001);
81 
82  acc_stdev_ = nh->param<double>("acc_stdev", 1.15);
83  acc_bias_range_ = nh->param<double>("acc_bias_range", 0.15);
84  acc_bias_walk_stdev_ = nh->param<double>("acc_bias_walk_stdev", 0.001);
85 
86  mag_stdev_ = nh->param<double>("mag_stdev", 1.15);
87  mag_bias_range_ = nh->param<double>("mag_bias_range", 0.15);
88  mag_bias_walk_stdev_ = nh->param<double>("mag_bias_walk_stdev", 0.001);
89 
90  baro_stdev_ = nh->param<double>("baro_stdev", 1.15);
91  baro_bias_range_ = nh->param<double>("baro_bias_range", 0.15);
92  baro_bias_walk_stdev_ = nh->param<double>("baro_bias_walk_stdev", 0.001);
93 
94  airspeed_stdev_ = nh_->param<double>("airspeed_stdev", 1.15);
95  airspeed_bias_range_ = nh_->param<double>("airspeed_bias_range", 0.15);
96  airspeed_bias_walk_stdev_ = nh_->param<double>("airspeed_bias_walk_stdev", 0.001);
97 
98  sonar_stdev_ = nh_->param<double>("sonar_stdev", 1.15);
99  sonar_min_range_ = nh_->param<double>("sonar_min_range", 0.25);
100  sonar_max_range_ = nh_->param<double>("sonar_max_range", 8.0);
101 
102  imu_update_rate_ = nh_->param<double>("imu_update_rate", 1000.0);
103  imu_update_period_us_ = (uint64_t)(1e6 / imu_update_rate_);
104 
105  // Calculate Magnetic Field Vector (for mag simulation)
106  double inclination = nh_->param<double>("inclination", 1.14316156541);
107  double declination = nh_->param<double>("declination", 0.198584539676);
109  GZ_COMPAT_SET_X(inertial_magnetic_field_, cos(-inclination) * cos(-declination));
110  GZ_COMPAT_SET_Y(inertial_magnetic_field_, cos(-inclination) * sin(-declination));
111 
112  // Get the desired altitude at the ground (for baro and LLA)
113 
114  origin_altitude_ = nh->param<double>("origin_altitude", 1387.0);
115  origin_latitude_ = nh->param<double>("origin_latitude", 40.2463724);
116  origin_longitude_ = nh->param<double>("origin_longitude", -111.6474138);
117 
118  horizontal_gps_stdev_ = nh->param<double>("horizontal_gps_stdev", 1.0);
119  vertical_gps_stdev_ = nh->param<double>("vertical_gps_stdev", 3.0);
120  gps_velocity_stdev_ = nh->param<double>("gps_velocity_stdev", 0.1);
121 
122  // Configure Noise
123  random_generator_ = std::default_random_engine(std::chrono::system_clock::now().time_since_epoch().count());
124  normal_distribution_ = std::normal_distribution<double>(0.0, 1.0);
125  uniform_distribution_ = std::uniform_real_distribution<double>(-1.0, 1.0);
126 
128 
129  // Initialize the Sensor Biases
141 
147 }
148 
149 void SIL_Board::board_reset(bool bootloader) {}
150 
151 // clock
152 
154 {
155  uint32_t millis = (uint32_t)((GZ_COMPAT_GET_SIM_TIME(world_) - boot_time_).Double() * 1e3);
156  return millis;
157 }
158 
160 {
161  uint64_t micros = (uint64_t)((GZ_COMPAT_GET_SIM_TIME(world_) - boot_time_).Double() * 1e6);
162  return micros;
163 }
164 
165 void SIL_Board::clock_delay(uint32_t milliseconds) {}
166 
167 // sensors
171 {
172  // Initialize the Biases
179 
180  // Gazebo coordinates is NWU and Earth's magnetic field is defined in NED, hence the negative signs
181  double inclination_ = 1.14316156541;
182  double declination_ = 0.198584539676;
184  GZ_COMPAT_SET_X(inertial_magnetic_field_, cos(-inclination_) * cos(-declination_));
185  GZ_COMPAT_SET_Y(inertial_magnetic_field_, cos(-inclination_) * sin(-declination_));
186 
187 #if GAZEBO_MAJOR_VERSION >= 9
188  using SC = gazebo::common::SphericalCoordinates;
189  using Ang = ignition::math::Angle;
190  sph_coord_.SetSurfaceType(SC::SurfaceType::EARTH_WGS84);
191  sph_coord_.SetLatitudeReference(Ang(deg2Rad(origin_latitude_)));
192  sph_coord_.SetLongitudeReference(Ang(deg2Rad(origin_longitude_)));
193  sph_coord_.SetElevationReference(origin_altitude_);
194  // Force x-axis to be north-aligned. I promise, I will change everything to ENU in the next commit
195  sph_coord_.SetHeadingOffset(Ang(-M_PI / 2.0));
196 #endif
197 }
198 
200 {
201  return 0;
202 }
203 
205 {
206  uint64_t now_us = clock_micros();
207  if (now_us >= next_imu_update_time_us_)
208  {
210  return true;
211  }
212  else
213  {
214  return false;
215  }
216 }
217 
218 bool SIL_Board::imu_read(float accel[3], float *temperature, float gyro[3], uint64_t *time_us)
219 {
222  GazeboVector y_acc;
223 
224  // this is James' egregious hack to overcome wild imu while sitting on the ground
225  if (GZ_COMPAT_GET_LENGTH(current_vel) < 0.05)
226  y_acc = q_I_NWU.RotateVectorReverse(-gravity_);
227  else
228  y_acc = q_I_NWU.RotateVectorReverse(GZ_COMPAT_GET_WORLD_LINEAR_ACCEL(link_) - gravity_);
229 
230  // Apply normal noise (only if armed, because most of the noise comes from motors
231  if (motors_spinning())
232  {
236  }
237 
238  // Perform Random Walk for biases
245 
246  // Add constant Bias to measurement
250 
251  // Convert to NED for output
252  accel[0] = GZ_COMPAT_GET_X(y_acc);
253  accel[1] = -GZ_COMPAT_GET_Y(y_acc);
254  accel[2] = -GZ_COMPAT_GET_Z(y_acc);
255 
257 
258  // Normal Noise from motors
259  if (motors_spinning())
260  {
264  }
265 
266  // Random Walk for bias
273 
274  // Apply Constant Bias
278 
279  // Convert to NED for output
280  gyro[0] = GZ_COMPAT_GET_X(y_gyro);
281  gyro[1] = -GZ_COMPAT_GET_Y(y_gyro);
282  gyro[2] = -GZ_COMPAT_GET_Z(y_gyro);
283 
284  (*temperature) = 27.0;
285  (*time_us) = clock_micros();
286  return true;
287 }
288 
290 {
291  ROS_ERROR("[gazebo_rosflight_sil] imu not responding");
292 }
293 
294 void SIL_Board::mag_read(float mag[3])
295 {
297  GazeboVector noise;
301 
302  // Random Walk for bias
309 
310  // combine parts to create a measurement
311  GazeboVector y_mag = GZ_COMPAT_GET_ROT(I_to_B).RotateVectorReverse(inertial_magnetic_field_) + mag_bias_ + noise;
312 
313  // Convert measurement to NED
314  mag[0] = GZ_COMPAT_GET_X(y_mag);
315  mag[1] = -GZ_COMPAT_GET_Y(y_mag);
316  mag[2] = -GZ_COMPAT_GET_Z(y_mag);
317 }
318 
320 {
321  return true;
322 }
323 
325 {
326  return true;
327 }
328 
329 void SIL_Board::baro_read(float *pressure, float *temperature)
330 {
331  // pull z measurement out of Gazebo
332  GazeboPose current_state_NWU = GZ_COMPAT_GET_WORLD_POSE(link_);
333 
334  // Invert measurement model for pressure and temperature
335  double alt = GZ_COMPAT_GET_Z(GZ_COMPAT_GET_POS(current_state_NWU)) + origin_altitude_;
336 
337  // Convert to the true pressure reading
338  double y_baro = 101325.0f * (float)pow((1 - 2.25694e-5 * alt), 5.2553);
339 
340  // Add noise
342 
343  // Perform random walk
345 
346  // Add random walk
347  y_baro += baro_bias_;
348 
349  (*pressure) = (float)y_baro;
350  (*temperature) = 27.0f;
351 }
352 
354 {
355  if (mav_type_ == "fixedwing")
356  return true;
357  else
358  return false;
359 }
360 
361 void SIL_Board::diff_pressure_read(float *diff_pressure, float *temperature)
362 {
363  static double rho_ = 1.225;
364  // Calculate Airspeed
366 
367  double Va = GZ_COMPAT_GET_LENGTH(vel);
368 
369  // Invert Airpseed to get sensor measurement
370  double y_as = rho_ * Va * Va / 2.0; // Page 130 in the UAV Book
371 
372  // Add noise
375  y_as += airspeed_bias_;
376 
377  *diff_pressure = y_as;
378  *temperature = 27.0;
379 }
380 
382 {
383  return true;
384 }
385 
387 {
388  GazeboPose current_state_NWU = GZ_COMPAT_GET_WORLD_POSE(link_);
389  double alt = GZ_COMPAT_GET_Z(GZ_COMPAT_GET_POS(current_state_NWU));
390 
391  if (alt < sonar_min_range_)
392  {
393  return sonar_min_range_;
394  }
395  else if (alt > sonar_max_range_)
396  {
397  return sonar_max_range_;
398  }
399  else
401 }
402 
404 {
405  return true;
406 }
407 
409 {
410  return 15 * battery_voltage_multiplier;
411 }
412 
414 {
415  battery_voltage_multiplier = multiplier;
416 }
417 
419 {
420  return true;
421 }
422 
424 {
425  return 1 * battery_current_multiplier;
426 }
427 
429 {
430  battery_current_multiplier = multiplier;
431 }
432 
433 // PWM
434 void SIL_Board::pwm_init(uint32_t refresh_rate, uint16_t idle_pwm)
435 {
436  rc_received_ = false;
437  latestRC_.values[0] = 1500; // x
438  latestRC_.values[1] = 1500; // y
439  latestRC_.values[3] = 1500; // z
440  latestRC_.values[2] = 1000; // F
441  latestRC_.values[4] = 1000; // attitude override
442  latestRC_.values[5] = 1000; // arm
443 
444  for (size_t i = 0; i < 14; i++) pwm_outputs_[i] = 1000;
445 
446  rc_sub_ = nh_->subscribe("RC", 1, &SIL_Board::RCCallback, this);
447 }
448 
449 float SIL_Board::rc_read(uint8_t channel)
450 {
451  if (rc_sub_.getNumPublishers() > 0)
452  {
453  return static_cast<float>(latestRC_.values[channel] - 1000) / 1000.0;
454  }
455 
456  // no publishers, set throttle low and center everything else
457  if (channel == 2)
458  return 0.0;
459 
460  return 0.5;
461 }
462 
463 void SIL_Board::pwm_write(uint8_t channel, float value)
464 {
465  pwm_outputs_[channel] = 1000 + (uint16_t)(1000 * value);
466 }
468 {
469  for (int i = 0; i < 14; i++) pwm_write(i, 0);
470 }
471 
473 {
474  return !rc_received_;
475 }
476 
478 
479 // non-volatile memory
481 
482 bool SIL_Board::memory_read(void *dest, size_t len)
483 {
484  std::string directory = "rosflight_memory" + nh_->getNamespace();
485  std::ifstream memory_file;
486  memory_file.open(directory + "/mem.bin", std::ios::binary);
487 
488  if (!memory_file.is_open())
489  {
490  ROS_ERROR("Unable to load rosflight memory file %s/mem.bin", directory.c_str());
491  return false;
492  }
493 
494  memory_file.read((char *)dest, len);
495  memory_file.close();
496  return true;
497 }
498 
499 bool SIL_Board::memory_write(const void *src, size_t len)
500 {
501  std::string directory = "rosflight_memory" + nh_->getNamespace();
502  std::string mkdir_command = "mkdir -p " + directory;
503  const int dir_err = system(mkdir_command.c_str());
504 
505  if (dir_err == -1)
506  {
507  ROS_ERROR("Unable to write rosflight memory file %s/mem.bin", directory.c_str());
508  return false;
509  }
510 
511  std::ofstream memory_file;
512  memory_file.open(directory + "/mem.bin", std::ios::binary);
513  memory_file.write((char *)src, len);
514  memory_file.close();
515  return true;
516 }
517 
519 {
520  if (pwm_outputs_[2] > 1100)
521  return true;
522  else
523  return false;
524 }
525 
526 // LED
527 
528 void SIL_Board::led0_on(void) {}
529 void SIL_Board::led0_off(void) {}
531 
532 void SIL_Board::led1_on(void) {}
533 void SIL_Board::led1_off(void) {}
535 
537 
538 bool SIL_Board::backup_memory_read(void *dest, size_t len)
539 {
540  if (len <= BACKUP_SRAM_SIZE)
541  {
542  memcpy(dest, backup_memory_, len);
543  return true;
544  }
545  else
546  return false;
547 }
548 
549 void SIL_Board::backup_memory_write(const void *src, size_t len)
550 {
551  if (len < BACKUP_SRAM_SIZE)
552  memcpy(backup_memory_, src, len);
553 }
554 
556 {
557  if (len < BACKUP_SRAM_SIZE)
558  memset(backup_memory_, 0, len);
559 }
560 
561 void SIL_Board::RCCallback(const rosflight_msgs::RCRaw &msg)
562 {
563  rc_received_ = true;
565  latestRC_ = msg;
566 }
567 
569 {
570  return GAZEBO_MAJOR_VERSION >= 9;
571 }
573 
575 {
577 #if GAZEBO_MAJOR_VERSION >= 9
578  using Vec3 = ignition::math::Vector3d;
579  using Coord = gazebo::common::SphericalCoordinates::CoordinateType;
580 
585  Vec3 local_pos = GZ_COMPAT_GET_POS(local_pose) + pos_noise;
586 
587  Vec3 local_vel = GZ_COMPAT_GET_WORLD_LINEAR_VEL(link_);
591  local_vel += vel_noise;
592 
593  Vec3 ecef_pos = sph_coord_.PositionTransform(local_pos, Coord::LOCAL, Coord::ECEF);
594  Vec3 ecef_vel = sph_coord_.VelocityTransform(local_vel, Coord::LOCAL, Coord::ECEF);
595  Vec3 lla = sph_coord_.PositionTransform(local_pos, Coord::LOCAL, Coord::SPHERICAL);
596 
597  out.lat = std::round(rad2Deg(lla.X()) * 1e7);
598  out.lon = std::round(rad2Deg(lla.Y()) * 1e7);
599  out.height = std::round(rad2Deg(lla.Z()) * 1e3);
600 
601  // For now, we have defined the Gazebo Local Frame as NWU. This should be fixed in a future
602  // commit
603  out.vel_n = std::round(local_vel.X() * 1e3);
604  out.vel_e = std::round(-local_vel.Y() * 1e3);
605  out.vel_d = std::round(-local_vel.Z() * 1e3);
606 
607  out.fix_type = rosflight_firmware::GNSSFixType::GNSS_FIX_TYPE_FIX;
608  out.time_of_week = GZ_COMPAT_GET_SIM_TIME(world_).Double() * 1000;
609  out.time = GZ_COMPAT_GET_SIM_TIME(world_).Double();
610  out.nanos = (GZ_COMPAT_GET_SIM_TIME(world_).Double() - out.time) * 1e9;
611 
612  out.h_acc = std::round(horizontal_gps_stdev_ * 1000.0);
613  out.v_acc = std::round(vertical_gps_stdev_ * 1000.0);
614 
615  out.ecef.x = std::round(ecef_pos.X() * 100);
616  out.ecef.y = std::round(ecef_pos.Y() * 100);
617  out.ecef.z = std::round(ecef_pos.Z() * 100);
618  out.ecef.p_acc = std::round(out.h_acc / 10.0);
619  out.ecef.vx = std::round(ecef_vel.X() * 100);
620  out.ecef.vy = std::round(ecef_vel.Y() * 100);
621  out.ecef.vz = std::round(ecef_vel.Z() * 100);
622  out.ecef.s_acc = std::round(gps_velocity_stdev_ * 100);
623 
625 
626 #endif
627  return out;
628 }
629 
631 {
632  return GAZEBO_MAJOR_VERSION >= 9;
633 }
635 {
637 #if GAZEBO_MAJOR_VERSION >= 9
638  using Vec3 = ignition::math::Vector3d;
639  using Vec3 = ignition::math::Vector3d;
640  using Coord = gazebo::common::SphericalCoordinates::CoordinateType;
641 
646  Vec3 local_pos = GZ_COMPAT_GET_POS(local_pose) + pos_noise;
647 
648  Vec3 local_vel = GZ_COMPAT_GET_WORLD_LINEAR_VEL(link_);
652  local_vel += vel_noise;
653 
654  // TODO: Do a better job of simulating the wander of GPS
655 
656  Vec3 ecef_pos = sph_coord_.PositionTransform(local_pos, Coord::LOCAL, Coord::ECEF);
657  Vec3 ecef_vel = sph_coord_.VelocityTransform(local_vel, Coord::LOCAL, Coord::ECEF);
658  Vec3 lla = sph_coord_.PositionTransform(local_pos, Coord::LOCAL, Coord::SPHERICAL);
659 
660  out.lat = std::round(rad2Deg(lla.X()) * 1e7);
661  out.lon = std::round(rad2Deg(lla.Y()) * 1e7);
662  out.height = std::round(rad2Deg(lla.Z()) * 1e3);
663  out.height_msl = out.height; // TODO
664 
665  // For now, we have defined the Gazebo Local Frame as NWU. This should be
666  // fixed in a future commit
667  out.vel_n = std::round(local_vel.X() * 1e3);
668  out.vel_e = std::round(-local_vel.Y() * 1e3);
669  out.vel_d = std::round(-local_vel.Z() * 1e3);
670 
671  out.fix_type = rosflight_firmware::GNSSFixType::GNSS_FIX_TYPE_FIX;
672  out.time_of_week = GZ_COMPAT_GET_SIM_TIME(world_).Double() * 1000;
673  out.num_sat = 15;
674  // TODO
675  out.year = 0;
676  out.month = 0;
677  out.day = 0;
678  out.hour = 0;
679  out.min = 0;
680  out.sec = 0;
681  out.valid = 0;
682  out.t_acc = 0;
683  out.nano = 0;
684 
685  out.h_acc = std::round(horizontal_gps_stdev_ * 1000.0);
686  out.v_acc = std::round(vertical_gps_stdev_ * 1000.0);
687 
688  // Again, TODO switch to using ENU convention per REP
689  double vn = local_vel.X();
690  double ve = -local_vel.Y();
691  double ground_speed = std::sqrt(vn * vn + ve * ve);
692  out.g_speed = std::round(ground_speed * 1000);
693 
694  double head_mot = std::atan2(ve, vn);
695  out.head_mot = std::round(rad2Deg(head_mot) * 1e5);
696  out.p_dop = 0.0; // TODO
698 
699 #endif
700  return out;
701 }
702 
703 } // namespace rosflight_sim
#define GZ_COMPAT_SET_X(VECTOR, VALUE)
Definition: gz_compat.h:80
#define GZ_COMPAT_GET_GRAVITY(WORLD_PTR)
Definition: gz_compat.h:99
#define GZ_COMPAT_GET_WORLD_LINEAR_VEL(LINK_PTR)
Definition: gz_compat.h:89
uint8_t backup_memory_[BACKUP_SRAM_SIZE]
Definition: sil_board.h:133
static constexpr size_t BACKUP_SRAM_SIZE
Definition: sil_board.h:132
uint32_t millis(void)
#define GZ_COMPAT_SET_Z(VECTOR, VALUE)
Definition: gz_compat.h:82
gazebo::common::Time last_time_
Definition: sil_board.h:128
gazebo::physics::WorldPtr world_
Definition: sil_board.h:104
bool battery_voltage_present() const override
Definition: sil_board.cpp:403
void baro_read(float *pressure, float *temperature) override
Definition: sil_board.cpp:329
#define GZ_COMPAT_GET_Z(VECTOR)
Definition: gz_compat.h:78
bool gnss_has_new_data() override
Definition: sil_board.cpp:630
std::uniform_real_distribution< double > uniform_distribution_
Definition: sil_board.h:97
void clock_delay(uint32_t milliseconds) override
Definition: sil_board.cpp:165
bool memory_write(const void *src, size_t len) override
Definition: sil_board.cpp:499
void memory_init(void) override
Definition: sil_board.cpp:480
float cos(float x)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
bool diff_pressure_present(void) override
Definition: sil_board.cpp:353
gazebo::math::Vector3 GazeboVector
Definition: gz_compat.h:72
bool sonar_present(void) override
Definition: sil_board.cpp:381
GazeboVector prev_vel_3_
Definition: sil_board.h:127
void led1_off(void) override
Definition: sil_board.cpp:533
float sin(float x)
void mag_read(float mag[3]) override
Definition: sil_board.cpp:294
rosflight_firmware::GNSSData gnss_read() override
Definition: sil_board.cpp:574
bool rc_lost(void) override
Definition: sil_board.cpp:472
#define GZ_COMPAT_GET_X(VECTOR)
Definition: gz_compat.h:76
void sensors_init() override
Definition: sil_board.cpp:170
bool backup_memory_read(void *dest, size_t len) override
Definition: sil_board.cpp:538
float alt(float press)
GazeboVector gyro_bias_
Definition: sil_board.h:89
bool gnss_present() override
Definition: sil_board.cpp:568
#define GZ_COMPAT_GET_RELATIVE_ANGULAR_VEL(LINK_PTR)
Definition: gz_compat.h:90
uint64_t next_imu_update_time_us_
Definition: sil_board.h:119
void battery_voltage_set_multiplier(double multiplier) override
Definition: sil_board.cpp:413
ros::Subscriber rc_sub_
Definition: sil_board.h:109
void gazebo_setup(gazebo::physics::LinkPtr link, gazebo::physics::WorldPtr world, gazebo::physics::ModelPtr model, ros::NodeHandle *nh, std::string mav_type)
Definition: sil_board.cpp:56
float sonar_read(void) override
Definition: sil_board.cpp:386
ros::Time last_rc_message_
Definition: sil_board.h:112
void backup_memory_write(const void *src, size_t len) override
Definition: sil_board.cpp:549
void led1_on(void) override
Definition: sil_board.cpp:532
GazeboVector prev_vel_2_
Definition: sil_board.h:126
float battery_current_read() const override
Definition: sil_board.cpp:423
void backup_memory_clear(size_t len) override
Definition: sil_board.cpp:555
void diff_pressure_read(float *diff_pressure, float *temperature) override
Definition: sil_board.cpp:361
void pwm_init(uint32_t refresh_rate, uint16_t idle_pwm) override
Definition: sil_board.cpp:434
void led0_on(void) override
Definition: sil_board.cpp:528
std::normal_distribution< double > normal_distribution_
Definition: sil_board.h:96
uint32_t clock_millis() override
Definition: sil_board.cpp:153
uint64_t micros(void)
bool imu_read(float accel[3], float *temperature, float gyro[3], uint64_t *time_us) override
Definition: sil_board.cpp:218
rosflight_msgs::RCRaw latestRC_
Definition: sil_board.h:110
gazebo::common::Time boot_time_
Definition: sil_board.h:118
#define GZ_COMPAT_GET_WORLD_POSE(LINK_PTR)
Definition: gz_compat.h:92
GazeboVector acc_bias_
Definition: sil_board.h:90
void backup_memory_init() override
Definition: sil_board.cpp:536
void board_reset(bool bootloader) override
Definition: sil_board.cpp:149
gazebo::math::Pose GazeboPose
Definition: gz_compat.h:73
bool param(const std::string &param_name, T &param_val, const T &default_val) const
gazebo::physics::LinkPtr link_
Definition: sil_board.h:106
void imu_not_responding_error() override
Definition: sil_board.cpp:289
bool new_imu_data() override
Definition: sil_board.cpp:204
double airspeed_bias_walk_stdev_
Definition: sil_board.h:77
uint32_t getNumPublishers() const
bool battery_current_present() const override
Definition: sil_board.cpp:418
const std::string & getNamespace() const
#define GZ_COMPAT_GET_ROT(POSE)
Definition: gz_compat.h:85
void led1_toggle(void) override
Definition: sil_board.cpp:534
uint32_t out
void RCCallback(const rosflight_msgs::RCRaw &msg)
Definition: sil_board.cpp:561
void gnss_update() override
Definition: sil_board.cpp:572
int i
#define GZ_COMPAT_GET_WORLD_LINEAR_ACCEL(LINK_PTR)
Definition: gz_compat.h:95
void pwm_disable(void) override
Definition: sil_board.cpp:467
float battery_voltage_read() const override
Definition: sil_board.cpp:408
uint64_t clock_micros() override
Definition: sil_board.cpp:159
void battery_current_set_multiplier(double multiplier) override
Definition: sil_board.cpp:428
GazeboVector prev_vel_1_
Definition: sil_board.h:125
GazeboVector mag_bias_
Definition: sil_board.h:91
void set_ports(std::string bind_host, uint16_t bind_port, std::string remote_host, uint16_t remote_port)
uint16_t num_sensor_errors(void) override
Definition: sil_board.cpp:199
GazeboVector gravity_
Definition: sil_board.h:99
#define GZ_COMPAT_GET_LENGTH(VECTOR)
Definition: gz_compat.h:96
bool baro_present(void) override
Definition: sil_board.cpp:324
static Time now()
float rc_read(uint8_t channel) override
Definition: sil_board.cpp:449
GazeboVector inertial_magnetic_field_
Definition: sil_board.h:57
#define GZ_COMPAT_GET_POS(POSE)
Definition: gz_compat.h:84
double time_since_epoch()
bool mag_present(void) override
Definition: sil_board.cpp:319
#define M_PI
std::default_random_engine random_generator_
Definition: sil_board.h:95
void init_board(void) override
Definition: sil_board.cpp:42
gazebo::physics::ModelPtr model_
Definition: sil_board.h:105
uint64_t imu_update_period_us_
Definition: sil_board.h:120
void rc_init(rc_type_t rc_type) override
Definition: sil_board.cpp:477
ros::NodeHandle * nh_
Definition: sil_board.h:108
rosflight_firmware::GNSSFull gnss_full_read() override
Definition: sil_board.cpp:634
constexpr double deg2Rad(double x)
Definition: sil_board.cpp:51
void led0_off(void) override
Definition: sil_board.cpp:529
void led0_toggle(void) override
Definition: sil_board.cpp:530
#define GZ_COMPAT_GET_SIM_TIME(WORLD_PTR)
Definition: gz_compat.h:87
#define ROS_ERROR(...)
void pwm_write(uint8_t channel, float value) override
Definition: sil_board.cpp:463
#define GZ_COMPAT_GET_Y(VECTOR)
Definition: gz_compat.h:77
constexpr double rad2Deg(double x)
Definition: sil_board.cpp:47
#define GZ_COMPAT_GET_RELATIVE_LINEAR_VEL(LINK_PTR)
Definition: gz_compat.h:88
bool memory_read(void *dest, size_t len) override
Definition: sil_board.cpp:482
#define GZ_COMPAT_SET_Y(VECTOR, VALUE)
Definition: gz_compat.h:81
gazebo::math::Quaternion GazeboQuaternion
Definition: gz_compat.h:74


rosflight_sim
Author(s): James Jackson, Gary Ellingson, Daniel Koch
autogenerated on Thu Apr 15 2021 05:09:58