amiro-os / include / amiro / ControllerAreaNetworkTx.h @ 2af9778e
History | View | Annotate | Download (3.12 KB)
1 |
#ifndef AMIRO_CONTROLLER_AREA_NETWORK_TX_H_
|
---|---|
2 |
#define AMIRO_CONTROLLER_AREA_NETWORK_TX_H_
|
3 |
|
4 |
#include <evtimer.h> |
5 |
#include <amiro/Color.h> |
6 |
#include <Types.h> // ::kinematic |
7 |
|
8 |
#include <amiro/Constants.h> // CAN::* macros |
9 |
|
10 |
namespace amiro { |
11 |
|
12 |
class ControllerAreaNetworkTx : public chibios_rt::BaseStaticThread<128> {
|
13 |
public:
|
14 |
ControllerAreaNetworkTx(CANDriver *can, const uint8_t boardId);
|
15 |
virtual ~ControllerAreaNetworkTx() = 0;
|
16 |
|
17 |
/**
|
18 |
* \brief Setting the brightness of the light ring
|
19 |
*
|
20 |
* @param brightness Brightness level 0 .. 200
|
21 |
*/
|
22 |
void setLightBrightness(int brightness); |
23 |
|
24 |
/**
|
25 |
* \brief Setting the color of the LED with the given index
|
26 |
*
|
27 |
* @param index Index of the LED
|
28 |
* @param color Color of the LED
|
29 |
*/
|
30 |
void setLightColor(int index, Color color); |
31 |
|
32 |
/**
|
33 |
* \brief Setting the desired speed in as kinematic struct
|
34 |
*
|
35 |
* @param targetSpeed Desired speed of the robot
|
36 |
*/
|
37 |
void setTargetSpeed(types::kinematic &targetSpeed);
|
38 |
|
39 |
/**
|
40 |
* \brief Setting the desired speed in ยต rounds per minute
|
41 |
*
|
42 |
* @param leftURpm Desired speed of the left wheel
|
43 |
* @param rightURpm Desired speed of the right wheel
|
44 |
*/
|
45 |
void setTargetSpeed(int32_t leftURpm, int32_t rightURpm);
|
46 |
|
47 |
/**
|
48 |
* \brief Setting odometry for the Euler-Collatz algorithm on the DiWheelDrive board
|
49 |
*
|
50 |
* \notice Only bits 31..8 of robotPosition.x and robotPosition.y will be sent,
|
51 |
* i.e. values are divided by 1024 before being sent.
|
52 |
* Only bits 23..8 of orientation vector f_z be sent, i.e.
|
53 |
* f_z is devided by 1024 and clamped to int16_t.
|
54 |
* To avoid buffer overflow, only values between between [0, 2 * pi * 1e6] are valid.
|
55 |
* This is due to size constraints of CAN message frames.
|
56 |
*
|
57 |
* @param robotPosition Desired robot position.
|
58 |
*/
|
59 |
void setOdometry(types::position robotPosition);
|
60 |
|
61 |
/**
|
62 |
* \brief Setting target position of current robot
|
63 |
* local frame
|
64 |
*
|
65 |
* @param targetPosition Desired robot position
|
66 |
* @param targetTime Desired time reaching this position
|
67 |
*/
|
68 |
void setTargetPosition(types::position &targetPosition, uint32_t targetTime);
|
69 |
|
70 |
/**
|
71 |
* \brief Setting correction ratios of the differential kinematic
|
72 |
*
|
73 |
* @param Ed Diameter ratio
|
74 |
* @param Eb Base width ratio
|
75 |
*/
|
76 |
void setKinematicConstants(float Ed, float Eb); |
77 |
|
78 |
void txQueryShell(uint8_t toBoardId, char *textdata, uint16_t size); |
79 |
void txReplyShell(uint8_t toBoardId, char *textdata, uint16_t size); |
80 |
|
81 |
void broadcastShutdown();
|
82 |
|
83 |
protected:
|
84 |
virtual msg_t main(); |
85 |
virtual msg_t updateSensorVal(); |
86 |
void transmitMessage(CANTxFrame *frame);
|
87 |
virtual void periodicBroadcast() = 0; |
88 |
|
89 |
void encodeBoardId(CANTxFrame *frame, int board); |
90 |
void encodeDeviceId(CANTxFrame *frame, int device); |
91 |
void encodeIndexId(CANTxFrame *frame, int index); |
92 |
|
93 |
int boardId;
|
94 |
chibios_rt::EvtListener eventTimerEvtListener; |
95 |
chibios_rt::EvtSource *eventTimerEvtSource; |
96 |
|
97 |
private:
|
98 |
EvTimer evtimer; |
99 |
CANDriver *canDriver; |
100 |
CANConfig canConfig; |
101 |
|
102 |
}; |
103 |
|
104 |
} |
105 |
|
106 |
#endif /* AMIRO_CONTROLLER_AREA_NETWORK_TX_H_ */ |