|
Haptic Controller
|
Go to the source code of this file.
Classes | |
| struct | SystemInfo |
| Struct to hold important system information. More... | |
Functions | |
| void | onOdriveCanMessage (const CanMsg &msg) |
| void | endEffMirrorUpdate () |
| : Links end effector positions together | |
| void | jointMirrorUpdate () |
| : Links joints states | |
| void | enterState (ControllerState state) |
| Process enter state requests. | |
| void | exitState (ControllerState state) |
| Process exit state requests. | |
| void | printEverything () |
| Print statements, set at a separate frequency than others. | |
| bool | shouldError () |
| Check if there is a critical error that should prompt a transition to the error state. | |
| void | doReboot () |
| Reboot the Teensy. | |
| void | openRelays () |
| Open relays to disable motors. | |
| void | closeRelays () |
| Close relays to enable motors. | |
| void | request_disable () |
| Request estop from odrives. | |
| void | request_enable () |
| Process enable request, clear errors. | |
| bool | isInitialized () |
| Check if the motors are in the initial position. | |
| bool | isSynced () |
| Check if the motors are in sync. | |
| void | ledUpdate () |
| Update the LED strip and on board LED based on the current state, timeouts, and mirror states. | |
| void | doState () |
| Handles the current state of the controller. | |
| void | changeState () |
| Evaluates state transitions based on current state and system information. | |
| void | updateSystemInfo () |
| Update system information struct with new CAN information. | |
| void | updateAndSendSystemInfo () |
| Send the end effector position over CAN to the other teensy. | |
| void | checkDeadman () |
| Check the deadman switch state. | |
| void | setup () |
| setup function before main loop | |
| void | loop () |
| Main loop. | |
| void changeState | ( | ) |
Evaluates state transitions based on current state and system information.
Definition at line 361 of file main.cpp.
References comms_controller, controller_state, SystemInfo::deadman_switch_pressed, enterState(), ERROR, exitState(), INITIALIZING, isInitialized(), isSynced(), SystemInfo::mirror_teensy_state, printEverything(), READY, RUNNING, shouldError(), and sys_inf.
Referenced by setup().
| void checkDeadman | ( | ) |
Check the deadman switch state.
Definition at line 668 of file main.cpp.
References comms_controller, SystemInfo::deadman_switch_pressed, and sys_inf.
Referenced by setup().
| void closeRelays | ( | ) |
| void doReboot | ( | ) |
| void doState | ( | ) |
Handles the current state of the controller.
Definition at line 318 of file main.cpp.
References controller_state, endEffMirrorUpdate(), ERROR, INITIALIZING, jointMirrorUpdate(), SystemInfo::odrive0_heartbeat_timeout, SystemInfo::odrive1_heartbeat_timeout, openRelays(), READY, RUNNING, and sys_inf.
Referenced by setup().
| void endEffMirrorUpdate | ( | ) |
: Links end effector positions together
Definition at line 599 of file main.cpp.
References comms_controller, joint_thetas, limit(), pos, soft_limit_torques(), spatial_jacobian(), tau_to_torque(), and vel.
Referenced by doState().
| void enterState | ( | ControllerState | state | ) |
Process enter state requests.
| state | - The state to enter |
Definition at line 448 of file main.cpp.
References comms_controller, doReboot(), ERROR, INITIALIZING, SystemInfo::odrive0_heartbeat_timeout, SystemInfo::odrive1_heartbeat_timeout, READY, request_disable(), request_enable(), RUNNING, sys_inf, and SystemInfo::teensy_heartbeat_timeout.
Referenced by changeState(), and setup().
| void exitState | ( | ControllerState | state | ) |
Process exit state requests.
| state | - The state to exit |
Definition at line 474 of file main.cpp.
References closeRelays(), comms_controller, ERROR, INITIALIZING, READY, and RUNNING.
Referenced by changeState(), and setup().
| bool isInitialized | ( | ) |
Check if the motors are in the initial position.
Definition at line 226 of file main.cpp.
Referenced by changeState().
| bool isSynced | ( | ) |
Check if the motors are in sync.
Definition at line 239 of file main.cpp.
References comms_controller, float_close_compare(), joint_thetas, and pos.
Referenced by changeState().
| void jointMirrorUpdate | ( | ) |
: Links joints states
Definition at line 562 of file main.cpp.
References comms_controller, joint_thetas, joint_vels, limit(), soft_limit_torques(), and tau_to_torque().
Referenced by doState().
| void ledUpdate | ( | ) |
Update the LED strip and on board LED based on the current state, timeouts, and mirror states.
Definition at line 260 of file main.cpp.
References blue, controller_state, cyan, ERROR, green, INITIALIZING, last_received_time, magneta, SystemInfo::odrive0_heartbeat_timeout, SystemInfo::odrive1_heartbeat_timeout, READY, red, RUNNING, setColor(), sys_inf, SystemInfo::teensy_heartbeat_timeout, and yellow.
Referenced by setup().
| void loop | ( | ) |
Main loop.
Definition at line 749 of file main.cpp.
References comms_controller, micro_timer_group, teensy_can, and timer_group.
| void onOdriveCanMessage | ( | const CanMsg & | msg | ) |
Definition at line 49 of file main.cpp.
References odrv0, odrv1, and OdriveController< CAN >::odrv_.
| void openRelays | ( | ) |
| void printEverything | ( | ) |
Print statements, set at a separate frequency than others.
Definition at line 110 of file main.cpp.
References comms_controller, joint_thetas, joint_vels, pos, and vel.
Referenced by changeState(), and setup().
| void request_disable | ( | ) |
Request estop from odrives.
Definition at line 204 of file main.cpp.
References comms_controller.
Referenced by enterState().
| void request_enable | ( | ) |
Process enable request, clear errors.
Definition at line 212 of file main.cpp.
References clear_safe_errors(), and comms_controller.
Referenced by enterState().
| void setup | ( | ) |
setup function before main loop
Definition at line 684 of file main.cpp.
References allUnitTests(), changeState(), checkDeadman(), comms_controller, controller_state, doState(), enterState(), ERROR, exitState(), INITIALIZING, ledSetup(), ledUpdate(), micro_timer_group, printEverything(), teensy_can, timer_group, updateAndSendSystemInfo(), and updateSystemInfo().
| bool shouldError | ( | ) |
Check if there is a critical error that should prompt a transition to the error state.
Definition at line 153 of file main.cpp.
References clear_safe_errors(), comms_controller, SystemInfo::estop_enabled, ODriveUserData::last_heartbeat, SystemInfo::odrive0_heartbeat_timeout, SystemInfo::odrive1_heartbeat_timeout, odrv0_user_data, odrv1_user_data, SystemInfo::relays_open, sys_inf, and SystemInfo::teensy_heartbeat_timeout.
Referenced by changeState().
| void updateAndSendSystemInfo | ( | ) |
Send the end effector position over CAN to the other teensy.
Definition at line 500 of file main.cpp.
References comms_controller, convert_angular_units(), filter_phi_0, filter_phi_1, filter_phi_dot_0, filter_phi_dot_1, forward_kinematics(), joint_thetas, joint_vels, ODriveUserData::last_feedback, motors_to_joints(), odrv0_user_data, odrv1_user_data, phi_to_theta(), pos, RADIANS, REVS, spatial_jacobian(), MovingAverageFilter::update(), and vel.
Referenced by setup().
| void updateSystemInfo | ( | ) |
Update system information struct with new CAN information.
Definition at line 493 of file main.cpp.
References comms_controller, SystemInfo::mirror_teensy_state, sys_inf, and SystemInfo::teensy_heartbeat_timeout.
Referenced by setup().
| CommsController<ODRV_CAN0, ODRV_CAN1> comms_controller |
Definition at line 55 of file main.cpp.
Referenced by changeState(), checkDeadman(), endEffMirrorUpdate(), enterState(), exitState(), isSynced(), jointMirrorUpdate(), loop(), printEverything(), request_disable(), request_enable(), setup(), shouldError(), updateAndSendSystemInfo(), and updateSystemInfo().
| ControllerState controller_state = ControllerState::RUNNING |
Definition at line 171 of file main.cpp.
Referenced by changeState(), doState(), ledUpdate(), and setup().
| LowPassFilter filter = LowPassFilter(20.0) |
| MovingAverageFilter filter_phi_0 {1} |
Definition at line 65 of file main.cpp.
Referenced by updateAndSendSystemInfo().
| MovingAverageFilter filter_phi_1 {1} |
Definition at line 66 of file main.cpp.
Referenced by updateAndSendSystemInfo().
| MovingAverageFilter filter_phi_dot_0 {1} |
Definition at line 67 of file main.cpp.
Referenced by updateAndSendSystemInfo().
| MovingAverageFilter filter_phi_dot_1 {1} |
Definition at line 68 of file main.cpp.
Referenced by updateAndSendSystemInfo().
| std::vector<float> joint_thetas = {0.0f, 0.0f} |
Definition at line 70 of file main.cpp.
Referenced by endEffMirrorUpdate(), isSynced(), jointMirrorUpdate(), phi_to_theta(), printEverything(), soft_limit_torques(), theta_to_phi(), and updateAndSendSystemInfo().
| std::vector<float> joint_vels = {0.0f, 0.0f} |
Definition at line 71 of file main.cpp.
Referenced by jointMirrorUpdate(), printEverything(), and updateAndSendSystemInfo().
| uint32_t last_received_time |
Definition at line 33 of file main.cpp.
Referenced by ledUpdate().
| VirtualTimerGroup micro_timer_group {} |
| OdriveController<CAN2> odrv0 = OdriveController<CAN2>(odrive_can0, ODRIVE0_ID, odrv0_user_data) |
: Odrive for first joint
Definition at line 43 of file main.cpp.
Referenced by onOdriveCanMessage().
| ODriveUserData odrv0_user_data {} |
Definition at line 39 of file main.cpp.
Referenced by shouldError(), and updateAndSendSystemInfo().
| OdriveController<CAN3> odrv1 = OdriveController<CAN3>(odrive_can1, ODRIVE1_ID, odrv1_user_data) |
: Odrive for second joint
Definition at line 46 of file main.cpp.
Referenced by onOdriveCanMessage().
| ODriveUserData odrv1_user_data {} |
Definition at line 40 of file main.cpp.
Referenced by shouldError(), and updateAndSendSystemInfo().
| std::vector<float> pos = {0.0f, 0.0f} |
Definition at line 72 of file main.cpp.
Referenced by endEffMirrorUpdate(), inverse_kinematics(), isSynced(), printEverything(), OdriveController< CAN >::set_torque(), and updateAndSendSystemInfo().
| SystemInfo sys_inf = SystemInfo(comms_controller) |
Definition at line 107 of file main.cpp.
Referenced by changeState(), checkDeadman(), doState(), enterState(), ledUpdate(), shouldError(), and updateSystemInfo().
| VirtualTimerGroup timer_group {} |
| std::vector<float> vel = {0.0f, 0.0f} |
Definition at line 73 of file main.cpp.
Referenced by endEffMirrorUpdate(), printEverything(), and updateAndSendSystemInfo().