#include <kern/global.h>
#include <lib/motor_group.h>
#include <lib/pid.h>
Data Structures | |
| struct | MotionController |
Functions | |
| void | motion_init (MotionController *motion, MotorGroup motor, uint8_t encoder_port, float kp, float ki, float kd) |
| void | motion_set_goal (MotionController *motion, int32_t goal) |
| void | motion_update (MotionController *motion) |
| bool | motion_goal_reached (MotionController *motion) |
Given a MotorGroup (one or more motors), an encoder port and a target position, the MotionController will attempt to drive the MotorGroup to the given target.
| bool motion_goal_reached | ( | MotionController * | motion | ) |
Check if the MotionController's goal has been reached
| void motion_init | ( | MotionController * | motion, | |
| MotorGroup | motor, | |||
| uint8_t | encoder_port, | |||
| float | kp, | |||
| float | ki, | |||
| float | kd | |||
| ) |
Create a new MotionController
| motion | MotionController to initialise | |
| motor | MotorGroup to drive | |
| encoder_port | Encoder port to read motor position from | |
| kp | Proportional constant for PID | |
| ki | Integral constant for PID | |
| kd | Derivative constant for PID |
| void motion_set_goal | ( | MotionController * | motion, | |
| int32_t | goal | |||
| ) |
Set the target position for the MotionController. The controller will immediately start driving the motor towards the goal.
| motion | MotionController to set | |
| goal | Goal position to drive towards |
| void motion_update | ( | MotionController * | motion | ) |
Perform one cycle of the motion controller loop. Call as often as possible.
| motion | MotionController to run |