Robot angle is now a float and therefore converted as a int16_t when sended
This commit is contained in:
parent
5512d868ed
commit
d964cdf9cf
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <pico/types.h>
|
#include <pico/types.h>
|
||||||
|
|
||||||
#define ANGLE_PER_SECOND 45
|
#define ANGLE_PER_SECOND 90
|
||||||
|
|
||||||
typedef enum buttons_t {
|
typedef enum buttons_t {
|
||||||
BUTTON_L,
|
BUTTON_L,
|
||||||
|
@ -31,7 +31,7 @@ extern const button_def_t BUTTONS_DEFS[];
|
||||||
typedef struct inputs_buffer_t {
|
typedef struct inputs_buffer_t {
|
||||||
int8_t x_axis_speed;
|
int8_t x_axis_speed;
|
||||||
int8_t y_axis_speed;
|
int8_t y_axis_speed;
|
||||||
int16_t robot_angle;
|
float robot_angle;
|
||||||
bool buttons_states[NB_BUTTONS];
|
bool buttons_states[NB_BUTTONS];
|
||||||
} inputs_buffer_t;
|
} inputs_buffer_t;
|
||||||
|
|
||||||
|
|
|
@ -93,8 +93,8 @@ void udp_server_send(void)
|
||||||
|
|
||||||
for(uint i = 0; i < 16; i++) data[i] = 0;
|
for(uint i = 0; i < 16; i++) data[i] = 0;
|
||||||
|
|
||||||
data[UDP_PAYLOAD_ANGLE_L_BYTE] = controller.inputs_buffer.robot_angle & 0xff;
|
data[UDP_PAYLOAD_ANGLE_L_BYTE] = ((int16_t)controller.inputs_buffer.robot_angle) & 0xff;
|
||||||
data[UDP_PAYLOAD_ANGLE_H_BYTE] = (controller.inputs_buffer.robot_angle >> 8) & 0xff;
|
data[UDP_PAYLOAD_ANGLE_H_BYTE] = (((int16_t)controller.inputs_buffer.robot_angle) >> 8) & 0xff;
|
||||||
data[UDP_PAYLOAD_X_AXIS_SPEED_BYTE] = *(uint8_t *)&controller.inputs_buffer.x_axis_speed;
|
data[UDP_PAYLOAD_X_AXIS_SPEED_BYTE] = *(uint8_t *)&controller.inputs_buffer.x_axis_speed;
|
||||||
data[UDP_PAYLOAD_Y_AXIS_SPEED_BYTE] = *(uint8_t *)&controller.inputs_buffer.y_axis_speed;
|
data[UDP_PAYLOAD_Y_AXIS_SPEED_BYTE] = *(uint8_t *)&controller.inputs_buffer.y_axis_speed;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue