Thunderbots Project
Loading...
Searching...
No Matches
power.h
1#pragma once
2
3#include <atomic>
4#include <thread>
5
6#include "proto/power_frame_msg.pb.h"
7#include "shared/uart_framing/uart_framing.hpp"
8#include "software/logger/logger.h"
9#include "software/uart/boost_uart_communication.h"
10
11extern "C"
12{
13#include "proto/power_frame_msg.nanopb.h"
14}
15
17{
18 public:
25
33 TbotsProto::PowerStatus poll(const TbotsProto::PowerControl& control,
34 double kick_coeff, int kick_constant, int chip_constant);
35
39 void tick();
40
41 private:
45 void continuousRead();
46
47 std::thread read_thread;
48 std::atomic<TbotsProto_PowerStatus> status;
49 std::atomic<TbotsProto_PowerPulseControl> nanopb_command;
50 std::unique_ptr<BoostUartCommunication> uart;
51
52 // Constants
53 const size_t READ_BUFFER_SIZE =
54 getMarshalledSize(TbotsProto_PowerStatus TbotsProto_PowerStatus_init_default);
55 const std::string DEVICE_SERIAL_PORT = "/dev/ttyUSB0";
56 static constexpr unsigned int BAUD_RATE = 460800;
57
58 // Required flag to exit power service cleanly
59 bool is_running = true;
60};
Definition power.h:17
TbotsProto::PowerStatus poll(const TbotsProto::PowerControl &control, double kick_coeff, int kick_constant, int chip_constant)
Definition power.cpp:78
void tick()
Definition power.cpp:35
PowerService()
Definition power.cpp:9