-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVesc.h
68 lines (44 loc) · 1.48 KB
/
Vesc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef VESC_H
#define VESC_H
#include <string>
#include <unordered_map>
#include "commands.h"
namespace {
using std::unordered_map;
using std::string;
}
namespace vesc {
class Vesc {
public:
Vesc();
virtual ~Vesc() = default;
void FindandMapMotorControllers();
void SetWheelsRPM(unordered_map<int, int> wheel_rpms);
void SetWheelsDuty(unordered_map<int, double> wheel_duty);
unordered_map<int, double> GetWheelsRPM();
unordered_map<int, MC_VALUES> GetSelectMotorData();
unordered_map<int, MC_VALUES> GetAllMotorData();
bool isTwoWheelDrive();
bool isFourWheelDrive();
bool anyWheels() { return any_of(begin(wheel_found), end(wheel_found), [](auto kv) { return kv.second; }); }
unordered_map<int, bool> Wheels() { return wheel_found; }
enum wheel_ids {
left_back = 100,
right_back = 200,
left_front = 300,
right_front = 400
};
private:
const Packet m_VescIDPacket;
const Packet m_KeepAlivePacket;
const Packet m_AllMotorDataPacket;
const Packet m_SelectmotorDataPacket;
const Packet m_RPMPacket;
Commands cmd;
bool SendAndReceive(const Packet &packet, const string &port);
bool SendAndReceive(const Packet &packet, const int &port);
unordered_map<int, string> wheel_ports;
unordered_map<int, bool> wheel_found;
};
}
#endif //VESC_H