94 lines
2.3 KiB
C
94 lines
2.3 KiB
C
#ifndef __GO_M8010_6_H
|
||
#define __GO_M8010_6_H
|
||
#ifdef __cplusplus
|
||
extern "C"{
|
||
#endif
|
||
#include "main.h"
|
||
#include "crc16.h"
|
||
#include "usart.h"
|
||
#include "string.h"
|
||
#include <math.h>
|
||
#define GO_NUM 2
|
||
/**
|
||
* @brief
|
||
|
||
*
|
||
*/
|
||
typedef struct
|
||
{
|
||
uint8_t id :4;
|
||
uint8_t status :3;
|
||
uint8_t none :1;
|
||
} RIS_Mode_t /*__attribute__((packed))*/;
|
||
|
||
|
||
|
||
/**
|
||
* @brief <20><><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||
*
|
||
*/
|
||
typedef struct
|
||
{
|
||
int16_t tor_des; // <20><><EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD><EFBFBD>Ť<EFBFBD><C5A4> unit: N.m (q8)
|
||
int16_t spd_des; // <20><><EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD> unit: rad/s (q7)
|
||
int32_t pos_des; // <20><><EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB> unit: rad (q15)
|
||
uint16_t k_pos; // <20><><EFBFBD><EFBFBD><EFBFBD>ؽڸն<DAB8>ϵ<EFBFBD><CFB5> unit: 0.0-1.0 (q15)
|
||
uint16_t k_spd; // <20><><EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5> unit: 0.0-1.0 (q15)
|
||
|
||
} RIS_Comd_t;
|
||
|
||
|
||
|
||
/**
|
||
*
|
||
*
|
||
*/
|
||
typedef struct
|
||
{
|
||
uint8_t head[2];
|
||
RIS_Mode_t mode;
|
||
RIS_Comd_t comd;
|
||
uint16_t CRC16;
|
||
|
||
} ControlData_t;
|
||
|
||
|
||
|
||
|
||
typedef struct {
|
||
unsigned short id;
|
||
unsigned short mode;
|
||
uint16_t correct;
|
||
int MError;
|
||
int Temp;
|
||
float tar_pos; // target position
|
||
float tar_w; // target speed
|
||
float T; // <20><>ǰʵ<C7B0>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
float W; // <20><>ǰʵ<C7B0>ʵ<EFBFBD><CAB5><EFBFBD>ٶȣ<D9B6><C8A3><EFBFBD><EFBFBD>٣<EFBFBD>
|
||
float Pos; // <20><>ǰ<EFBFBD><C7B0><EFBFBD>λ<EFBFBD><CEBB>
|
||
int footForce; // They dont even know what 7 is this so we dont update this
|
||
uint8_t buffer[17];
|
||
uint8_t Rec_buffer[16];
|
||
ControlData_t motor_send_data;
|
||
}GO_Motorfield;
|
||
|
||
|
||
void GO_M8010_init(void);
|
||
|
||
|
||
void GO_M8010_send_data(UART_HandleTypeDef *huart,int id, int rev,float T,float W,float Pos,float K_P,float K_W);
|
||
void USART6_RxCompleteCallback(void );
|
||
void uartTxCB(UART_HandleTypeDef *huart);
|
||
|
||
|
||
void basic_ForceControl (UART_HandleTypeDef *huart, int id, float bias, float length, float mass,
|
||
float tar_pos, float tar_w, float K_P,float K_W);
|
||
|
||
|
||
GO_Motorfield* getGoPoint(uint8_t id);
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
#endif /*__GO_M8010_6_H */
|