motor_parmeters.h
Go to the documentation of this file.
1 
31 #ifndef UBIQUITY_MOTOR_MOTOR_PARMETERS_H
32 #define UBIQUITY_MOTOR_MOTOR_PARMETERS_H
33 
34 #include <ros/ros.h>
35 
36 template <typename T>
37 T getParamOrDefault(ros::NodeHandle nh, std::string parameter_name,
38  T default_val) {
39  T value = default_val;
40  if (!nh.getParam(parameter_name, value)) {
41  nh.setParam(parameter_name, value);
42  }
43  return value;
44 }
45 
48  int32_t pid_integral;
49  int32_t pid_derivative;
50  int32_t pid_velocity;
51  int32_t pid_denominator;
54  int32_t estop_detection;
56  int32_t max_speed_fwd;
57  int32_t max_speed_rev;
58  int32_t max_pwm;
59  int32_t deadman_timer;
60  int32_t deadzone_enable;
61  int32_t hw_options;
64 
66  : pid_proportional(4000),
67  pid_integral(5),
68  pid_derivative(-200),
69  pid_velocity(0),
70  pid_denominator(1000),
71  pid_moving_buffer_size(10),
72  controller_board_version(49),
73  estop_detection(1),
74  estop_pid_threshold(1500),
75  max_speed_fwd(80),
76  max_speed_rev(-80),
77  max_pwm(250),
78  deadman_timer(2400000),
79  deadzone_enable(1),
80  hw_options(0),
81  battery_voltage_multiplier(0.05057),
82  battery_voltage_offset(0.40948){};
83 
85  : pid_proportional(4000),
86  pid_integral(5),
87  pid_derivative(-200),
88  pid_velocity(0),
89  pid_denominator(1000),
90  pid_moving_buffer_size(10),
91  controller_board_version(49),
92  estop_detection(1),
93  estop_pid_threshold(1500),
94  max_speed_fwd(80),
95  max_speed_rev(-80),
96  max_pwm(250),
97  deadman_timer(2400000),
98  deadzone_enable(1),
99  hw_options(0),
100  battery_voltage_multiplier(0.05057),
101  battery_voltage_offset(0.40948)
102  {
103  // clang-format off
104  pid_proportional = getParamOrDefault(
105  nh, "ubiquity_motor/pid_proportional", pid_proportional);
106  pid_integral = getParamOrDefault(
107  nh, "ubiquity_motor/pid_integral", pid_integral);
108  pid_derivative = getParamOrDefault(
109  nh, "ubiquity_motor/pid_derivative", pid_derivative);
110  pid_velocity = getParamOrDefault(
111  nh, "ubiquity_motor/pid_velocity", pid_velocity);
112  pid_denominator = getParamOrDefault(
113  nh, "ubiquity_motor/pid_denominator", pid_denominator);
114  pid_moving_buffer_size = getParamOrDefault(
115  nh, "ubiquity_motor/window_size", pid_moving_buffer_size);
116  controller_board_version = getParamOrDefault(
117  nh, "ubiquity_motor/controller_board_version", controller_board_version);
118  estop_detection = getParamOrDefault(
119  nh, "ubiquity_motor/fw_estop_detection", estop_detection);
120  estop_pid_threshold = getParamOrDefault(
121  nh, "ubiquity_motor/fw_estop_pid_threshold", estop_pid_threshold);
122  max_speed_fwd = getParamOrDefault(
123  nh, "ubiquity_motor/fw_max_speed_fwd", max_speed_fwd);
124  max_speed_rev = getParamOrDefault(
125  nh, "ubiquity_motor/fw_max_speed_rev", max_speed_rev);
126  max_pwm = getParamOrDefault(
127  nh, "ubiquity_motor/fw_max_pwm", max_pwm);
128  deadman_timer = getParamOrDefault(
129  nh, "ubiquity_motor/deadman_timer", deadman_timer);
130  deadzone_enable = getParamOrDefault(
131  nh, "ubiquity_motor/deadzone_enable", deadzone_enable);
132  battery_voltage_offset = getParamOrDefault(
133  nh, "ubiquity_motor/battery_voltage_offset", battery_voltage_offset);
134  battery_voltage_multiplier = getParamOrDefault(
135  nh, "ubiquity_motor/battery_voltage_multiplier", battery_voltage_multiplier);
136  // clang-format on
137  };
138 };
139 
140 struct CommsParams {
141  std::string serial_port;
142  int32_t baud_rate;
143 
145  : serial_port("/dev/ttyS0"), baud_rate(9600) {};
146 
148  : serial_port("/dev/ttyS0"), baud_rate(9600) {
149  // clang-format off
150  serial_port = getParamOrDefault(
151  nh, "ubiquity_motor/serial_port", serial_port);
152  baud_rate = getParamOrDefault(
153  nh, "ubiquity_motor/serial_baud", baud_rate);
154  // clang-format on
155  };
156 };
157 
158 struct NodeParams {
160 
161  NodeParams() : controller_loop_rate(10.0){};
162  NodeParams(ros::NodeHandle nh) : controller_loop_rate(10.0) {
163  // clang-format off
164  controller_loop_rate = getParamOrDefault(
165  nh, "ubiquity_motor/controller_loop_rate", controller_loop_rate);
166  // clang-format on
167  };
168 };
169 
170 #endif // UBIQUITY_MOTOR_MOTOR_PARMETERS_H
int32_t pid_proportional
int32_t pid_velocity
int32_t deadman_timer
double controller_loop_rate
float battery_voltage_offset
CommsParams(ros::NodeHandle nh)
int32_t pid_denominator
int32_t baud_rate
int32_t pid_moving_buffer_size
FirmwareParams(ros::NodeHandle nh)
int32_t controller_board_version
int32_t pid_integral
bool getParam(const std::string &key, std::string &s) const
int32_t pid_derivative
int32_t estop_pid_threshold
float battery_voltage_multiplier
int32_t deadzone_enable
int32_t max_speed_rev
T getParamOrDefault(ros::NodeHandle nh, std::string parameter_name, T default_val)
int32_t max_speed_fwd
void setParam(const std::string &key, const XmlRpc::XmlRpcValue &v) const
std::string serial_port
NodeParams(ros::NodeHandle nh)
int32_t estop_detection


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