You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.2KB

  1. #ifndef CONTROLLER_H
  2. #define CONTROLLER_H
  3. #include "event.h"
  4. #include "gb_math.h"
  5. #include "stepper.h"
  6. #include "path.h"
  7. #define VEL_DIV 1024
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. enum {
  12. CONTROLLER_OK = 0,
  13. CONTROLLER_ERR = -1,
  14. CONTROLLER_NO_PATH = -2,
  15. CONTROLLER_STATISFIED = -3,
  16. };
  17. typedef struct {
  18. event_t event;
  19. event_timeout_t event_timeout;
  20. event_queue_t *queue;
  21. stepper_t *stepper_a;
  22. stepper_t *stepper_b;
  23. float arm_a;
  24. float arm_b;
  25. float angle1_setpoint;
  26. float angle2_setpoint;
  27. uint32_t time_step;
  28. gbVec2 setpoint;
  29. path_t *path;
  30. float error;
  31. } controller_t;
  32. int controller_init(controller_t *control);
  33. void controller_update(event_t *event);
  34. int controller_setpoint(controller_t *control, gbVec2 *point);
  35. void controller_inverse_kinematics(controller_t *control, gbVec2 *point, float *angle1, float *angle2);
  36. void controller_current_position(controller_t *control, gbVec2 *point);
  37. int controller_calculate_velocity(controller_t *control);
  38. int controller_sub_setpoint(controller_t *control, gbVec2 *setpoint, float distance);
  39. int controller_home(controller_t *control);
  40. #ifdef __cplusplus
  41. }
  42. #endif
  43. #endif /* CONTROLLER_H */