kinematics.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) 2019, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2019-07-17 Wu Han The first version
  9. */
  10. #ifndef __KINEMATICS_H__
  11. #define __KINEMATICS_H__
  12. #include <rtthread.h>
  13. enum base {
  14. TWO_WD = 0,
  15. FOUR_WD,
  16. ACKERMANN,
  17. MECANUM
  18. };
  19. // rad/min
  20. struct rpm
  21. {
  22. int motor1;
  23. int motor2;
  24. int motor3;
  25. int motor4;
  26. };
  27. // m/s
  28. struct velocity
  29. {
  30. float linear_x;
  31. float linear_y;
  32. float angular_z;
  33. };
  34. typedef struct kinematics *kinematics_t;
  35. struct kinematics
  36. {
  37. enum base k_base;
  38. float length_x;
  39. float length_y;
  40. float wheel_cir;
  41. int total_wheels;
  42. };
  43. kinematics_t kinematics_create(enum base k_base, float length_x, float length_y, float wheel_radius);
  44. void kinematics_destroy(kinematics_t kinematics);
  45. rt_err_t kinematics_reset(kinematics_t kin);
  46. void kinematics_get_rpm(struct kinematics kin, struct velocity target_vel, rt_int16_t *rpm);
  47. void kinematics_get_velocity(struct kinematics kin, struct rpm current_rpm, struct velocity *velocity);
  48. #endif