dji电机没问题
This commit is contained in:
parent
703185baa2
commit
8fa0d118f9
@ -77,12 +77,14 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE
|
|||||||
|
|
||||||
# User/module sources
|
# User/module sources
|
||||||
User/module/config.c
|
User/module/config.c
|
||||||
|
User/module/arm.cpp
|
||||||
|
User/module/chassis.cpp
|
||||||
|
|
||||||
# User/task sources
|
# User/task sources
|
||||||
User/task/atti_esit.c
|
User/task/atti_esit.c
|
||||||
User/task/blink.c
|
User/task/blink.c
|
||||||
User/task/ctrl_arm.c
|
User/task/ctrl_arm.cpp
|
||||||
User/task/ctrl_chassis.c
|
User/task/ctrl_chassis.cpp
|
||||||
User/task/init.c
|
User/task/init.c
|
||||||
User/task/monitor.c
|
User/task/monitor.c
|
||||||
User/task/rc.c
|
User/task/rc.c
|
||||||
|
|||||||
@ -431,10 +431,10 @@ int8_t MOTOR_LZ_Offline(MOTOR_LZ_Param_t *param) {
|
|||||||
return DEVICE_ERR_NO_DEV;
|
return DEVICE_ERR_NO_DEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
static MOTOR_LZ_Feedback_t* MOTOR_LZ_GetFeedback(MOTOR_LZ_Param_t *param) {
|
// static MOTOR_LZ_Feedback_t* MOTOR_LZ_GetFeedback(MOTOR_LZ_Param_t *param) {
|
||||||
MOTOR_LZ_t *motor = MOTOR_LZ_GetMotor(param);
|
// MOTOR_LZ_t *motor = MOTOR_LZ_GetMotor(param);
|
||||||
if (motor && motor->motor.header.online) {
|
// if (motor && motor->motor.header.online) {
|
||||||
return &motor->lz_feedback;
|
// return &motor->lz_feedback;
|
||||||
}
|
// }
|
||||||
return NULL;
|
// return NULL;
|
||||||
}
|
// }
|
||||||
|
|||||||
0
User/module/arm.cpp
Normal file
0
User/module/arm.cpp
Normal file
0
User/module/arm.hpp
Normal file
0
User/module/arm.hpp
Normal file
62
User/module/chassis.cpp
Normal file
62
User/module/chassis.cpp
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#include "module/chassis.hpp"
|
||||||
|
#include "bsp/can.h"
|
||||||
|
#include "device/motor_rm.h"
|
||||||
|
|
||||||
|
|
||||||
|
Chassis::Chassis() {
|
||||||
|
motors_param[0] = {
|
||||||
|
.can = BSP_CAN_1,
|
||||||
|
.id = 0x201,
|
||||||
|
.module = MOTOR_M3508,
|
||||||
|
.reverse = false,
|
||||||
|
.gear = true
|
||||||
|
};
|
||||||
|
motors_param[1] = {
|
||||||
|
.can = BSP_CAN_1,
|
||||||
|
.id = 0x202,
|
||||||
|
.module = MOTOR_M3508,
|
||||||
|
.reverse = false,
|
||||||
|
.gear = true
|
||||||
|
};
|
||||||
|
motors_param[2] = {
|
||||||
|
.can = BSP_CAN_1,
|
||||||
|
.id = 0x203,
|
||||||
|
.module = MOTOR_M3508,
|
||||||
|
.reverse = false,
|
||||||
|
.gear = true
|
||||||
|
};
|
||||||
|
motors_param[3] = {
|
||||||
|
.can = BSP_CAN_1,
|
||||||
|
.id = 0x204,
|
||||||
|
.module = MOTOR_M3508,
|
||||||
|
.reverse = false,
|
||||||
|
.gear = true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void Chassis::init() {
|
||||||
|
BSP_CAN_Init();
|
||||||
|
MOTOR_RM_Register(&motors_param[0]);
|
||||||
|
MOTOR_RM_Register(&motors_param[1]);
|
||||||
|
MOTOR_RM_Register(&motors_param[2]);
|
||||||
|
MOTOR_RM_Register(&motors_param[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Chassis::operator()() {
|
||||||
|
MOTOR_RM_UpdateAll();
|
||||||
|
|
||||||
|
MOTOR_RM_t *motor = NULL;
|
||||||
|
motor = MOTOR_RM_GetMotor(&motors_param[0]);
|
||||||
|
chassis_motors[0] = motor->motor;
|
||||||
|
motor = MOTOR_RM_GetMotor(&motors_param[1]);
|
||||||
|
chassis_motors[1] = motor->motor;
|
||||||
|
motor = MOTOR_RM_GetMotor(&motors_param[2]);
|
||||||
|
chassis_motors[2] = motor->motor;
|
||||||
|
motor = MOTOR_RM_GetMotor(&motors_param[3]);
|
||||||
|
chassis_motors[3] = motor->motor;
|
||||||
|
|
||||||
|
// MOTOR_RM_SetOutput(&motors_param[0], 0.1f);
|
||||||
|
// MOTOR_RM_Ctrl(&motors_param[0]);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
17
User/module/chassis.hpp
Normal file
17
User/module/chassis.hpp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include "bsp/can.h"
|
||||||
|
#include "device/motor.h"
|
||||||
|
#include "device/motor_rm.h"
|
||||||
|
|
||||||
|
class Chassis {
|
||||||
|
public:
|
||||||
|
Chassis();
|
||||||
|
void init();
|
||||||
|
void operator()();
|
||||||
|
private:
|
||||||
|
MOTOR_RM_Param_t motors_param[4];
|
||||||
|
MOTOR_t chassis_motors[4];
|
||||||
|
};
|
||||||
|
|
||||||
@ -6,7 +6,7 @@
|
|||||||
/* Includes ----------------------------------------------------------------- */
|
/* Includes ----------------------------------------------------------------- */
|
||||||
#include "task/user_task.h"
|
#include "task/user_task.h"
|
||||||
/* USER INCLUDE BEGIN */
|
/* USER INCLUDE BEGIN */
|
||||||
|
#include "module/chassis.hpp"
|
||||||
/* USER INCLUDE END */
|
/* USER INCLUDE END */
|
||||||
|
|
||||||
/* Private typedef ---------------------------------------------------------- */
|
/* Private typedef ---------------------------------------------------------- */
|
||||||
@ -14,7 +14,7 @@
|
|||||||
/* Private macro ------------------------------------------------------------ */
|
/* Private macro ------------------------------------------------------------ */
|
||||||
/* Private variables -------------------------------------------------------- */
|
/* Private variables -------------------------------------------------------- */
|
||||||
/* USER STRUCT BEGIN */
|
/* USER STRUCT BEGIN */
|
||||||
|
Chassis chassis;
|
||||||
/* USER STRUCT END */
|
/* USER STRUCT END */
|
||||||
|
|
||||||
/* Private function --------------------------------------------------------- */
|
/* Private function --------------------------------------------------------- */
|
||||||
@ -30,13 +30,13 @@ void Task_ctrl_chassis(void *argument) {
|
|||||||
|
|
||||||
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
|
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
|
||||||
/* USER CODE INIT BEGIN */
|
/* USER CODE INIT BEGIN */
|
||||||
|
chassis.init();
|
||||||
/* USER CODE INIT END */
|
/* USER CODE INIT END */
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||||
/* USER CODE BEGIN */
|
/* USER CODE BEGIN */
|
||||||
|
chassis();
|
||||||
/* USER CODE END */
|
/* USER CODE END */
|
||||||
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user