bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
rc_command.h
Go to the documentation of this file.
1#ifndef BITSIM_CONTROL_RC_COMMAND_H
2#define BITSIM_CONTROL_RC_COMMAND_H
3
5
6namespace bitsim
7{
8namespace control
9{
10
20{
22 real_t yaw{0.0};
24 real_t roll{0.0};
25 bool armed{false};
26
30 RCCommand clamped() const noexcept;
31};
32
37inline RCCommand failsafe_command() noexcept { return RCCommand{}; }
38
39inline RCCommand RCCommand::clamped() const noexcept
40{
41 const auto clamp = [](real_t x, real_t lo, real_t hi)
42 { return x < lo ? lo : (x > hi ? hi : x); };
43 return {clamp(throttle, 0.0, 1.0), clamp(yaw, -1.0, 1.0), clamp(pitch, -1.0, 1.0),
44 clamp(roll, -1.0, 1.0), armed};
45}
46
47} // namespace control
48} // namespace bitsim
49
50#endif // BITSIM_CONTROL_RC_COMMAND_H
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
RCCommand failsafe_command() noexcept
What a receiver does when it loses the transmitter: disarm, so the motors stop.
Definition rc_command.h:37
Controllers: PID controllers, line following, a quadrotor flight controller, a fixed wing autopilot,...
Definition control_module.h:18
Definition dc_motor_backend_base.h:9
double real_t
real_t
Definition bitsim_types.h:20
What the sticks of a radio transmitter for a quadrotor say, as a toy drone's transmitter sends them: ...
Definition rc_command.h:20
real_t roll
[-1, 1]: + flies to the right, right side down
Definition rc_command.h:24
real_t yaw
[-1, 1]: + turns to the right
Definition rc_command.h:22
bool armed
the motors spin only when armed
Definition rc_command.h:25
RCCommand clamped() const noexcept
The command with the throttle in [0, 1] and the sticks in [-1, 1].
Definition rc_command.h:39
real_t throttle
[0, 1]: 0 the motors off, 1 full thrust
Definition rc_command.h:21
real_t pitch
[-1, 1]: + flies forward, nose down
Definition rc_command.h:23