motor_hardware.h
Go to the documentation of this file.
1 
31 #ifndef MOTORHARDWARE_H
32 #define MOTORHARDWARE_H
33 
37 #include "ros/ros.h"
38 #include "sensor_msgs/JointState.h"
39 
40 #include "std_msgs/Int32.h"
41 #include "std_msgs/UInt32.h"
42 #include "std_msgs/Bool.h"
43 #include "sensor_msgs/BatteryState.h"
44 
47 
50 
51 #include <gtest/gtest_prod.h>
52 
56  diagnostic_updater::FrequencyStatusParam(&odom_min_freq, &odom_max_freq)) {}
57  // Communication Statuses
59  int firmware_date = 0;
61 
62  double odom_max_freq = 1000;
63  double odom_min_freq = 50;
65 
66  // Limits
67  bool left_pwm_limit = false;
68  bool right_pwm_limit = false;
69  bool left_integral_limit = false;
70  bool right_integral_limit = false;
71  bool left_max_speed_limit = false;
72  bool right_max_speed_limit = false;
74 
75  // Power supply statuses
76  float battery_voltage = 0.0;
77  /* For later implementation (firmware support)
78  bool main_5V_error = false;
79  bool main_5V_ol = false;
80  bool main_12V_error = false;
81  bool main_12V_ol = false;
82  bool aux_5V_error = false;
83  bool aux_5V_ol = false;
84  bool aux_12V_error = false;
85  bool aux_12V_ol = false;
86  */
87 
88  bool estop_motor_power_off = false; // for Diagnostic reporting of ESTOP switch
89 
96 };
97 
99 public:
102  virtual ~MotorHardware();
103  void clearCommands();
104  void readInputs();
105  void writeSpeeds();
106  void writeSpeedsInRadians(double left_radians, double right_radians);
107  void requestFirmwareVersion();
108  void requestFirmwareDate();
109  void setParams(FirmwareParams firmware_params);
110  void sendParams();
111  void setDeadmanTimer(int32_t deadman);
112  void setDeadzoneEnable(int32_t deadzone_enable);
113  void setDebugLeds(bool led1, bool led2);
114  void setHardwareVersion(int32_t hardware_version);
115  void setEstopPidThreshold(int32_t estop_pid_threshold);
116  void setEstopDetection(int32_t estop_detection);
117  bool getEstopState(void);
118  void setMaxFwdSpeed(int32_t max_speed_fwd);
119  void setMaxRevSpeed(int32_t max_speed_rev);
120  void setMaxPwm(int32_t max_pwm);
128  int max_pwm;
130 
132 private:
133  void _addOdometryRequest(std::vector<MotorMessage>& commands) const;
134  void _addVelocityRequest(std::vector<MotorMessage>& commands) const;
135 
136  int16_t calculateSpeedFromRadians(double radians) const;
137  double calculateRadiansFromTicks(int16_t ticks) const;
138 
141 
144 
145  int32_t deadman_timer;
146 
147  double ticks_per_radian; // Odom ticks per radian for wheel encoders in use
148 
149  int32_t sendPid_count;
150 
151  bool estop_motor_power_off; // Motor power inactive, most likely from ESTOP switch
152 
153  struct Joint {
154  double position;
155  double velocity;
156  double effort;
158 
159  Joint() : position(0), velocity(0), effort(0), velocity_command(0) {}
160  } joints_[2];
161 
164 
167 
169 
171 
172  FRIEND_TEST(MotorHardwareTests, nonZeroWriteSpeedsOutputs);
173  FRIEND_TEST(MotorHardwareTests, odomUpdatesPosition);
174  FRIEND_TEST(MotorHardwareTests, odomUpdatesPositionMax);
175 };
176 
177 #endif
void limit_status(diagnostic_updater::DiagnosticStatusWrapper &stat)
double ticks_per_radian
MotorDiagnostics motor_diag_
ros::Publisher battery_state
void battery_status(diagnostic_updater::DiagnosticStatusWrapper &stat)
hardware_interface::JointStateInterface joint_state_interface_
bool estop_motor_power_off
ros::Publisher rightError
ros::Publisher motor_power_active
void firmware_status(diagnostic_updater::DiagnosticStatusWrapper &stat)
static FirmwareParams firmware_params
Definition: motor_node.cc:44
ros::Publisher leftError
void motor_power_status(diagnostic_updater::DiagnosticStatusWrapper &stat)
int32_t sendPid_count
FirmwareParams fw_params
static CommsParams serial_params
Definition: motor_node.cc:45
hardware_interface::VelocityJointInterface velocity_joint_interface_
bool param_limit_in_firmware
int32_t deadman_timer
diagnostic_updater::FrequencyStatus odom_update_status
void firmware_date_status(diagnostic_updater::DiagnosticStatusWrapper &stat)
MotorSerial * motor_serial_
void firmware_options_status(diagnostic_updater::DiagnosticStatusWrapper &stat)
diagnostic_updater::Updater diag_updater
FirmwareParams prev_fw_params


ubiquity_motor
Author(s):
autogenerated on Mon Feb 28 2022 23:57:06