mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-09-25 02:47:27 +08:00
Reorganize config parameters
All configurable parameters are now exposed on the protocol in objects called "[...].config". Those are the same parameters that are saved to NVM.
This commit is contained in:
@@ -42,7 +42,7 @@ typedef struct {
|
||||
float encoder_idx_search_speed;
|
||||
int32_t encoder_cpr;
|
||||
int32_t encoder_offset;
|
||||
int32_t motor_dir;
|
||||
int32_t encoder_motor_dir;
|
||||
} MotorConfig_t;
|
||||
|
||||
/* Global constant data ------------------------------------------------------*/
|
||||
@@ -182,7 +182,7 @@ void set_motor_config(const MotorConfig_t* config, Motor_t* motor) {
|
||||
motor->encoder.idx_search_speed = config->encoder_idx_search_speed;
|
||||
motor->encoder.encoder_cpr = config->encoder_cpr;
|
||||
motor->encoder.encoder_offset = config->encoder_offset;
|
||||
motor->encoder.motor_dir = config->motor_dir;
|
||||
motor->encoder.motor_dir = config->encoder_motor_dir;
|
||||
}
|
||||
|
||||
// This function is obviously stupid and should go away (make MotorConfig_t a member of Motor_t)
|
||||
@@ -209,14 +209,14 @@ void get_motor_config(const Motor_t* motor, MotorConfig_t* config) {
|
||||
config->encoder_idx_search_speed = motor->encoder.idx_search_speed;
|
||||
config->encoder_cpr = motor->encoder.encoder_cpr;
|
||||
config->encoder_offset = motor->encoder.encoder_offset;
|
||||
config->motor_dir = motor->encoder.motor_dir;
|
||||
config->encoder_motor_dir = motor->encoder.motor_dir;
|
||||
}
|
||||
|
||||
|
||||
void init_configuration(void) {
|
||||
MotorConfig_t motor_config[2];
|
||||
//TODO: we really shouldn't be hardcoding like this
|
||||
if (NVM_init() || Config<MotorConfig_t, MotorConfig_t, AxisConfig, AxisConfig>::load_config(&motor_config[0], &motor_config[1], &axis_configs[0], &axis_configs[1])) {
|
||||
if (NVM_init() || Config<MotorConfig_t, MotorConfig_t, AxisConfig, AxisConfig, float>::load_config(&motor_config[0], &motor_config[1], &axis_configs[0], &axis_configs[1], &brake_resistance)) {
|
||||
//printf("no config found\r\n"); osDelay(5);
|
||||
// load default config
|
||||
// motor_config[0] = MotorConfig_t();
|
||||
@@ -237,7 +237,7 @@ void save_configuration(void) {
|
||||
get_motor_config(&motors[0], &motor_config[0]);
|
||||
get_motor_config(&motors[1], &motor_config[1]);
|
||||
//TODO: we really shouldn't be hardcoding like this
|
||||
if (Config<MotorConfig_t, MotorConfig_t, AxisConfig, AxisConfig>::store_config(&motor_config[0], &motor_config[1], &axis_configs[0], &axis_configs[1])) {
|
||||
if (Config<MotorConfig_t, MotorConfig_t, AxisConfig, AxisConfig, float>::store_config(&motor_config[0], &motor_config[1], &axis_configs[0], &axis_configs[1], &brake_resistance)) {
|
||||
//printf("saving configuration failed\r\n"); osDelay(5);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user