Skip to content

Commit

Permalink
rename autoaim_protocol as minipc_protocol; add more comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
AzulRadio committed Nov 21, 2023
1 parent 7a07240 commit a1cb494
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 21 deletions.
4 changes: 2 additions & 2 deletions examples/autoaim/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "gimbal.h"
#include "rgb.h"
#include "bsp_gpio.h"
#include "autoaim_protocol.h"
#include "minipc_protocol.h"
#include "filtering.h"
#include "i2c.h"
#include "bsp_imu.h"
Expand Down Expand Up @@ -305,4 +305,4 @@ void RM_RTOS_Default_Task(const void* args) {
control::MotorCANBase::TransmitOutput(motors, 2);
osDelay(10);
}
}
}
8 changes: 4 additions & 4 deletions examples/minipc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ project(example_minipc ASM C CXX)
# TARGET DJI_Board_TypeA
# SOURCES typeA.cc)
#
irm_add_arm_executable(${PROJECT_NAME}_typeC
irm_add_arm_executable(${PROJECT_NAME}_stresstesttypec
TARGET DJI_Board_TypeC
SOURCES typeC.cc)
SOURCES StressTestTypeC.cc)

irm_add_arm_executable(${PROJECT_NAME}_test
irm_add_arm_executable(${PROJECT_NAME}_pingpongtest
TARGET DJI_Board_TypeC
SOURCES test.cc)
SOURCES PingpongTest.cc)

29 changes: 18 additions & 11 deletions examples/minipc/test.cc → examples/minipc/PingpongTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "bsp_print.h"
#include "bsp_uart.h"
#include "cmsis_os.h"
#include "autoaim_protocol.h"
#include "minipc_protocol.h"
#include "rgb.h"

#define RX_SIGNAL (1 << 0)
Expand Down Expand Up @@ -86,9 +86,14 @@ void RM_RTOS_Default_Task(const void* argument) {
/* wait until rx data is available */
//led->Display(0xFF0000FF);

// TX RX test, see vision repo communication/communicator.py
// TX RX test. Use with communication/communicator.py in iRM_Vision_2023 repo
// In the communicator.py, need to set TESTING_TX_RX = True for this test
// The value for TESTING_CRC doesn't matter

// Wait until first packet from minipc.
uint32_t flags = osThreadFlagsWait(RX_SIGNAL, osFlagsWaitAll, osWaitForever);
if (flags & RX_SIGNAL) {
// When packet received from miniPC, increase rel_pitch by 1 and send back
length = uart->Read(&data);
minipc_session.ParseUartBuffer(data, length);
status_data = minipc_session.GetStatus();
Expand All @@ -99,16 +104,18 @@ void RM_RTOS_Default_Task(const void* argument) {
osDelay(10);


// example code for prepare packet and send
//uart->Write(packet_to_send, minipc_session.GetPacketLen(communication::GIMBAL_CMD_ID));
//osDelay(1);
// example code for prepare other packets and send
/*
uart->Write(packet_to_send, minipc_session.GetPacketLen(communication::GIMBAL_CMD_ID));
osDelay(1);
//minipc_session.Pack(packet_to_send, (void*)&color_data, communication::COLOR_CMD_ID);
//uart->Write(packet_to_send, minipc_session.GetPacketLen(communication::COLOR_CMD_ID));
//osDelay(1);
minipc_session.Pack(packet_to_send, (void*)&color_data, communication::COLOR_CMD_ID);
uart->Write(packet_to_send, minipc_session.GetPacketLen(communication::COLOR_CMD_ID));
osDelay(1);
//minipc_session.Pack(packet_to_send, (void*)&chassis_data, communication::CHASSIS_CMD_ID);
//uart->Write(packet_to_send, minipc_session.GetPacketLen(communication::CHASSIS_CMD_ID));
//osDelay(1);
minipc_session.Pack(packet_to_send, (void*)&chassis_data, communication::CHASSIS_CMD_ID);
uart->Write(packet_to_send, minipc_session.GetPacketLen(communication::CHASSIS_CMD_ID));
osDelay(1);
*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "bsp_print.h"
#include "bsp_uart.h"
#include "cmsis_os.h"
#include "autoaim_protocol.h"
#include "minipc_protocol.h"
#include "rgb.h"

#define RX_SIGNAL (1 << 0)
Expand Down Expand Up @@ -62,6 +62,10 @@ void RM_RTOS_Default_Task(const void* argument) {
auto minipc_session = communication::MinipcPort();
int total_processed_bytes = 0;

/* To run this test, use Communication/communicator.py in the iRM_Vision_2023 repo
* Need to set TESTING_TX_RX = False and TESTING_CRC = True
**/

while (true) {
/* wait until rx data is available */
led->Display(0xFF0000FF);
Expand Down
2 changes: 1 addition & 1 deletion examples/minipc/typeA.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "bsp_print.h"
#include "bsp_uart.h"
#include "cmsis_os.h"
#include "autoaim_protocol.h"
#include "minipc_protocol.h"

#define RX_SIGNAL (1 << 0)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* *
****************************************************************************/

#include "autoaim_protocol.h"
#include "minipc_protocol.h"

#include <cstring>
#include <memory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ enum CMD_ID {GIMBAL_CMD_ID,
TOTAL_NUM_OF_ID};

// WARNING: THIS CLASS IS NOT THREAD SAFE!!!
// See docs/comm_protocol.md in vision repo for docs
class MinipcPort {
public:
MinipcPort();
Expand Down
2 changes: 1 addition & 1 deletion vehicles/Steering/gimbal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include "rgb.h"
#include "shooter.h"
#include "stepper.h"
#include "autoaim_protocol.h"
#include "minipc_protocol.h"

static bsp::CAN* can1 = nullptr;
static bsp::CAN* can2 = nullptr;
Expand Down

0 comments on commit a1cb494

Please sign in to comment.