bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
Flying a simulated quadrotor from the laptop

A toy drone is flown with a hand-held transmitter: two sticks for the throttle, yaw, pitch and roll, sent over a radio to a receiver on the drone, whose flight controller keeps it level and turns the sticks into rotor speeds. This example puts the laptop in the place of the transmitter and flies the quadrotor of The dynamics of a quadrotor in a simulation: from the keyboard in a window, or headless along a scripted flight. It is the first step to flying a real toy drone from the laptop: the commands are those its radio carries.

The scripted flight, at twice the speed it ran

The scripted flight, at twice the speed it ran: take off, fly 5 m forward, turn round, fly back and land. The red rotor is the front one, the yellow line the track over the floor.

What you need

bitsim built with Chrono and Irrlicht, which draw the drone; see Installing bitsim. The flight itself is QuadrotorDynamics, not Chrono.

From the sticks to the rotors

Piece Where What it does
RCCommand bitsim the throttle in [0, 1], yaw, pitch and roll in [-1, 1], and whether the motors are armed
KeyboardRC bitsim the keyboard of the window as the sticks
RCTransmitterBase bitsim sends the commands; a backend decides where to
SIM_RCLink bitsim the radio to a simulated drone, with the receiver's failsafe
QuadrotorFlightController bitsim the drone's flight controller in angle mode, and its motor mixer
QuadrotorDynamics bitsim flies the drone
SimulatedQuadrotor the example the receiver, the flight controller and the dynamics together, and the floor

The transmitter sends a command every 20 ms. The receiver passes the latest one to the flight controller at every step of 1 ms; if it has heard nothing for 0.5 s it goes into failsafe and disarms the drone, so that its motors stop, as a toy drone does when it flies out of range.

Angle mode

The flight controller of a toy drone flies in angle mode:

  • the throttle sets the thrust, as a share of the most the rotors can give. Here they can lift twice the weight, so the drone hovers at a throttle of 0.5. There is no height hold: the pilot holds the height, and tilting the drone takes some of the thrust off the weight, cos 15 degrees of it at 15 degrees, so the pilot adds a little throttle while flying forward;
  • the roll and pitch sticks set the angle to tilt to, up to 25 degrees; letting them go levels the drone. A PD controller on each angle gives the torque, \(\tau = J(\omega_n^2 (\phi_{sp} - \phi) - 2\zeta\omega_n p)\), with \(\omega_n\) = 12 rad/s and \(\zeta\) = 0.8. A tilted drone accelerates the way it tilts, until the air drag of the model, 0.25 kg/s, holds it at a steady speed;
  • the yaw stick sets the rate of turn, up to 120 deg/s.

The mixer turns the thrust and the three torques into the four rotor speeds, by inverting the equations of The dynamics of a quadrotor; a rotor cannot push down, nor spin faster than its motor allows. The flight controller reads the attitude and the rates of the drone directly; a real one estimates them from its IMU, as Turning by the gyroscope of an IMU does for a heading.

The floor

QuadrotorDynamics knows nothing of a floor, so SimulatedQuadrotor keeps the drone on it: there it stands still and level. A touchdown faster than 1 m/s counts as a hard landing.

Flying it

./quadrotor_rc_simulation --render # fly it from the keyboard
./quadrotor_rc_simulation # the scripted flight, headless
./quadrotor_rc_simulation --render --script # watch the scripted flight
./quadrotor_rc_simulation --failsafe # the transmitter stops at 7 s
Key Stick
Space arm, or disarm
W, S throttle up, down; it stays where it is left
A, D yaw left, right
Up, Down pitch forward, back
Left, Right roll left, right
R start again

Arm it, hold W until the throttle passes 0.5 and it lifts off, and let go when it climbs: the status bar at the bottom shows the throttle and the hover throttle. The camera follows behind the drone. --record DIR writes the window to DIR, as in Following a line with infrared sensors and avoiding obstacles; the movie above was made with --render --script --record frames.

Output

The scripted flight, headless. It returns 0 if the drone took off, came back within a metre of the start, landed gently and never tilted beyond the 25 degrees the sticks allow.

