fix: typo in header name and change buf0 flags and fix tests
This commit is contained in:
parent
ffd778ab69
commit
54c8296622
5 changed files with 149 additions and 61 deletions
|
@ -1,18 +1,16 @@
|
|||
// clang-format off
|
||||
#include "Arduino.h"
|
||||
#include "reg_can.h"
|
||||
#include "stm32f446xx.h"
|
||||
#include <SimpleFOC.h>
|
||||
#include <STM32_CAN.h>
|
||||
#include <AS5045.h>
|
||||
#include <DRV8313.h>
|
||||
#include <cstring>
|
||||
#include <iterator>
|
||||
#include "common/base_classes/FOCMotor.h"
|
||||
#include "hal_conf_extra.h"
|
||||
#include "wiring_analog.h"
|
||||
#include "wiring_constants.h"
|
||||
// clang-format on
|
||||
#include "reg_cah.h"
|
||||
#include "flash.h"
|
||||
|
||||
|
||||
|
@ -145,7 +143,7 @@ void send_can_with_id_crc(uint32_t id, uint8_t message_type, const void* data, s
|
|||
|
||||
|
||||
void send_velocity() {
|
||||
float current_velocity = motor.shaftVelocity();
|
||||
float current_velocity = motor.shaft_velocity;
|
||||
flash_rec = load_params();
|
||||
if (flash_rec == nullptr) { // Проверка на NULL
|
||||
// Обработка ошибки: запись в лог, сигнализация и т.д.
|
||||
|
@ -153,11 +151,11 @@ void send_velocity() {
|
|||
}
|
||||
uint8_t value = flash_rec[vel].value;
|
||||
uint8_t id = flash_rec[addr_id].value;
|
||||
send_can_with_id_crc(id,'V',&value,sizeof(value));
|
||||
send_can_with_id_crc(id, MOTOR_VELOCITY, &value,sizeof(value));
|
||||
}
|
||||
|
||||
void send_angle() {
|
||||
float current_angle = motor.shaftAngle();
|
||||
float current_angle = motor.shaft_angle;
|
||||
|
||||
flash_rec = load_params();
|
||||
if (flash_rec == nullptr) { // Проверка на NULL
|
||||
|
@ -166,13 +164,13 @@ void send_angle() {
|
|||
}
|
||||
// uint8_t value = flash_rec[angl].value;
|
||||
uint8_t id = flash_rec[addr_id].value;
|
||||
send_can_with_id_crc(id,'A',¤t_angle,sizeof(current_angle));
|
||||
send_can_with_id_crc(id, MOTOR_ANGLE, ¤t_angle,sizeof(current_angle));
|
||||
}
|
||||
|
||||
void send_motor_enabled() {
|
||||
uint8_t id = *(volatile uint8_t*)ADDR_VAR;
|
||||
CAN_TX_msg.id = id;
|
||||
CAN_TX_msg.buf[0] = 'E';
|
||||
CAN_TX_msg.buf[0] = MOTOR_ENABLED;
|
||||
memcpy(&CAN_TX_msg.buf[1], &motor_control_inputs.motor_enabled,
|
||||
sizeof(motor_control_inputs.motor_enabled));
|
||||
Can.write(CAN_TX_msg);
|
||||
|
@ -188,7 +186,7 @@ void send_foc_state() {
|
|||
|
||||
uint8_t value = flash_rec[foc_id].value;
|
||||
uint8_t id = flash_rec[addr_id].value;
|
||||
send_can_with_id_crc(id,'F',&value,sizeof(value));
|
||||
send_can_with_id_crc(id, FOC_STATE, &value,sizeof(value));
|
||||
}
|
||||
|
||||
void send_id() {
|
||||
|
@ -199,7 +197,7 @@ void send_id() {
|
|||
return;
|
||||
}
|
||||
uint8_t id = flash_rec[addr_id].value;
|
||||
send_can_with_id_crc(id,'I',&id,sizeof(id));
|
||||
send_can_with_id_crc(id, MOTOR_ID, &id,sizeof(id));
|
||||
__NOP();
|
||||
}
|
||||
|
||||
|
@ -209,7 +207,7 @@ void send_motor_torque() {
|
|||
torque *= 100;
|
||||
flash_rec = load_params();
|
||||
CAN_TX_msg.id = flash_rec->value;
|
||||
CAN_TX_msg.buf[0] = 'T';
|
||||
CAN_TX_msg.buf[0] = MOTOR_TORQUE;
|
||||
CAN_TX_msg.len = 5;
|
||||
memcpy(&CAN_TX_msg.buf[1], &torque, sizeof(torque));
|
||||
Can.write(CAN_TX_msg);
|
||||
|
@ -247,9 +245,12 @@ void setup_id(uint8_t my_id) {
|
|||
}
|
||||
|
||||
void setup_angle(float target_angle) {
|
||||
// float target_angle = target_angle_rad / 100.0f; // Предполагаем, что передается в значениях сотых градуса или сотые радианы
|
||||
motor.enable(); // Включаем мотор если он отключен
|
||||
motor.controller = MotionControlType::angle;
|
||||
if (!motor_control_inputs.motor_enabled) {
|
||||
motor.enable();
|
||||
}
|
||||
if (motor.controller != MotionControlType::angle) {
|
||||
motor.controller = MotionControlType::angle;
|
||||
}
|
||||
motor.move(target_angle);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue