Skip to content

Commit

Permalink
Orin uart fixed, autoaim tuned a little
Browse files Browse the repository at this point in the history
  • Loading branch information
CuboiLeo committed Apr 27, 2024
1 parent 9a370b1 commit a064785
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/app/src/debug_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ char g_debug_buffer[1024*2] = {0};
const char* top_border = "\r\n\r\n\r\n/***** System Info *****/\r\n";
const char* bottom_border = "/***** End of Info *****/\r\n";

#define DEBUG_ENABLED
// #define DEBUG_ENABLED

void Debug_Task_Loop(void)
{
Expand Down
4 changes: 2 additions & 2 deletions src/app/src/gimbal_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ void Gimbal_Ctrl_Loop()
g_pitch->angle_pid->kd = 400.0f;
g_pitch->velocity_pid->kp = 4500.0f;
g_pitch->velocity_pid->ki = 0.8f;
DJI_Motor_Set_Angle(g_pitch, g_robot_state.gimbal_pitch_angle - 12.5f / 180.0f * PI);
DJI_Motor_Set_Angle(g_yaw, g_robot_state.gimbal_yaw_angle - 2.0f / 180.0f * PI);
DJI_Motor_Set_Angle(g_pitch, g_robot_state.gimbal_pitch_angle);
DJI_Motor_Set_Angle(g_yaw, g_robot_state.gimbal_yaw_angle);
} else {
g_yaw->angle_pid->kp = 20.0f;
g_yaw->angle_pid->kd = 150.0f;
Expand Down
14 changes: 7 additions & 7 deletions src/app/src/robot.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ void Robot_Cmd_Loop()
__MAX_LIMIT(g_robot_state.chassis_y_speed, -MAX_SPEED, MAX_SPEED);

/* power buffer*/
float power_buffer = Referee_System.Power_n_Heat.Chassis_Power_Buffer / 60.0f;
if (power_buffer < 0.8f)
{
g_robot_state.chassis_x_speed *= pow(power_buffer,1);
g_robot_state.chassis_y_speed *= pow(power_buffer,1);
g_robot_state.chassis_omega *= pow(power_buffer,1);
}
// float power_buffer = Referee_System.Power_n_Heat.Chassis_Power_Buffer / 60.0f;
// if (power_buffer < 0.8f)
// {
// g_robot_state.chassis_x_speed *= pow(power_buffer,1);
// g_robot_state.chassis_y_speed *= pow(power_buffer,1);
// g_robot_state.chassis_omega *= pow(power_buffer,1);
// }
}
}
else
Expand Down
5 changes: 4 additions & 1 deletion src/devices/inc/jetson_orin.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

#include <stdint.h>
#include "bsp_uart.h"
#include "referee_system.h"

#define ORIN_DATA_RX_BUFER_SIZE (20)
#define ORIN_DATA_TX_BUFER_SIZE (33)
#define ORIN_DATA_TX_BUFER_SIZE (34)

#define ORIN_TIMEOUT_MS (3000)
#define JETSON_ORIN_PERIOD (100)
Expand All @@ -26,6 +27,8 @@ typedef struct
float orientation; // rad
float velocity_x; // m/s
float velocity_y; // m/s
uint8_t game_start_flag; //1 for start and 0 for not start
uint8_t enemy_color_flag; //1 for red and 0 for blue

union
{
Expand Down
7 changes: 5 additions & 2 deletions src/devices/src/jetson_orin.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ void Jetson_Orin_Send_Data(void)
g_orin_data.sending.orientation = g_imu.rad.yaw;
g_orin_data.sending.velocity_x = 0;
g_orin_data.sending.velocity_y = 0;
g_orin_data.sending.game_start_flag = (Referee_System.Game_Status.Progress == 4) ? 1 : 0; //4 for match begin
g_orin_data.sending.enemy_color_flag = (Referee_Robot_State.ID > 11) ? 1 : 0; //ID > 11 means myself is blue, which means enemy is red

// float to byte conversion
g_orin_data.sending.float_byte.data[0] = g_orin_data.sending.pitch_angle;
Expand All @@ -99,7 +101,8 @@ void Jetson_Orin_Send_Data(void)
g_orin_data.sending.float_byte.data[7] = g_orin_data.sending.velocity_y;

g_orin_data.tx_buffer[0] = 0xAA;
memcpy(&g_orin_data.tx_buffer[1],&g_orin_data.sending.float_byte.data_bytes[0], 32*sizeof(uint8_t));
g_orin_data.tx_buffer[1] = g_orin_data.sending.enemy_color_flag << 1 | g_orin_data.sending.game_start_flag;
memcpy(&g_orin_data.tx_buffer[2],&g_orin_data.sending.float_byte.data_bytes[0], 32*sizeof(uint8_t));

//UART_Transmit(g_orin_uart_instance_ptr, g_orin_data.tx_buffer, sizeof(g_orin_data.tx_buffer), UART_DMA);
UART_Transmit(g_orin_uart_instance_ptr, g_orin_data.tx_buffer, sizeof(g_orin_data.tx_buffer), UART_DMA);
}

0 comments on commit a064785

Please sign in to comment.