From d8d1711c9f1082ffaea3c5acf076f1947d5ff948 Mon Sep 17 00:00:00 2001 From: kingoflolz Date: Tue, 28 May 2019 15:28:15 -0400 Subject: [PATCH 1/6] Update getting started --- docs/getting-started.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 8060bbb3..6d4baf8a 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -124,21 +124,16 @@ Try step 5 again ### Linux -1. [Install Python 3](https://www.python.org/downloads/). -2. Install the ODrive tools by opening a terminal and typing `pip install odrive` Enter -3. Set up USB permissions -```bash - echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="0d[0-9][0-9]", MODE="0666"' | sudo tee /etc/udev/rules.d/91-odrive.rules - sudo udevadm control --reload-rules - sudo udevadm trigger -``` +1. [Install Python 3](https://www.python.org/downloads/). (for example, on Ubuntu, `sudo apt install python3 python3-pip`) +2. Install the ODrive tools by opening a terminal and typing `sudo pip3 install odrive` Enter +3. (needed on Ubuntu, maybe other distros too) Add odrivetool into the path, by adding `~/.local/bin/` into `~/.bash_profile`, for example by running `nano ~/.bashrc`, scrolling to the bottom, pasting `PATH=$PATH:~/.local/bin/`, and then saving and closing, and close and reopen the terminal window. ## Firmware **ODrive v3.5 and later**
Your board should come preflashed with firmware. If you run into problems, follow the instructions [here](odrivetool.md#device-firmware-update) on the DFU procedure before you continue. **ODrive v3.4 and earlier**
-Your board does **not** come preflashed with any firmware. Follow the instructions [here](odrivetool.md#device-firmware-update) on the STP Link procedure before you continue. +Your board does **not** come preflashed with any firmware. Follow the instructions [here](odrivetool.md#device-firmware-update) on the ST Link procedure before you continue. ## Start `odrivetool` To launch the main interactive ODrive tool, type `odrivetool` Enter. Connect your ODrive and wait for the tool to find it. Now you can, for instance type `odrv0.vbus_voltage` Enter to inpect the boards main supply voltage. From 7e0977a73aba6e70f53a0e9d9db471f3265265d7 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Thu, 30 May 2019 22:16:30 -0700 Subject: [PATCH 2/6] Update getting-started.md --- docs/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 6d4baf8a..7d208e09 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -188,7 +188,7 @@ This is the resistance of the brake resistor. If you are not using it, you may s `odrv0.axis0.motor.config.pole_pairs` This is the number of **magnet poles** in the rotor, **divided by two**. To find this, you can simply count the number of permanent magnets in the rotor, if you can see them. _Note: this is not the same as the number of coils in the stator._ -If you can't see them, try sliding a magnet around the rotor, and counting how many times it stops. This will be the number of **pole pairs**. If you use a magnetic piece of metal instead of a magnet, you will get the number of **magnet poles**. +If you can't see them, try sliding a loose magnet in your hand around the rotor, and counting how many times it stops. This will be the number of **pole pairs**. If you use a magnetic piece of metal instead of a magnet, you will get the number of **magnet poles**. `odrv0.axis0.motor.config.motor_type` This is the type of motor being used. Currently two types of motors are supported: High-current motors (`MOTOR_TYPE_HIGH_CURRENT`) and gimbal motors (`MOTOR_TYPE_GIMBAL`). From fc5022fde0f65eb8d242ff85b85193c285dc49eb Mon Sep 17 00:00:00 2001 From: Ioannis Chatzikonstantinou Date: Thu, 13 Jun 2019 10:27:07 +0300 Subject: [PATCH 3/6] velocity limiting in current control mode --- Firmware/MotorControl/controller.cpp | 39 ++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/Firmware/MotorControl/controller.cpp b/Firmware/MotorControl/controller.cpp index d295246c..f8c88512 100644 --- a/Firmware/MotorControl/controller.cpp +++ b/Firmware/MotorControl/controller.cpp @@ -1,10 +1,7 @@ #include "odrive_main.h" - -Controller::Controller(Config_t& config) : - config_(config) -{} +Controller::Controller(Config_t& config) : config_(config) {} void Controller::reset() { pos_setpoint_ = 0.0f; @@ -59,10 +56,10 @@ void Controller::move_to_pos(float goal_point) { goal_point_ = goal_point; } -void Controller::move_incremental(float displacement, bool from_goal_point = true){ - if(from_goal_point){ +void Controller::move_incremental(float displacement, bool from_goal_point = true) { + if (from_goal_point) { move_to_pos(goal_point_ + displacement); - } else{ + } else { move_to_pos(pos_setpoint_ + displacement); } } @@ -88,12 +85,12 @@ bool Controller::anticogging_calibration(float pos_estimate, float vel_estimate) fabsf(vel_estimate) < anticogging_.calib_vel_threshold) { anticogging_.cogging_map[anticogging_.index++] = vel_integrator_current_; } - if (anticogging_.index < axis_->encoder_.config_.cpr) { // TODO: remove the dependency on encoder CPR + if (anticogging_.index < axis_->encoder_.config_.cpr) { // TODO: remove the dependency on encoder CPR set_pos_setpoint(anticogging_.index, 0.0f, 0.0f); return false; } else { anticogging_.index = 0; - set_pos_setpoint(0.0f, 0.0f, 0.0f); // Send the motor home + set_pos_setpoint(0.0f, 0.0f, 0.0f); // Send the motor home anticogging_.use_anticogging = true; // We're good to go, enable anti-cogging anticogging_.calib_anticogging = false; return true; @@ -124,7 +121,7 @@ bool Controller::update(float pos_estimate, float vel_estimate, float* current_s vel_setpoint_ = traj_step.Yd; current_setpoint_ = traj_step.Ydd * axis_->trap_.config_.A_per_css; } - anticogging_pos = pos_setpoint_; // FF the position setpoint instead of the pos_estimate + anticogging_pos = pos_setpoint_; // FF the position setpoint instead of the pos_estimate } // Ramp rate limited velocity setpoint @@ -166,7 +163,7 @@ bool Controller::update(float pos_estimate, float vel_estimate, float* current_s if (vel_des < -vel_lim) vel_des = -vel_lim; // Check for overspeed fault (done in this module (controller) for cohesion with vel_lim) - if (config_.vel_limit_tolerance > 0.0f) { // 0.0f to disable + if (config_.vel_limit_tolerance > 0.0f) { // 0.0f to disable if (fabsf(vel_estimate) > config_.vel_limit_tolerance * vel_lim) { set_error(ERROR_OVERSPEED); return false; @@ -203,6 +200,26 @@ bool Controller::update(float pos_estimate, float vel_estimate, float* current_s Iq = -Ilim; } + // Velocity limiting in current mode + if (config_.control_mode < CTRL_MODE_VELOCITY_CONTROL) { + float vmax = (config_.vel_limit - fabsf(vel_estimate)) * config_.vel_gain; + if (Iq > 0 && Iq > vmax) { + limited = true; + if (vmax > 0) { + Iq = vmax; + } else { + Iq = 0; + } + } else if (Iq < 0 && Iq < -vmax) { + limited = true; + if (vmax > 0) { + Iq = -vmax; + } else { + Iq = 0; + } + } + } + // Velocity integrator (behaviour dependent on limiting) if (config_.control_mode < CTRL_MODE_VELOCITY_CONTROL) { // reset integral if not in use From 7b232b4f8a2670c48e9ac2959e85e040a0056a60 Mon Sep 17 00:00:00 2001 From: Ioannis Chatzikonstantinou Date: Thu, 13 Jun 2019 10:31:26 +0300 Subject: [PATCH 4/6] better naming --- Firmware/MotorControl/controller.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Firmware/MotorControl/controller.cpp b/Firmware/MotorControl/controller.cpp index f8c88512..8fb179be 100644 --- a/Firmware/MotorControl/controller.cpp +++ b/Firmware/MotorControl/controller.cpp @@ -202,18 +202,18 @@ bool Controller::update(float pos_estimate, float vel_estimate, float* current_s // Velocity limiting in current mode if (config_.control_mode < CTRL_MODE_VELOCITY_CONTROL) { - float vmax = (config_.vel_limit - fabsf(vel_estimate)) * config_.vel_gain; - if (Iq > 0 && Iq > vmax) { + float Imax = (config_.vel_limit - fabsf(vel_estimate)) * config_.vel_gain; + if (Iq > 0 && Iq > Imax) { limited = true; - if (vmax > 0) { - Iq = vmax; + if (Imax > 0) { + Iq = Imax; } else { Iq = 0; } - } else if (Iq < 0 && Iq < -vmax) { + } else if (Iq < 0 && Iq < -Imax) { limited = true; - if (vmax > 0) { - Iq = -vmax; + if (Imax > 0) { + Iq = -Imax; } else { Iq = 0; } From cfb0e1127220b769f759a8b4186b3f345e4338f3 Mon Sep 17 00:00:00 2001 From: Yannis Chatzikonstantinou Date: Fri, 14 Jun 2019 22:48:57 +0300 Subject: [PATCH 5/6] add check for vel_limt == 0 --- Firmware/MotorControl/controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/MotorControl/controller.cpp b/Firmware/MotorControl/controller.cpp index 8fb179be..642e1785 100644 --- a/Firmware/MotorControl/controller.cpp +++ b/Firmware/MotorControl/controller.cpp @@ -201,7 +201,7 @@ bool Controller::update(float pos_estimate, float vel_estimate, float* current_s } // Velocity limiting in current mode - if (config_.control_mode < CTRL_MODE_VELOCITY_CONTROL) { + if (config_.control_mode < CTRL_MODE_VELOCITY_CONTROL && config_.vel_limit > 0) { float Imax = (config_.vel_limit - fabsf(vel_estimate)) * config_.vel_gain; if (Iq > 0 && Iq > Imax) { limited = true; From 313bd9fe9eebbaf648eb7d9fdc27f4b74e870498 Mon Sep 17 00:00:00 2001 From: Yannis Chatzikonstantinou Date: Fri, 14 Jun 2019 22:53:04 +0300 Subject: [PATCH 6/6] add check for vel_gain > 0 --- Firmware/MotorControl/controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/MotorControl/controller.cpp b/Firmware/MotorControl/controller.cpp index 642e1785..cb5b8642 100644 --- a/Firmware/MotorControl/controller.cpp +++ b/Firmware/MotorControl/controller.cpp @@ -201,7 +201,7 @@ bool Controller::update(float pos_estimate, float vel_estimate, float* current_s } // Velocity limiting in current mode - if (config_.control_mode < CTRL_MODE_VELOCITY_CONTROL && config_.vel_limit > 0) { + if (config_.control_mode < CTRL_MODE_VELOCITY_CONTROL && config_.vel_limit > 0 && config_.vel_gain > 0) { float Imax = (config_.vel_limit - fabsf(vel_estimate)) * config_.vel_gain; if (Iq > 0 && Iq > Imax) { limited = true;