4#include <freertos/FreeRTOS.h>
5#include <freertos/queue.h>
6#include "freertos/semphr.h"
27#include "coproc_link_parser.h"
32class MotorChangeBuilder;
51 static_cast<int>(a) |
static_cast<int>(b));
88 BaseType_t managerLoopStackSize = 3072);
120 return m_motors[
static_cast<int>(id)];
134 void schedule(uint32_t period_ms, std::function<
bool()> callback) {
146 return m_coprocFwVersion;
155 static void consumerRoutineTrampoline(
void* cookie);
156 void consumerRoutine();
158 static void keepaliveRoutine(
void* cookie);
160 void resetMotorsFailSafe();
161 bool motorsFailSafe();
163#ifdef RB_DEBUG_MONITOR_TASKS
164 bool printTasksDebugInfo();
166 std::vector<TaskHandle_t> m_tasks;
167 std::mutex m_tasks_mutex;
169 void fault(CoprocStat_FaultStat faultStat);
171 TaskHandle_t m_keepaliveTask;
174 uint8_t m_txBuf[CoprocCodec::MaxFrameSize];
175 std::mutex m_codecTxMutex;
177 uint16_t m_coprocWatchdogTimer;
179 CoprocStat_VersionStat m_coprocFwVersion;
180 SemaphoreHandle_t m_coprocSemaphore;
182 TickType_t m_motors_last_set;
263 std::vector<std::function<void()>> m_calls;
Contains the battery state and can control the robot's power.
Definition: RBCXBattery.h:12
Definition: RBCXLeds.h:31
The main library class for working with the RBCX board. Call the install() method at the start of you...
Definition: RBCXManager.h:61
void sendToCoproc(const CoprocReq &msg)
Definition: RBCXManager.cpp:185
void install(ManagerInstallFlags flags=MAN_NONE, BaseType_t managerLoopStackSize=3072)
Initialize the manager - must be called once at the start of the program.
Definition: RBCXManager.cpp:25
Timers & timers()
Definition: RBCXManager.h:138
void coprocFwVersionAssert(uint32_t minVersion, const char *name)
Definition: RBCXManager.cpp:197
static Manager & get()
Get manager instance.
Definition: RBCXManager.h:77
friend class PcntInterruptHandler
Definition: RBCXManager.h:64
Motor & motor(MotorId id)
Definition: RBCXManager.h:119
Leds & leds()
Get the Leds helper.
Definition: RBCXManager.h:116
Battery & battery()
Get the Battery interface.
Definition: RBCXManager.h:113
Mpu & mpu()
Get the Piezo controller.
Definition: RBCXManager.h:107
Oled & oled()
Get the Piezo controller.
Definition: RBCXManager.h:106
friend class Encoder
Definition: RBCXManager.h:63
StupidServo & stupidServo(uint8_t index)
Definition: RBCXManager.cpp:216
void monitorTask(TaskHandle_t task)
Definition: RBCXManager.cpp:246
Ultrasound & ultrasound(uint8_t index)
Initialize the UART servo bus for intelligent servos LX-16. TODO: smart servos not implemented!
Definition: RBCXManager.h:102
void schedule(uint32_t period_ms, std::function< bool()> callback)
Schedule callback to fire after period (in millisecond).
Definition: RBCXManager.h:134
MotorChangeBuilder setMotors()
Get a motor instance.
Definition: RBCXManager.cpp:244
Manager(Manager const &)=delete
const CoprocStat_VersionStat & coprocFwVersion() const
Definition: RBCXManager.h:145
Piezo & piezo()
Get the Piezo controller.
Definition: RBCXManager.h:112
SmartServoBusBackend & smartServoBusBackend()
Definition: RBCXManager.cpp:211
void operator=(Manager const &)=delete
Buttons & buttons()
Definition: RBCXManager.h:117
Helper class for building the motor change event.
Definition: RBCXManager.h:198
void set()
Finish the changes and submit the events. This method must be called at the end of the motor change e...
Definition: RBCXManager.cpp:340
MotorChangeBuilder & drive(MotorId id, int32_t positionRelative, int16_t speedTicksPerSecond, Motor::callback_t callback=nullptr)
Drive motor to relative position.
Definition: RBCXManager.cpp:319
MotorChangeBuilder & driveToValue(MotorId id, int32_t positionAbsolute, int16_t speedTicksPerSecond, Motor::callback_t callback=nullptr)
Drive motor to absolute position.
Definition: RBCXManager.cpp:330
MotorChangeBuilder(const MotorChangeBuilder &o)=delete
MotorChangeBuilder & brake(MotorId id, uint16_t brakingPower)
Start braking.
Definition: RBCXManager.cpp:312
MotorChangeBuilder & power(MotorId id, int16_t value)
Set single motor power.
Definition: RBCXManager.cpp:292
MotorChangeBuilder()
Definition: RBCXManager.cpp:285
MotorChangeBuilder & speed(MotorId id, int16_t ticksPerSecond)
Set single motor power.
Definition: RBCXManager.cpp:298
MotorChangeBuilder & pwmMaxPercent(MotorId id, int8_t percent)
Limit motor index's power to percent.
Definition: RBCXManager.cpp:305
~MotorChangeBuilder()
Definition: RBCXManager.cpp:290
Definition: RBCXMotor.h:19
std::function< void(Motor &)> callback_t
Definition: RBCXMotor.h:24
Helper class for controlling the Mpu.
Definition: RBCXMpu.h:33
Helper class for controlling the Oled.
Definition: RBCXOled.h:11
Helper class for controlling the piezo.
Definition: RBCXPiezo.h:10
Definition: RBCXSmartServoBusBackend.h:11
Definition: RBCXStupidServo.h:12
Definition: RBCXTimers.h:14
uint16_t schedule(uint32_t period_ms, std::function< bool()> callback)
Schedule callback to fire after period (in millisecond).
Definition: RBCXTimers.cpp:44
static Timers & get()
Definition: RBCXTimers.cpp:19
Definition: RBCXUltrasound.h:17
Definition: RBCXAngle.cpp:3
static constexpr int UltrasoundsCount
Definition: RBCXPinout.h:27
ManagerInstallFlags operator|(ManagerInstallFlags a, ManagerInstallFlags b)
Definition: RBCXManager.h:48
MotorId
Definition: RBCXPinout.h:8
ManagerInstallFlags
This enum contains flags for the Manager's install() method.
Definition: RBCXManager.h:35
@ MAN_DISABLE_ESP_WATCHDOG
Definition: RBCXManager.h:45
@ MAN_DISABLE_MOTOR_FAILSAFE
Definition: RBCXManager.h:39
@ MAN_NONE
Definition: RBCXManager.h:36