Quadrotor: 0.47 kg, arms 0.23 m, rotors up to 878 rad/s, hover throttle 0.50
Radio: a command every 20.00 ms, failsafe after 0.50 s without one
Flying the script
t [s] x [m] y [m] height [m] roll pitch heading [deg] throttle phase
0.0 0.00 0.00 0.00 0.0 0.0 0.0 0.00 on the floor
1.0 0.00 0.00 0.00 0.0 0.0 0.0 0.00 arm
2.0 0.00 0.00 0.50 0.0 0.0 0.0 0.56 take off
3.0 0.00 0.00 1.47 0.0 0.0 0.0 0.45 level off
4.0 0.00 0.00 1.57 0.0 0.0 0.0 0.50 hover
5.0 0.15 0.00 1.57 0.0 -15.2 0.0 0.52 forward
6.0 1.91 0.00 1.63 0.0 -15.0 0.0 0.52 forward
7.0 4.65 0.00 1.72 0.0 15.3 0.0 0.52 brake
8.0 4.91 0.00 1.83 0.0 15.0 0.0 0.52 brake
9.0 3.19 0.01 1.91 -0.0 -0.3 45.1 0.50 turn round
10.0 1.84 0.03 1.95 0.0 0.0 164.6 0.50 turn round
11.0 0.22 0.06 2.04 -0.0 -15.0 182.1 0.52 forward
12.0 -2.75 0.01 2.12 0.0 -15.0 182.1 0.52 forward
13.0 -4.89 -0.04 2.25 0.0 15.0 182.1 0.52 brake
14.0 -4.14 0.01 2.37 0.0 15.0 182.1 0.52 brake
15.0 -2.49 0.08 2.43 0.0 0.0 182.1 0.50 hover
16.0 -1.50 0.13 2.42 0.0 0.0 182.1 0.48 land
...
21.0 -0.22 0.18 0.00 0.0 0.0 182.1 0.48 land
...
Highest 2.45 m, furthest 5.13 m from the start, most tilt 15.4 deg
Ended on the floor, 0.29 m from the start; touched down at 0.69 m/s; hard landings: 0

A pitch stick of 0.6 tilts the drone by 0.6 x 25 = 15 degrees, nose down to fly forward, nose up to brake. Full yaw for 1.5 s turns it by 182 degrees, a little more than the 180 the sticks ask for, as the rate loop lags. The drone ends 0.29 m from where it took off and touches down at 0.69 m/s. It climbs from 1.6 to 2.4 m along the way: the extra throttle for the tilt is a guess, as it is for a pilot.

With --failsafe the transmitter falls silent at 7 s, while the drone brakes 1.7 m up:

7.0 4.65 0.00 1.72 0.0 15.3 0.0 0.52 brake
7.5 5.13 0.00 1.78 0.0 15.0 0.0 0.00 FAILSAFE
8.0 5.24 0.00 0.61 0.0 15.0 0.0 0.00 FAILSAFE
8.5 5.26 0.00 0.00 0.0 0.0 0.0 0.00 FAILSAFE
Ended on the floor, 5.26 m from the start; touched down at 5.16 m/s; hard landings: 1

Half a second later the receiver disarms the drone. With its motors stopped nothing levels it, and it falls, still tilted, onto the floor at 5 m/s. Cutting the motors is what a toy drone does; a safer failsafe would level the drone and lower it slowly while it still can.

Things to try

  1. Fly the scripted flight's square by hand, and land on the white pad.
  2. Give the flight controller tilt compensation: divide the thrust by \(\cos\phi\cos\theta\). Does the drone still climb while flying forward?
  3. Make the failsafe of SIM_RCLink level the drone and land it at 0.5 m/s instead of stopping the motors.
  4. Lower attitude_frequency to 4 rad/s. How does the drone answer the sticks?
  5. Add a height hold: a PI controller on the height, with the throttle stick setting the rate of climb instead of the thrust.

The code

