Formula Student Electronics & Software
The code for the embedded software
Loading...
Searching...
No Matches
utils.hpp
Go to the documentation of this file.
1#pragma once
2#include <Arduino.h>
3
5
9void create_left_wheel_msg(std::array<uint8_t, 5> &msg, double value) {
10 value /= WHEEL_PRECISION; // take precision off to send integer value
11 if (value < 0) value = 0;
12
14 // Copy the bytes of the double value to msg[1] to msg[4]
15 for (int i = 0; i < 4; i++)
16 msg[i + 1] = static_cast<int>(value) >> (8 * i); // shift 8(byte) to msb each time
17}
constexpr auto LEFT_WHEEL_MSG
constexpr auto WHEEL_PRECISION
CAN_message_t msg
void create_left_wheel_msg(std::array< uint8_t, 5 > &msg, double value)
Function to create left wheel msg.
Definition utils.hpp:9