Browse Source

SITL: added support for laser scanner for Morse

master
Andrew Tridgell 6 years ago
parent
commit
8d86b6fbee
  1. 4
      libraries/SITL/SIM_Aircraft.cpp
  2. 6
      libraries/SITL/SIM_Aircraft.h
  3. 4
      libraries/SITL/SIM_Morse.cpp
  4. 2
      libraries/SITL/SIM_Morse.h

4
libraries/SITL/SIM_Aircraft.cpp

@ -394,6 +394,10 @@ void Aircraft::fill_fdm(struct sitl_fdm &fdm) @@ -394,6 +394,10 @@ void Aircraft::fill_fdm(struct sitl_fdm &fdm)
memcpy(fdm.rcin, rcin, rcin_chan_count * sizeof(float));
fdm.bodyMagField = mag_bf;
// copy laser scanner results
fdm.scanner.points = scanner.points;
fdm.scanner.ranges = scanner.ranges;
if (smoothing.enabled) {
fdm.xAccel = smoothing.accel_body.x;
fdm.yAccel = smoothing.accel_body.y;

6
libraries/SITL/SIM_Aircraft.h

@ -142,6 +142,12 @@ protected: @@ -142,6 +142,12 @@ protected:
float rcin[8];
float range = -1.0f; // rangefinder detection in m
struct {
// data from simulated laser scanner, if available
struct vector3f_array points;
struct float_array ranges;
} scanner;
// Wind Turbulence simulated Data
float turbulence_azimuth = 0.0f;
float turbulence_horizontal_speed = 0.0f; // m/s

4
libraries/SITL/SIM_Morse.cpp

@ -449,6 +449,10 @@ void Morse::update(const struct sitl_input &input) @@ -449,6 +449,10 @@ void Morse::update(const struct sitl_input &input)
accel_body.y = constrain_float(accel_body.y, -a_limit, a_limit);
accel_body.z = constrain_float(accel_body.z, -a_limit, a_limit);
// fill in laser scanner results, if available
scanner.points = state.scanner.points;
scanner.ranges = state.scanner.ranges;
// offset based on first position to account for offset in morse world
if (position_offset.is_zero()) {
position_offset = position;

2
libraries/SITL/SIM_Morse.h

@ -60,7 +60,7 @@ private: @@ -60,7 +60,7 @@ private:
void report_FPS();
// buffer for parsing pose data in JSON format
uint8_t sensor_buffer[4096];
uint8_t sensor_buffer[50000];
uint32_t sensor_buffer_len;
SocketAPM *sensors_sock;

Loading…
Cancel
Save