// Flying a simulated quadrotor from the laptop, as with a toy drone's transmitter. The laptop
// sends RC commands, throttle, yaw, pitch and roll, over a simulated radio link; the drone's
// flight controller, in angle mode, turns them into rotor speeds; and QuadrotorDynamics flies it.
//
// Usage: quadrotor_rc_simulation [--render] [--script] [--failsafe] [--record DIR]
//
// Without --render it flies a scripted flight, headless: take off, fly forward, turn round, fly
// back and land, and it returns 0 if the drone took off, came back and landed gently. --render
// opens a window and you fly it from the keyboard; with --script as well the window shows the
// scripted flight. --failsafe stops the transmitter in the middle of the scripted flight, to show
// what the receiver does then. --record DIR writes the window to DIR, ten pictures a second.
#include "bitsim/bitsim_config.h"
#if defined(BITSIM_CHRONO) && defined(BITSIM_IRRLICHT)
#include <algorithm>
#include <array>
#include <chrono>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <memory>
#include <optional>
#include <sstream>
#include <string>
#include <thread>
#include <utility>
#include <vector>
{
const real_t DEG = PI / 180.0;
const real_t STEP_SIZE = 0.001; // [s] of the dynamics and the flight controller
const real_t SEND_PERIOD = 0.02; // [s] the transmitter sends 50 commands a second
const real_t PRINT_PERIOD = 0.5; // [s]
const real_t RENDER_RATE = 30.0; // [frames/s]
const real_t RECORD_RATE = 10.0; // [frames/s] written by --record
const real_t HARD_LANDING = 1.0; // [m/s] down, faster than this hurts the drone
const real_t FAILSAFE_AT = 7.0; // [s] when --failsafe stops the transmitter
// The quadrotor of Luukkonen, Modelling and control of quadcopter, as in the
// quadrotor_dynamics example, with some air drag
QuadrotorDynamicsConfig quadrotor_config()
{
QuadrotorDynamicsConfig config;
config.dt = STEP_SIZE;
config.mass = 0.468;
config.l = 0.225;
config.k_1 = 2.980e-6;
config.k_2 = 1.140e-7;
config.Jx = 4.856e-3;
config.Jy = 4.856e-3;
config.Jz = 8.801e-3;
config.drag = 0.25;
return config;
}
SysState<12> on_the_ground()
{
std::array<std::pair<std::string, real_t>, 12> values{{{"x", 0.0},
{"y", 0.0},
{"z", 0.0},
{"u", 0.0},
{"v", 0.0},
{"w", 0.0},
{"p", 0.0},
{"q", 0.0},
{"r", 0.0},
{"phi", 0.0},
{"theta", 0.0},
{"psi", 0.0}}};
return SysState<12>(std::move(values));
}
// ---------------------------------------------------------------------------
// The drone: its receiver, its flight controller and its dynamics
// ---------------------------------------------------------------------------
{
public:
: config_(quadrotor_config()), state_(on_the_ground()), dynamics_(config_, state_),
controller_(config_)
{
}
// The transmitter end of the radio
SIM_RCLink &radio() { return radio_; }
const SIM_RCLink &radio() const { return radio_; }
// One step: the receiver gives the latest command, the flight controller sets the rotors,
// and the dynamics move the drone. The floor stops it
void step(real_t time)
{
command_ = radio_.receive(time);
rotors_ = controller_.rotor_speeds(command_, dynamics_);
dynamics_.integrate(rotors_);
stand_on_the_floor_();
}
const QuadrotorDynamics &dynamics() const { return dynamics_; }
const QuadrotorFlightController &controller() const { return controller_; }
const RCCommand &command() const { return command_; }
const RealVec &rotors() const { return rotors_; }
real_t height() const { return -dynamics_.get_position()[2]; }
bool on_the_floor() const { return on_floor_; }
int n_hard_landings() const { return n_hard_landings_; }
real_t last_touchdown_speed() const { return touchdown_speed_; }
private:
// NED: z is down, so the floor is at z = 0 and the drone is below it when z > 0. On the floor
// it stands still and level, facing where it faced
void stand_on_the_floor_()
{
auto &s = dynamics_.get_state();
if (s.get("z") < 0.0)
{
on_floor_ = false;
return;
}
if (!on_floor_)
{
// Touching down: how fast was it coming down, in the world?
touchdown_speed_ = std::abs(dynamics_.get_velocity()[2]);
if (touchdown_speed_ > HARD_LANDING)
{
++n_hard_landings_;
}
}
on_floor_ = true;
for (const char *name : {"z", "u", "v", "w", "p", "q", "r", "phi", "theta"})
{
s.set(name, 0.0);
}
}
QuadrotorDynamicsConfig config_;
SysState<12> state_;
QuadrotorDynamics dynamics_;
QuadrotorFlightController controller_;
SIM_RCLink radio_{0.5};
RCCommand command_{};
RealVec rotors_{RealVec::Zero(4)};
bool on_floor_{true};
int n_hard_landings_{0};
real_t touchdown_speed_{0.0};
};
// ---------------------------------------------------------------------------
// The scripted flight
// ---------------------------------------------------------------------------
struct Phase
{
real_t until; // [s]
std::string name;
RCCommand sticks; // the throttle 0 means: the hover throttle plus `throttle_offset`
};
// Take off, fly forward, turn round, fly back and land. The throttle is given relative to the
// hover throttle, as a pilot feels it
std::vector<Phase> script()
{
const auto at = [](real_t until, const std::string &name, real_t throttle_offset, real_t yaw,
real_t pitch, real_t roll, bool armed = true) {
return Phase{until, name, RCCommand{0.0, yaw, pitch, roll, armed}, throttle_offset};
};
return {
at(0.5, "on the floor", -0.5, 0.0, 0.0, 0.0, false),
at(1.0, "arm", -0.5, 0.0, 0.0, 0.0),
at(2.5, "take off", 0.06, 0.0, 0.0, 0.0),
at(3.5, "level off", -0.05, 0.0, 0.0, 0.0),
at(4.5, "hover", 0.0, 0.0, 0.0, 0.0),
at(6.5, "forward", 0.02, 0.0, 0.6, 0.0),
at(8.5, "brake", 0.02, 0.0, -0.6, 0.0),
at(10.0, "turn round", 0.0, 1.0, 0.0, 0.0),
at(12.0, "forward", 0.02, 0.0, 0.6, 0.0),
at(14.0, "brake", 0.02, 0.0, -0.6, 0.0),
at(15.5, "hover", 0.0, 0.0, 0.0, 0.0),
at(22.0, "land", -0.02, 0.0, 0.0, 0.0),
at(23.0, "disarm", -0.5, 0.0, 0.0, 0.0, false),
};
}
{
public:
explicit ScriptedPilot(real_t hover_throttle) : hover_(hover_throttle), phases_(script()) {}
RCCommand command(real_t time) const
{
const Phase &p = phase(time);
RCCommand command = p.sticks;
command.throttle = std::clamp(hover_ + p.throttle_offset, 0.0, 1.0);
return command;
}
const Phase &phase(real_t time) const
{
for (const auto &p : phases_)
{
if (time < p.until)
{
return p;
}
}
return phases_.back();
}
real_t duration() const { return phases_.back().until; }
private:
real_t hover_;
std::vector<Phase> phases_;
};
// ---------------------------------------------------------------------------
// The window
// ---------------------------------------------------------------------------
// NED to Chrono's z up: (x, y, z) -> (x, -y, -z), a half turn about x. The same turn takes the
// body's NED axes to the drawing's
// ---------------------------------------------------------------------------
// Running it
// ---------------------------------------------------------------------------
struct Options
{
bool render{false};
bool script{false};
bool failsafe{false};
std::string record;
};
Options parse(int argc, char **argv)
{
Options options;
for (int i = 1; i < argc; ++i)
{
const std::string arg = argv[i];
if (arg == "--render")
{
options.render = true;
}
else if (arg == "--script")
{
options.script = true;
}
else if (arg == "--failsafe")
{
options.failsafe = true;
}
else if (arg == "--record" && i + 1 < argc)
{
options.record = argv[++i];
}
else
{
std::cout << "Usage: quadrotor_rc_simulation [--render] [--script] [--failsafe] "
"[--record DIR]\n"
<< " --render fly it from the keyboard in a window\n"
<< " --script with --render, watch the scripted flight instead\n"
<< " --failsafe stop the transmitter at " << FAILSAFE_AT
<< " s of the scripted flight\n"
<< " --record DIR write the window to DIR\n"
<< "Keys: Space arm/disarm, W/S throttle, A/D yaw, arrows pitch and roll, "
"R start again"
<< std::endl;
std::exit(arg == "--help" || arg == "-h" ? 0 : 1);
}
}
if (!options.render)
{
options.script = true;
}
return options;
}
std::string status_line(const SimulatedQuadrotor &drone, real_t time, const std::string &phase)
{
const auto &d = drone.dynamics();
const auto &c = drone.command();
const RealColVec3d p = d.get_position();
std::ostringstream out;
out << std::fixed << std::setprecision(1) << "t " << time << " s "
<< (drone.radio().in_failsafe(time) ? "FAILSAFE" : (c.armed ? "armed" : "disarmed"))
<< " throttle " << std::setprecision(2) << c.throttle << " (hover "
<< drone.controller().hover_throttle() << ") yaw " << c.yaw << " pitch " << c.pitch
<< " roll " << c.roll << " height " << drone.height() << " m x " << p[0] << " y "
<< p[1] << " m heading " << std::setprecision(0) << d.psi() / DEG << " deg " << phase;
return out.str();
}
int run(const Options &options)
{
auto drone_ptr = std::make_unique<SimulatedQuadrotor>();
const ScriptedPilot pilot(drone_ptr->controller().hover_throttle());
std::optional<bitsim::utils::render::QuadrotorView> display;
bitsim::utils::render::KeyboardRC keyboard;
if (options.render)
{
display.emplace("Flying a quadrotor from the laptop",
std::vector<bitsim::utils::render::QuadrotorView::Style>{{}},
options.record, RECORD_RATE);
if (!options.script)
{
display->vis().AddUserEventReceiver(&keyboard);
}
}
std::cout << std::fixed << std::setprecision(2) << "Quadrotor: " << quadrotor_config().mass
<< " kg, arms " << quadrotor_config().l << " m, rotors up to " << std::setprecision(0)
<< drone_ptr->controller().max_rotor_speed() << " rad/s, hover throttle "
<< std::setprecision(2) << drone_ptr->controller().hover_throttle() << "\n"
<< "Radio: a command every " << SEND_PERIOD * 1000 << " ms, failsafe after "
<< drone_ptr->radio().timeout() << " s without one\n"
<< (options.script ? "Flying the script\n" : "Flying from the keyboard\n")
<< "\n t [s] x [m] y [m] height [m] roll pitch heading [deg] throttle"
" phase\n";
real_t time = 0.0;
real_t next_send = 0.0;
real_t next_print = 0.0;
real_t next_frame = 0.0;
real_t max_height = 0.0;
real_t max_tilt = 0.0;
real_t max_distance = 0.0;
bool flew = false;
const real_t limit = options.script ? pilot.duration() + 1.0 : 1.0e9;
const auto wall_start = std::chrono::steady_clock::now();
while (time < limit)
{
const std::string phase = options.script ? pilot.phase(time).name : "keyboard";
// The transmitter: the script or the keyboard, 50 times a second, unless --failsafe has
// stopped it
if (time + 1e-9 >= next_send)
{
next_send += SEND_PERIOD;
const bool silent = options.failsafe && time >= FAILSAFE_AT;
if (!silent)
{
drone_ptr->radio().send(
options.script ? pilot.command(time) : keyboard.command(SEND_PERIOD), time);
}
}
drone_ptr->step(time);
time += STEP_SIZE;
const auto &d = drone_ptr->dynamics();
max_height = std::max(max_height, drone_ptr->height());
max_tilt = std::max({max_tilt, std::abs(d.phi()), std::abs(d.theta())});
max_distance = std::max(max_distance, std::hypot(d.get_position()[0], d.get_position()[1]));
flew = flew || drone_ptr->height() > 0.2;
if (time + 1e-9 >= next_print)
{
next_print += PRINT_PERIOD;
const RealColVec3d p = d.get_position();
std::cout << std::setw(9) << std::setprecision(1) << time << std::setprecision(2)
<< std::setw(8) << clean(p[0]) << std::setw(8) << clean(p[1]) << std::setw(12)
<< clean(drone_ptr->height()) << std::setprecision(1) << std::setw(6)
<< clean(d.phi() / DEG) << std::setw(7) << clean(d.theta() / DEG)
<< std::setw(15) << clean(d.psi() / DEG) << std::setprecision(2)
<< std::setw(10) << drone_ptr->command().throttle << " "
<< (drone_ptr->radio().in_failsafe(time) ? "FAILSAFE" : phase) << std::endl;
}
if (display && time + 1e-9 >= next_frame)
{
next_frame += 1.0 / RENDER_RATE;
if (keyboard.reset_requested())
{
drone_ptr = std::make_unique<SimulatedQuadrotor>();
keyboard.reset();
}
if (!display->show({&drone_ptr->dynamics()}, time,
status_line(*drone_ptr, time, phase)))
{
break;
}
const real_t ahead =
time - std::chrono::duration<real_t>(std::chrono::steady_clock::now() - wall_start)
.count();
if (ahead > 0.0)
{
std::this_thread::sleep_for(std::chrono::duration<real_t>(ahead));
}
}
}
const RealColVec3d p = drone_ptr->dynamics().get_position();
const real_t from_start = std::hypot(p[0], p[1]);
std::cout << std::setprecision(2) << "\nHighest " << max_height << " m, furthest "
<< max_distance << " m from the start, most tilt " << std::setprecision(1)
<< max_tilt / DEG << " deg\n"
<< std::setprecision(2) << "Ended "
<< (drone_ptr->on_the_floor() ? "on the floor" : "in the air") << ", " << from_start
<< " m from the start; touched down at " << drone_ptr->last_touchdown_speed()
<< " m/s; hard landings: " << drone_ptr->n_hard_landings() << std::endl;
if (!options.script)
{
return 0;
}
const bool ok = flew && drone_ptr->on_the_floor() && drone_ptr->n_hard_landings() == 0 &&
from_start < 1.0 &&
max_tilt < drone_ptr->controller().parameters().max_tilt + 0.05;
return options.failsafe ? 0 : (ok ? 0 : 1);
}
} // namespace quadrotor_rc_simulation
int main(int argc, char **argv)
{
try
{
}
catch (const std::exception &e)
{
std::cerr << "Error: " << e.what() << std::endl;
return 1;
}
}
#else
#include <iostream>
int main()
{
std::cerr << "quadrotor_rc_simulation needs bitsim configured with Chrono and Irrlicht"
<< std::endl;
return 1;
}
#endif
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
The flight controller of a toy quadrotor in angle mode: it turns the sticks of an RCCommand into roto...
Definition quadrotor_flight_controller.h:52
The QuadrotorDynamics class. Implements quadrotor dynamics The implementation of this class follows t...
Definition quadrotor_dynamics.h:134
SysState utility class describing the state of a system.
Definition system_state.h:25
control::RCCommand command(real_t dt)
The command for the keys held now, dt [s] after the last call.
Definition keyboard_rc.cpp:70
bool reset_requested()
True once after R was pressed.
Definition keyboard_rc.cpp:88
void reset()
Put the throttle down and disarm.
Definition keyboard_rc.cpp:95
Definition quadrotor_rc_simulation.cpp:215
const Phase & phase(real_t time) const
Definition quadrotor_rc_simulation.cpp:227
ScriptedPilot(real_t hover_throttle)
Definition quadrotor_rc_simulation.cpp:217
real_t duration() const
Definition quadrotor_rc_simulation.cpp:239
RCCommand command(real_t time) const
Definition quadrotor_rc_simulation.cpp:219
Definition quadrotor_rc_simulation.cpp:106
const QuadrotorDynamics & dynamics() const
Definition quadrotor_rc_simulation.cpp:128
SIM_RCLink & radio()
Definition quadrotor_rc_simulation.cpp:115
real_t last_touchdown_speed() const
Definition quadrotor_rc_simulation.cpp:136
void step(real_t time)
Definition quadrotor_rc_simulation.cpp:120
const RealVec & rotors() const
Definition quadrotor_rc_simulation.cpp:131
SimulatedQuadrotor()
Definition quadrotor_rc_simulation.cpp:108
real_t height() const
Definition quadrotor_rc_simulation.cpp:133
const QuadrotorFlightController & controller() const
Definition quadrotor_rc_simulation.cpp:129
const RCCommand & command() const
Definition quadrotor_rc_simulation.cpp:130
int n_hard_landings() const
Definition quadrotor_rc_simulation.cpp:135
bool on_the_floor() const
Definition quadrotor_rc_simulation.cpp:134
int main()
Definition discounted_returns.cpp:19
Fly a quadrotor from the keyboard of an Irrlicht window, as with the sticks of a transmitter....
const real_t PI
The PI constant.
Definition bitsim_consts.h:63
real_t clean(real_t x, real_t zero)
x, or 0 when zero
Definition print_utils.cpp:15
DynVec< real_t > RealVec
double precision floating point vector
Definition bitsim_types.h:111
double real_t
real_t
Definition bitsim_types.h:20
Eigen::Vector3d RealColVec3d
3D column vector
Definition bitsim_types.h:137
Definition quadrotor_rc_simulation.cpp:44
const real_t HARD_LANDING
Definition quadrotor_rc_simulation.cpp:64
const real_t FAILSAFE_AT
Definition quadrotor_rc_simulation.cpp:65
SysState< 12 > on_the_ground()
Definition quadrotor_rc_simulation.cpp:84
const real_t RECORD_RATE
Definition quadrotor_rc_simulation.cpp:63
int run(const Options &options)
Definition quadrotor_rc_simulation.cpp:323
const real_t STEP_SIZE
Definition quadrotor_rc_simulation.cpp:59
const real_t RENDER_RATE
Definition quadrotor_rc_simulation.cpp:62
const real_t PRINT_PERIOD
Definition quadrotor_rc_simulation.cpp:61
real_t clean(real_t x, real_t zero=5.0e-4)
x, or 0 when zero
Definition print_utils.cpp:15
const real_t PI
Definition quadrotor_rc_simulation.cpp:57
const real_t DEG
Definition quadrotor_rc_simulation.cpp:58
Options parse(int argc, char **argv)
Definition quadrotor_rc_simulation.cpp:264
const real_t SEND_PERIOD
Definition quadrotor_rc_simulation.cpp:60
std::string status_line(const SimulatedQuadrotor &drone, real_t time, const std::string &phase)
Definition quadrotor_rc_simulation.cpp:308
std::vector< Phase > script()
Definition quadrotor_rc_simulation.cpp:191
QuadrotorDynamicsConfig quadrotor_config()
Definition quadrotor_rc_simulation.cpp:69
Print labelled values, one per line, as the examples do: two spaces, the label padded to a width,...
An Irrlicht window that shows quadrotors flying over a tiled floor. Needs bitsim built with Chrono an...
What the sticks of a radio transmitter for a quadrotor say, as a toy drone's transmitter sends them: ...
Definition rc_command.h:20
Definition quadrotor_dynamics.h:13
real_t mass
mass
Definition quadrotor_dynamics.h:27
real_t dt
The time step to use.
Definition quadrotor_dynamics.h:56
real_t l
the arm length
Definition quadrotor_dynamics.h:32
Definition quadrotor_rc_simulation.cpp:257
bool render
Definition quadrotor_rc_simulation.cpp:258
std::string record
Definition quadrotor_rc_simulation.cpp:261
bool failsafe
Definition quadrotor_rc_simulation.cpp:260
bool script
Definition quadrotor_rc_simulation.cpp:259
Definition quadrotor_rc_simulation.cpp:182
real_t throttle_offset
Definition quadrotor_rc_simulation.cpp:186
real_t until
Definition quadrotor_rc_simulation.cpp:183
RCCommand sticks
Definition quadrotor_rc_simulation.cpp:185
std::string name
Definition quadrotor_rc_simulation.cpp:184