bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
keyboard_rc.h
Go to the documentation of this file.
1#ifndef BITSIM_UTILS_RENDER_KEYBOARD_RC_H
2#define BITSIM_UTILS_RENDER_KEYBOARD_RC_H
3
9
10#include "bitsim/bitsim_config.h"
11
12#if defined(BITSIM_IRRLICHT) && defined(BITSIM_CHRONO)
13
14#include "bitsim/bitsim_types.h"
16
17#include <irrlicht.h>
18
19#include <array>
20
21namespace bitsim
22{
23namespace utils
24{
25namespace render
26{
27
46class KeyboardRC : public irr::IEventReceiver
47{
48 public:
53 explicit KeyboardRC(real_t throttle_rate = 0.25, real_t deflection = 1.0);
54
55 bool OnEvent(const irr::SEvent &event) override;
56
61
65 bool reset_requested();
66
70 void reset();
71
75 void set_key(irr::EKEY_CODE key, bool down);
76
77 private:
78 bool is_down_(irr::EKEY_CODE key) const { return down_[key]; }
79
80 real_t throttle_rate_;
81 real_t deflection_;
82 real_t throttle_{0.0};
83 bool armed_{false};
84 bool reset_{false};
85 std::array<bool, irr::KEY_KEY_CODES_COUNT> down_{};
86};
87
88} // namespace render
89} // namespace utils
90} // namespace bitsim
91
92#endif
93#endif // BITSIM_UTILS_RENDER_KEYBOARD_RC_H
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
control::RCCommand command(real_t dt)
The command for the keys held now, dt [s] after the last call.
Definition keyboard_rc.cpp:70
void set_key(irr::EKEY_CODE key, bool down)
Hold a key down or let it go, as if it were pressed, for tests and scripts.
Definition keyboard_rc.cpp:42
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
KeyboardRC(real_t throttle_rate=0.25, real_t deflection=1.0)
Definition keyboard_rc.cpp:37
bool OnEvent(const irr::SEvent &event) override
Definition keyboard_rc.cpp:59
Definition irrlicht_scene.cpp:20
Definition bitsim_utils.h:11
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