real_robot.h
Go to the documentation of this file.
1 #ifndef REAL_ROBOT_H
2 #define REAL_ROBOT_H
3 
7 #include <serial/serial.h>
8 #include "arduino_comms.h"
9 #include <cstring>
10 
12 {
13 
14 public:
15  struct Config
16  {
17  std::string left_wheel_name = "left_wheel";
18  std::string right_wheel_name = "right_wheel";
19  float loop_rate = 30;
20  std::string device = "/dev/ttyUSB0";
21  int baud_rate = 57600;
22  int timeout = 1000;
23  int enc_counts_per_rev = 1920;
24  };
25 
26 
27 
28 private:
29 
30  struct Wheel
31  {
32  std::string name = "";
33  int enc = 0;
34  double cmd = 0;
35  double pos = 0;
36  double vel = 0;
37  double eff = 0;
38  double velSetPt = 0;
39  double rads_per_count = 0;
40 
41  Wheel(const std::string &wheel_name, int counts_per_rev);
42 
43  double calcEncAngle();
44  };
45 
46 
47 
48 public:
49  RealRobot(const Config &cfg);
50 
51  void read();
52  void write();
53 
54 
55  const ros::Time &get_time() { return time_; }
56  const ros::Duration &get_period() { return period_; }
57 
58 private:
62 
65 
68  float loop_rate_;
69 
70 };
71 
72 
73 #endif // REAL_ROBOT_H
std::string left_wheel_name
Definition: real_robot.h:17
float loop_rate_
Definition: real_robot.h:68
ros::Time time_
Definition: real_robot.h:66
std::string device
Definition: real_robot.h:20
ArduinoComms arduino_
Definition: real_robot.h:61
string cmd
const ros::Duration & get_period()
Definition: real_robot.h:56
ros::Duration period_
Definition: real_robot.h:67
Wheel r_wheel_
Definition: real_robot.h:64
void read()
Definition: real_robot.cpp:49
hardware_interface::JointStateInterface jnt_state_interface_
Definition: real_robot.h:59
RealRobot(const Config &cfg)
Definition: real_robot.cpp:17
Wheel l_wheel_
Definition: real_robot.h:63
std::string right_wheel_name
Definition: real_robot.h:18
hardware_interface::VelocityJointInterface jnt_vel_interface_
Definition: real_robot.h:60
void write()
Definition: real_robot.cpp:72
const ros::Time & get_time()
Definition: real_robot.h:55


diffdrive_arduino
Author(s): Josh Newans
autogenerated on Mon Feb 28 2022 22:13:39