Merge branch 'devel' of https://github.com/madcowswe/ODrive into current_vel_limit

This commit is contained in:
Ioannis Chatzikonstantinou
2019-06-13 11:31:32 +03:00
15 changed files with 54191 additions and 12 deletions
+5
View File
@@ -50,6 +50,11 @@ float ODriveArduino::readFloat() {
return readString().toFloat();
}
float ODriveArduino::GetVelocity(int motor_number){
serial_<< "r axis" << motor_number << ".encoder.vel_estimate\n";
return ODriveArduino::readFloat();
}
int32_t ODriveArduino::readInt() {
return readString().toInt();
}
+2
View File
@@ -28,6 +28,8 @@ public:
void SetVelocity(int motor_number, float velocity, float current_feedforward);
void SetCurrent(int motor_number, float current);
void TrapezoidalMove(int motor_number, float position);
// Getters
float GetVelocity(int motor_number);
// General params
float readFloat();
int32_t readInt();
+3
View File
@@ -1,6 +1,9 @@
# Unreleased Features
Please add a note of your changes below this heading if you make a Pull Request.
### Added
* Check current limit violation: added `ERROR_CURRENT_UNSTABLE`, `motor.config.current_lim_tolerance`.
# Releases
## [0.4.10] - 2019-04-24
### Fixed
+7
View File
@@ -0,0 +1,7 @@
---
BasedOnStyle: Google
AlignConsecutiveAssignments: 'true'
AllowShortCaseLabelsOnASingleLine: 'true'
IndentWidth: '4'
...
+1
View File
@@ -15,6 +15,7 @@
"interface/stlink-v2.cfg",
"target/stm32f4x_stlink.cfg",
],
"svdFile": "${workspaceRoot}/Board/v3/STM32F40x.svd",
"cwd": "${workspaceRoot}"
},
{
-1
View File
@@ -1,5 +1,4 @@
{
"C_Cpp.clang_format_style": "{ BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 0 }",
"C_Cpp.intelliSenseEngine": "Default",
"C_Cpp.intelliSenseEngineFallback": "Disabled",
"files.exclude": {
@@ -161,7 +161,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PSP(void)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
{
__ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) : "sp");
__ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) : );
}
@@ -187,7 +187,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_MSP(void)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
{
__ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) : "sp");
__ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) : );
}
File diff suppressed because it is too large Load Diff
+4 -2
View File
@@ -6,14 +6,16 @@
#include "utils.h"
#include "odrive_main.h"
Axis::Axis(const AxisHardwareConfig_t& hw_config,
Axis::Axis(int axis_num,
const AxisHardwareConfig_t& hw_config,
Config_t& config,
Encoder& encoder,
SensorlessEstimator& sensorless_estimator,
Controller& controller,
Motor& motor,
TrapezoidalTrajectory& trap)
: hw_config_(hw_config),
: axis_num_(axis_num),
hw_config_(hw_config),
config_(config),
encoder_(encoder),
sensorless_estimator_(sensorless_estimator),
+3 -1
View File
@@ -80,7 +80,8 @@ public:
LOCKIN_STATE_CONST_VEL,
};
Axis(const AxisHardwareConfig_t& hw_config,
Axis(int axis_num,
const AxisHardwareConfig_t& hw_config,
Config_t& config,
Encoder& encoder,
SensorlessEstimator& sensorless_estimator,
@@ -183,6 +184,7 @@ public:
void run_state_machine_loop();
int axis_num_;
const AxisHardwareConfig_t& hw_config_;
Config_t& config_;
+1 -1
View File
@@ -169,7 +169,7 @@ int odrive_main(void) {
hw_configs[i].gate_driver_config,
motor_configs[i]);
TrapezoidalTrajectory *trap = new TrapezoidalTrajectory(trap_configs[i]);
axes[i] = new Axis(hw_configs[i].axis_config, axis_configs[i],
axes[i] = new Axis(i, hw_configs[i].axis_config, axis_configs[i],
*encoder, *sensorless_estimator, *controller, *motor, *trap);
}
+8
View File
@@ -342,6 +342,7 @@ bool Motor::FOC_current(float Id_des, float Iq_des, float I_phase, float pwm_pha
if (fabsf(current_meas_.phB) > ictrl.overcurrent_trip_level
|| fabsf(current_meas_.phC) > ictrl.overcurrent_trip_level) {
set_error(ERROR_CURRENT_SENSE_SATURATION);
return false;
}
// Clarke transform
@@ -356,6 +357,13 @@ bool Motor::FOC_current(float Id_des, float Iq_des, float I_phase, float pwm_pha
ictrl.Iq_measured += ictrl.I_measured_report_filter_k * (Iq - ictrl.Iq_measured);
ictrl.Id_measured += ictrl.I_measured_report_filter_k * (Id - ictrl.Id_measured);
// Check for violation of current limit
float I_trip = config_.current_lim_tolerance * effective_current_lim();
if (SQ(Id) + SQ(Iq) > SQ(I_trip)) {
set_error(ERROR_CURRENT_UNSTABLE);
return false;
}
// Current error
float Ierr_d = Id_des - Id;
float Ierr_q = Iq_des - Iq;
+4 -1
View File
@@ -22,7 +22,8 @@ public:
ERROR_BRAKE_DEADTIME_VIOLATION = 0x0100,
ERROR_UNEXPECTED_TIMER_CALLBACK = 0x0200,
ERROR_CURRENT_SENSE_SATURATION = 0x0400,
ERROR_INVERTER_OVER_TEMP = 0x0800
ERROR_INVERTER_OVER_TEMP = 0x0800,
ERROR_CURRENT_UNSTABLE = 0x1000
};
enum MotorType_t {
@@ -68,6 +69,7 @@ public:
// Read out max_allowed_current to see max supported value for current_lim.
// float current_lim = 70.0f; //[A]
float current_lim = 10.0f; //[A]
float current_lim_tolerance = 1.25f; // multiple of current_lim
// Value used to compute shunt amplifier gains
float requested_current_range = 60.0f; // [A]
float current_control_bandwidth = 1000.0f; // [rad/s]
@@ -227,6 +229,7 @@ public:
make_protocol_property("direction", &config_.direction),
make_protocol_property("motor_type", &config_.motor_type),
make_protocol_property("current_lim", &config_.current_lim),
make_protocol_property("current_lim_tolerance", &config_.current_lim_tolerance),
make_protocol_property("inverter_temp_limit_lower", &config_.inverter_temp_limit_lower),
make_protocol_property("inverter_temp_limit_upper", &config_.inverter_temp_limit_upper),
make_protocol_property("requested_current_range", &config_.requested_current_range),
@@ -976,17 +976,17 @@ public:
output_properties_.register_endpoints(list, id + 1 + decltype(input_properties_)::endpoint_count, length);
}
template<typename> std::enable_if_t<sizeof...(TOutputs) == 0>
template<size_t i = sizeof...(TOutputs)> std::enable_if_t<i == 0>
handle_ex() {
invoke_function_with_tuple(*obj_, func_ptr_, in_args_);
}
template<typename> std::enable_if_t<sizeof...(TOutputs) == 1>
template<size_t i = sizeof...(TOutputs)> std::enable_if_t<i == 1>
handle_ex() {
std::get<0>(out_args_) = invoke_function_with_tuple(*obj_, func_ptr_, in_args_);
}
template<typename> std::enable_if_t<sizeof...(TOutputs) >= 2>
template<size_t i = sizeof...(TOutputs)> std::enable_if_t<i >= 2>
handle_ex() {
out_args_ = invoke_function_with_tuple(*obj_, func_ptr_, in_args_);
}
@@ -997,7 +997,7 @@ public:
(void) output;
LOG_FIBRE("tuple still at %x and of size %u\r\n", (uintptr_t)&in_args_, sizeof(in_args_));
LOG_FIBRE("invoke function using %d and %.3f\r\n", std::get<0>(in_args_), std::get<1>(in_args_));
handle_ex<void>();
handle_ex();
}
const char * name_;
+1
View File
@@ -42,6 +42,7 @@ class errors:
ERROR_BRAKE_DEADTIME_VIOLATION = 0x0100
ERROR_UNEXPECTED_TIMER_CALLBACK = 0x0200
ERROR_CURRENT_SENSE_SATURATION = 0x0400
ERROR_CURRENT_UNSTABLE = 0x1000
class encoder:
ERROR_NONE = 0