mecanum.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "space_lib/space_lib.h"
  2. #include "mecanum/mecanum.h"
  3. #include <ros/ros.h>
  4. namespace mecanum {
  5. Mecanum::Mecanum()
  6. {
  7. __readConf();
  8. }
  9. Mecanum::~Mecanum()
  10. {}
  11. void Mecanum::__readConf()
  12. {
  13. common::Config conf = getConfig();
  14. std::string path = space::home() + "configure/nav_config.json";
  15. Json::Value c = space::readConfig(path);
  16. Json::Value coy = c;
  17. space::jsonValueTo(c["mecanum"]["maxmal_next"], conf.maxmal_next) ?
  18. false : (c["mecanum"]["maxmal_next"] = conf.maxmal_next = 0.6);
  19. space::jsonValueTo(c["mecanum"]["minmal_next"], conf.minmal_next) ?
  20. false : (c["mecanum"]["minmal_next"] = conf.minmal_next = 0.25);
  21. space::jsonValueTo(c["mecanum"]["close_ad"], conf.close_ad) ?
  22. false : (c["mecanum"]["close_ad"] = conf.close_ad = 1.0);
  23. space::jsonValueTo(c["mecanum"]["toler_theta"], conf.toler_theta) ?
  24. false : (c["mecanum"]["toler_theta"] = conf.toler_theta = 0.01);
  25. space::jsonValueTo(c["mecanum"]["toler_start_theta"], conf.toler_start_theta) ?
  26. false : (c["mecanum"]["toler_start_theta"] = conf.toler_start_theta = 0.1);
  27. space::jsonValueTo(c["mecanum"]["toler_follow"], conf.toler_follow) ?
  28. false : (c["mecanum"]["toler_follow"] = conf.toler_follow = 0.2);
  29. space::jsonValueTo(c["mecanum"]["toler_follow_theta"], conf.toler_follow_theta) ?
  30. false : (c["mecanum"]["toler_follow_theta"] = conf.toler_follow_theta = 0.51);
  31. space::jsonValueTo(c["mecanum"]["angular_slow_p"], conf.angular_slow_p) ?
  32. false : (c["mecanum"]["angular_slow_p"] = conf.angular_slow_p = 0.8);
  33. space::jsonValueTo(c["mecanum"]["linear_slow_p"], conf.linear_slow_p) ?
  34. false : (c["mecanum"]["linear_slow_p"] = conf.linear_slow_p = 0.3);
  35. if (coy != c) {
  36. space::writeConfig(path, c);
  37. }
  38. setConfig(conf);
  39. }
  40. common::NavState Mecanum::computeVelocityCommands(common::Point& sta_pose, common::Twist& cmd)
  41. {
  42. common::NavState state = computeVelocity(sta_pose, cmd);
  43. return state;
  44. }
  45. }