Skip to content

Commit

Permalink
fix(odrive_can_driver): never request new state
Browse files Browse the repository at this point in the history
New state should not be requested after driver configuration, as it
negatively affects control loop on the device. Previously, "closed loop
control" state was requested at every update. This intterupted control
loop on the ODrive and caused motors to artificialy slow down. To work
around this, we now don't request "closed loop" state at all and instead
we should enable "startup_closed_loop_control" on ODrive.
  • Loading branch information
Wihmajster committed Sep 18, 2024
1 parent 64eb324 commit 1131c98
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions odrive_can_driver/include/odrive_can_driver/odrive_can.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ class CanWriteThread
for (auto & motor_axis : motor_axis_.get()) {
auto node_id = motor_axis.GetNodeId();
Send(node_id, CommandId::kControllerModes, deadline, uint32_t(1), uint32_t(0));
Send(node_id, CommandId::kAxisRequestedState, deadline, uint32_t(1));
}
};
void Notify(const rclcpp::Time & time, const rclcpp::Duration & period)
Expand Down Expand Up @@ -428,24 +427,20 @@ class CanWriteThread
Send(node_id, command_id, deadline, float(motor_axis.GetCommandValue()));
// TODO: Replace command and input modes with enums
Send(node_id, CommandId::kControllerModes, deadline, uint32_t(1), uint32_t(6));
Send(node_id, CommandId::kAxisRequestedState, deadline, uint32_t(8));
break;
}
case CommandId::kInputVel: {
Send(node_id, command_id, deadline, float(motor_axis.GetCommandValue()), uint32_t(0));
Send(node_id, CommandId::kControllerModes, deadline, uint32_t(2), uint32_t(2));
Send(node_id, CommandId::kAxisRequestedState, deadline, uint32_t(8));
break;
}
case CommandId::kInputPos: {
Send(node_id, command_id, deadline, float(motor_axis.GetCommandValue()), uint32_t(0));
Send(node_id, CommandId::kControllerModes, deadline, uint32_t(3), uint32_t(1));
Send(node_id, CommandId::kAxisRequestedState, deadline, uint32_t(8));
break;
}
default: {
Send(node_id, CommandId::kControllerModes, deadline, uint32_t(1), uint32_t(0));
Send(node_id, CommandId::kAxisRequestedState, deadline, uint32_t(1));
break;
}
}
Expand Down

0 comments on commit 1131c98

Please sign in to comment.