base_controller.h
Go to the documentation of this file.
1 /*
2  * Author: Franz Pucher
3  */
4 
5 #ifndef DIFFBOT_BASE_CONTROLLER_H
6 #define DIFFBOT_BASE_CONTROLLER_H
7 
8 
9 #include <ros.h>
14 #include <std_msgs/Empty.h>
15 #include <sensor_msgs/JointState.h>
16 
17 #include "diffbot_base_config.h"
18 #include "encoder_diffbot.h"
20 #include "pid.h"
21 
22 
23 namespace diffbot {
24 
76  template <typename TMotorController, typename TMotorDriver>
78  {
79  public:
80 
93  BaseController(ros::NodeHandle &nh, TMotorController* motor_controller_left, TMotorController* motor_controller_right);
94 
103  struct UpdateRate
104  {
105  double imu_;
106  double control_;
107  double debug_;
108 
114  struct Period
115  {
116  double imu_;
117  double control_;
118  double debug_;
119 
120  inline Period(double imu_frequency, double control_frequency, double debug_frequency)
121  : imu_(1.0 / imu_frequency)
122  , control_(1.0 / control_frequency)
123  , debug_(1.0 / debug_frequency) {};
124  } period_;
125 
126  inline Period& period() { return period_; };
127 
139  inline UpdateRate(double imu_frequency,
140  double control_frequency,
141  double debug_frequency)
142  : imu_(imu_frequency)
143  , control_(control_frequency)
144  , debug_(debug_frequency)
145  , period_(imu_frequency, control_frequency, debug_frequency) {};
146  } update_rate_;
147 
154  inline int period(double frequency) { return 1 / frequency; };
155 
156  inline UpdateRate& publishRate() { return update_rate_; };
157 
168  {
169  // Time when the last angular wheel command velocity was received.
171  // Time when the last control update happened.
173  // Time when the last imu update took place.
175  // Time when the last debug message was logged.
177 
186  inline LastUpdateTime(ros::Time start)
187  : command_received(start.toSec(), start.toNsec())
188  , control(start.toSec(), start.toNsec())
189  , imu(start.toSec(), start.toNsec())
190  , debug(start.toSec(), start.toNsec()) {};
192 
203 
204 
211  inline bool debug() { return debug_; };
212 
218  void setup();
219 
232  void init();
233 
242  void eStop();
243 
251  void read();
252 
266  void write();
267  void printDebug();
268 
291  void commandCallback(const diffbot_msgs::WheelsCmdStamped& cmd_msg);
292 
303  void resetEncodersCallback(const std_msgs::Empty& reset_msg);
304 
312  void pidLeftCallback(const diffbot_msgs::PIDStamped& pid_msg);
313 
321  void pidRightCallback(const diffbot_msgs::PIDStamped& pid_msg);
322 
323  private:
324  // Reference to global node handle from main.cpp
326 
327  // constants
328  float wheel_radius_ = 0.0;
329  float max_linear_velocity_ = 0.0;
331 
332  // Encoder setup
333  // Change these pin numbers to the pins connected to your encoder.
334  // Best Performance: both pins have interrupt capability
335  // Good Performance: only the first pin has interrupt capability
336  // Low Performance: neither pin has interrupt capability
337  // avoid using pins with LEDs attached
340  long ticks_left_ = 0, ticks_right_ = 0;
341 
342  // Measured left and right joint states (angular position (rad) and angular velocity (rad/s))
344 
345  unsigned long encoder_resolution_;
346 
348 
349  // ROS Publisher setup to publish left and right encoder ticks
350  // This uses the custom encoder ticks message that defines an array of two integers
353 
354  sensor_msgs::JointState msg_measured_joint_states_;
356 
359 
363 
366 
371 
372  // DEBUG
373  bool debug_;
374  };
375 
376 
377 }
378 
379 template <typename TMotorController, typename TMotorDriver>
381 
382 
383 template <typename TMotorController, typename TMotorDriver>
386  : nh_(nh)
389  , sub_reset_encoders_("reset", &BC<TMotorController, TMotorDriver>::resetEncodersCallback, this)
390  , pub_encoders_("encoder_ticks", &encoder_msg_)
391  , pub_measured_joint_states_("measured_joint_states", &msg_measured_joint_states_)
392  , sub_wheel_cmd_velocities_("wheel_cmd_velocities", &BC<TMotorController, TMotorDriver>::commandCallback, this)
393  , last_update_time_(nh.now())
395  , sub_pid_left_("pid_left", &BC<TMotorController, TMotorDriver>::pidLeftCallback, this)
396  , sub_pid_right_("pid_right", &BC<TMotorController, TMotorDriver>::pidRightCallback, this)
397  , motor_pid_left_(PWM_MIN, PWM_MAX, K_P, K_I, K_D)
398  , motor_pid_right_(PWM_MIN, PWM_MAX, K_P, K_I, K_D)
399 {
402 }
403 
404 
405 template <typename TMotorController, typename TMotorDriver>
407 {
408  nh_.initNode();
409  nh_.advertise(pub_encoders_);
410 
411  // msg_measured_joint_states_ is of type sensor_msgs::JointState
412  // which contains float[] joint arrays of undefined size.
413  // For rosserial to work it is required to reserve the memory using malloc
414  // and setting the *_length member appropriately.
415  // http://wiki.ros.org/rosserial/Overview/Limitations#Arrays
416  msg_measured_joint_states_.position = (float*)malloc(sizeof(float) * 2);
417  msg_measured_joint_states_.position_length = 2;
418  msg_measured_joint_states_.velocity = (float*)malloc(sizeof(float) * 2);
419  msg_measured_joint_states_.velocity_length = 2;
420  nh_.advertise(pub_measured_joint_states_);
421 
422  nh_.subscribe(sub_wheel_cmd_velocities_);
423  nh_.subscribe(sub_reset_encoders_);
424 
425  nh_.subscribe(sub_pid_left_);
426  nh_.subscribe(sub_pid_right_);
427 
428  while (!nh_.connected())
429  {
430  nh_.spinOnce();
431  }
432 }
433 
434 template <typename TMotorController, typename TMotorDriver>
436 {
437  nh_.loginfo("Get Parameters from Parameter Server");
438  nh_.getParam("/diffbot/encoder_resolution", &this->encoder_resolution_);
439  String log_msg = String("/diffbot/encoder_resolution: ") + String(encoder_resolution_);
440  nh_.loginfo(log_msg.c_str());
441  nh_.getParam("/diffbot/mobile_base_controller/wheel_radius", &wheel_radius_);
442  log_msg = String("/diffbot/mobile_base_controller/wheel_radius: ") + String(wheel_radius_);
443  nh_.loginfo(log_msg.c_str());
444  nh_.getParam("/diffbot/mobile_base_controller/linear/x/max_velocity", &max_linear_velocity_);
445  log_msg = String("/diffbot/mobile_base_controller/linear/x/max_velocity: ") + String(max_linear_velocity_);
446  nh_.loginfo(log_msg.c_str());
447  nh_.getParam("/diffbot/debug/base_controller", &debug_);
448  log_msg = String("/diffbot/debug/base_controller: ") + String(debug_);
449  nh_.loginfo(log_msg.c_str());
450 
451  nh_.loginfo("Initialize DiffBot Wheel Encoders");
452  encoder_left_.resolution(encoder_resolution_);
453  encoder_right_.resolution(encoder_resolution_);
454 
455  std_msgs::Empty reset;
456  this->resetEncodersCallback(reset);
457  delay(1);
458 
459  max_angular_velocity_ = max_linear_velocity_ / wheel_radius_;
460 
461  delay(1000);
462 }
463 
464 template <typename TMotorController, typename TMotorDriver>
466 {
467  // Callback function every time the angular wheel commands for each wheel joint are received from 'wheel_cmd_velocities' topic
468  // This callback function receives diffbot_msgs::WheelsCmdStamped message object
469  // where diffbot_msgs::AngularVelocities for both joints are stored
470  wheel_cmd_velocity_left_ = cmd_msg.wheels_cmd.angular_velocities.joint[0];
471  wheel_cmd_velocity_right_ = cmd_msg.wheels_cmd.angular_velocities.joint[1];
472 
473  // Used for the eStop. In case no diffbot_msgs::WheelsCmdStamped messages are received on the wheel_cmd_velocities
474  // topic, the eStop method is called (see main loop in main.cpp)
475  lastUpdateTime().command_received = nh_.now();
476 }
477 
478 // ROS Subscriber setup to reset both encoders to zero
479 template <typename TMotorController, typename TMotorDriver>
481 {
482  // reset both back to zero.
483  this->encoder_left_.write(0);
484  this->encoder_right_.write(0);
485  this->nh_.loginfo("Reset both wheel encoders to zero");
486 }
487 
488 
489 template <typename TMotorController, typename TMotorDriver>
491 {
492  // Callback function to update the pid values of the left motor
493  // This callback function receives diffbot_msgs::PID message object
494  // where diffbot_msgs::PID kp, ki, kd for one pid controller is stored
495  motor_pid_left_.updateConstants(pid_msg.pid.kp, pid_msg.pid.ki, pid_msg.pid.kd);
496  motor_pid_left_.updateConstants(pid_msg.pid.kp, pid_msg.pid.ki, pid_msg.pid.kd);
497 }
498 
499 template <typename TMotorController, typename TMotorDriver>
501 {
502  // Callback function to update the pid values of the left motor
503  // This callback function receives diffbot_msgs::PID message object
504  // where diffbot_msgs::PID kp, ki, kd for one pid controller is stored
505  motor_pid_left_.updateConstants(pid_msg.pid.kp, pid_msg.pid.ki, pid_msg.pid.kd);
506  motor_pid_left_.updateConstants(pid_msg.pid.kp, pid_msg.pid.ki, pid_msg.pid.kd);
507 }
508 
509 
510 template <typename TMotorController, typename TMotorDriver>
512 {
513  joint_state_left_ = encoder_left_.jointState();
514  joint_state_right_ = encoder_right_.jointState();
515 
516  msg_measured_joint_states_.position[0] = joint_state_left_.angular_position_;
517  msg_measured_joint_states_.position[1] = joint_state_right_.angular_position_;
518 
519  msg_measured_joint_states_.velocity[0] = joint_state_left_.angular_velocity_;
520  msg_measured_joint_states_.velocity[1] = joint_state_right_.angular_velocity_;
521  pub_measured_joint_states_.publish(&msg_measured_joint_states_);
522 
523  // get the current tick count of each encoder
524  ticks_left_ = encoder_left_.read();
525  ticks_right_ = encoder_right_.read();
526 
527  encoder_msg_.encoders.ticks[0] = ticks_left_;
528  encoder_msg_.encoders.ticks[1] = ticks_right_;
529  // Avoid having too many publishers
530  // Otherwise error like 'wrong checksum for topic id and msg'
531  // and 'Write timeout: Write timeout' happen.
532  //pub_encoders_.publish(&encoder_msg_);
533 }
534 
535 template <typename TMotorController, typename TMotorDriver>
537 {
538  // https://www.arduino.cc/reference/en/language/functions/math/map/
539  // map(value, fromLow, fromHigh, toLow, toHigh)
540  // Map angular wheel joint velocity to motor cmd
541  // The /diffbot/mobile_base_controller/linear/x/max_velocity from the ROS parameter server
542  // is convert to max rotational velocity (see init()) and used to map the angular velocity to PWM signals for the motor.
543  // Note this is currently unused because the PID helps to keep the velocity to the commanded one.
544  //motor_cmd_left_ = map(wheel_cmd_velocity_left_, -max_angular_velocity_, max_angular_velocity_, PWM_MIN, PWM_MAX);
545  //motor_cmd_right_ = map(wheel_cmd_velocity_right_, -max_angular_velocity_, max_angular_velocity_, PWM_MIN, PWM_MAX);
546 
547  // Compute PID output
548  // The value sent to the motor driver is calculated by the PID based on the error between commanded angular velocity vs measured angular velocity
549  // The calculated PID ouput value is capped at -/+ MAX_RPM to prevent the PID from having too much error
550  motor_cmd_left_ = motor_pid_left_.compute(wheel_cmd_velocity_left_, joint_state_left_.angular_velocity_);
551  motor_cmd_right_ = motor_pid_right_.compute(wheel_cmd_velocity_right_, joint_state_right_.angular_velocity_);
552 
553  p_motor_controller_left_->setSpeed(motor_cmd_left_);
554  p_motor_controller_right_->setSpeed(motor_cmd_right_);
555 }
556 
557 template <typename TMotorController, typename TMotorDriver>
559 {
560  wheel_cmd_velocity_left_ = 0;
561  wheel_cmd_velocity_right_ = 0;
562 }
563 
564 template <typename TMotorController, typename TMotorDriver>
566 {
567  /*
568  String log_msg =
569  String("\nRead:\n") +
570  String("ticks_left_ \t ticks_right_ \t measured_ang_vel_left \t measured_ang_vel_right\n") +
571  String(ticks_left_) + String("\t") + String(ticks_right_) + String("\t") +
572  String(joint_state_left_.angular_velocity_) + String("\t") + String(joint_state_right_.angular_velocity_) +
573  String("\nWrite:\n") +
574  String("motor_cmd_left_ \t motor_cmd_right_ \t pid_left_error \t pid_right_error\n") +
575  String(motor_cmd_left_) + String("\t") + String(motor_cmd_right_) + String("\t") +
576  //String("pid_left \t pid_right\n") +
577  String(motor_pid_left_.error()) + String("\t") + String(motor_pid_right_.error());
578  */
579 
580  String log_msg =
581  String("\nRead:\n") +
582  String("ticks_left_: ") + String(ticks_left_) +
583  String("\nticks_right_: ") + String(ticks_right_) +
584  String("\nmeasured_ang_vel_left: ") + String(joint_state_left_.angular_velocity_) +
585  String("\nmeasured_ang_vel_right: ") + String(joint_state_right_.angular_velocity_) +
586  String("\nwheel_cmd_velocity_left_: ") + String(wheel_cmd_velocity_left_) +
587  String("\nwheel_cmd_velocity_right_: ") + String(wheel_cmd_velocity_right_) +
588 
589  String("\nWrite:\n") +
590  String("motor_cmd_left_: ") + String(motor_cmd_left_) +
591  String("\nmotor_cmd_right_: ") + String(motor_cmd_right_) +
592  String("\npid_left_errors (p, i, d): ") + String(motor_pid_left_.proportional()) + String(" ") + String(motor_pid_left_.integral()) + String(" ") + String(motor_pid_left_.derivative()) +
593  String("\npid_right_error (p, i, d): ") + String(motor_pid_right_.proportional()) + String(" ") + String(motor_pid_right_.integral()) + String(" ") + String(motor_pid_right_.derivative());
594  nh_.loginfo(log_msg.c_str());
595 }
596 
597 
598 #endif // DIFFBOT_BASE_CONTROLLER_H
diffbot_base_config.h
diffbot
Definition: base_controller.h:23
diffbot::BaseController::UpdateRate::control_
double control_
Definition: base_controller.h:106
diffbot::BaseController::read
void read()
Reads the current encoder tick counts and joint states (angular position (rad) and angular velocity (...
Definition: base_controller.h:511
diffbot::BaseController::motor_pid_right_
PID motor_pid_right_
Definition: base_controller.h:370
PWM_MAX
#define PWM_MAX
Definition: diffbot_base_config.h:33
diffbot_msgs::PID::ki
_ki_type ki
Definition: PID.h:18
ros::Publisher
ENCODER_RIGHT_H1
#define ENCODER_RIGHT_H1
Definition: diffbot_base_config.h:10
diffbot_msgs::WheelsCmdStamped
Definition: WheelsCmdStamped.h:14
diffbot::BaseController::encoder_resolution_
unsigned long encoder_resolution_
Definition: base_controller.h:345
K_P
#define K_P
Definition: diffbot_base_config.h:18
diffbot::BaseController::UpdateRate::period
Period & period()
Definition: base_controller.h:126
diffbot::BaseController::setup
void setup()
Initializes the main node handle and setup publisher and subscriber.
Definition: base_controller.h:406
diffbot::JointState
Definition: encoder_diffbot.h:15
diffbot::BaseController::motor_pid_left_
PID motor_pid_left_
Definition: base_controller.h:369
ENCODER_RESOLUTION
#define ENCODER_RESOLUTION
Definition: diffbot_base_config.h:8
diffbot::BaseController::joint_state_right_
diffbot::JointState joint_state_right_
Definition: base_controller.h:343
WheelsCmdStamped.h
ros.h
diffbot::BaseController::msg_measured_joint_states_
sensor_msgs::JointState msg_measured_joint_states_
Definition: base_controller.h:354
diffbot_msgs::WheelsCmd::angular_velocities
_angular_velocities_type angular_velocities
Definition: WheelsCmd.h:17
diffbot::BaseController::LastUpdateTime::debug
ros::Time debug
Definition: base_controller.h:176
diffbot::BaseController::encoder_left_
diffbot::Encoder encoder_left_
Definition: base_controller.h:338
UPDATE_RATE_IMU
#define UPDATE_RATE_IMU
Definition: diffbot_base_config.h:26
diffbot::BaseController::motor_cmd_left_
int motor_cmd_left_
Definition: base_controller.h:364
diffbot_msgs::EncodersStamped
Definition: EncodersStamped.h:14
diffbot::BaseController::init
void init()
Reads parameters from the parameter server.
Definition: base_controller.h:435
diffbot::BaseController::eStop
void eStop()
Stops the motors, in case no wheel commands are received over a longer time period.
Definition: base_controller.h:558
diffbot::BaseController::ticks_left_
long ticks_left_
Definition: base_controller.h:340
ENCODER_LEFT_H2
#define ENCODER_LEFT_H2
Definition: diffbot_base_config.h:5
ENCODER_LEFT_H1
#define ENCODER_LEFT_H1
Encoder pins.
Definition: diffbot_base_config.h:4
motor_controller_left
AdafruitMotorController motor_controller_left
Definition: main.cpp:13
diffbot::BaseController::UpdateRate
Stores update rate frequencies (Hz) for the main control loop, (optinal) imu and debug output.
Definition: base_controller.h:103
diffbot::BaseController::max_angular_velocity_
float max_angular_velocity_
Definition: base_controller.h:330
diffbot::BaseController::update_rate_
struct diffbot::BaseController::UpdateRate update_rate_
ENCODER_RIGHT_H2
#define ENCODER_RIGHT_H2
Definition: diffbot_base_config.h:11
diffbot::BaseController::UpdateRate::debug_
double debug_
Definition: base_controller.h:107
diffbot_msgs::PIDStamped::pid
_pid_type pid
Definition: PIDStamped.h:20
diffbot::BaseController::motor_cmd_right_
int motor_cmd_right_
Definition: base_controller.h:365
diffbot::BaseController::UpdateRate::period_
struct diffbot::BaseController::UpdateRate::Period period_
diffbot::BaseController::commandCallback
void commandCallback(const diffbot_msgs::WheelsCmdStamped &cmd_msg)
Callback method when a new diffbot_msgs::WheelsCmdStamped is received on the wheel_cmd_velocities top...
Definition: base_controller.h:465
diffbot::BaseController::last_update_time_
struct diffbot::BaseController::LastUpdateTime last_update_time_
diffbot::BaseController::UpdateRate::UpdateRate
UpdateRate(double imu_frequency, double control_frequency, double debug_frequency)
Construct a new Update Rate object.
Definition: base_controller.h:139
K_D
#define K_D
Definition: diffbot_base_config.h:20
diffbot::BaseController
Communicates with the high level hardware_interface::RobotHW and interacts with the robot hardware se...
Definition: base_controller.h:77
adafruit_feather_wing.h
diffbot::BaseController::LastUpdateTime
Keeps track of the last update times.
Definition: base_controller.h:167
diffbot::BaseController::debug
bool debug()
Getter if the firmware should log debug output.
Definition: base_controller.h:211
diffbot::BaseController::encoder_right_
diffbot::Encoder encoder_right_
Definition: base_controller.h:339
diffbot::BaseController::sub_wheel_cmd_velocities_
ros::Subscriber< diffbot_msgs::WheelsCmdStamped, BaseController< TMotorController, TMotorDriver > > sub_wheel_cmd_velocities_
Definition: base_controller.h:360
diffbot::BaseController::LastUpdateTime::imu
ros::Time imu
Definition: base_controller.h:174
diffbot::BaseController::encoder_msg_
diffbot_msgs::EncodersStamped encoder_msg_
Definition: base_controller.h:351
EncodersStamped.h
diffbot::BaseController::p_motor_controller_left_
MotorControllerIntf< TMotorDriver > * p_motor_controller_left_
Definition: base_controller.h:358
diffbot::BaseController::sub_pid_left_
ros::Subscriber< diffbot_msgs::PIDStamped, BaseController< TMotorController, TMotorDriver > > sub_pid_left_
Definition: base_controller.h:367
diffbot::BaseController::joint_state_left_
diffbot::JointState joint_state_left_
Definition: base_controller.h:343
diffbot::BaseController::LastUpdateTime::command_received
ros::Time command_received
Definition: base_controller.h:170
diffbot::BaseController::nh_
ros::NodeHandle & nh_
Definition: base_controller.h:325
diffbot::BaseController::BaseController
BaseController(ros::NodeHandle &nh, TMotorController *motor_controller_left, TMotorController *motor_controller_right)
Construct a new Base Controller object using two generic motor controllers.
Definition: base_controller.h:385
nh
ros::NodeHandle nh
Definition: main.cpp:8
diffbot::BaseController::wheel_cmd_velocity_left_
float wheel_cmd_velocity_left_
Definition: base_controller.h:361
diffbot::BaseController::wheel_radius_
float wheel_radius_
Definition: base_controller.h:328
diffbot::BaseController::sub_reset_encoders_
ros::Subscriber< std_msgs::Empty, BaseController< TMotorController, TMotorDriver > > sub_reset_encoders_
Definition: base_controller.h:347
AngularVelocities.h
diffbot::BaseController::UpdateRate::Period::debug_
double debug_
Definition: base_controller.h:118
start
ROSCPP_DECL void start()
K_I
#define K_I
Definition: diffbot_base_config.h:19
diffbot::BaseController::pidLeftCallback
void pidLeftCallback(const diffbot_msgs::PIDStamped &pid_msg)
Callback method to update the PID constants for the left motor.
Definition: base_controller.h:490
ros::Time
diffbot_msgs::WheelsCmdStamped::wheels_cmd
_wheels_cmd_type wheels_cmd
Definition: WheelsCmdStamped.h:20
diffbot::BaseController::max_linear_velocity_
float max_linear_velocity_
Definition: base_controller.h:329
diffbot::BaseController::lastUpdateTime
LastUpdateTime & lastUpdateTime()
Returns a reference to last_update_times_.
Definition: base_controller.h:202
UPDATE_RATE_CONTROL
#define UPDATE_RATE_CONTROL
Definition: diffbot_base_config.h:25
diffbot::BaseController::pidRightCallback
void pidRightCallback(const diffbot_msgs::PIDStamped &pid_msg)
Callback method to update the PID constants for the right motor.
Definition: base_controller.h:500
diffbot::BaseController::period
int period(double frequency)
Calculates the period (s) from a given frequency (Hz).
Definition: base_controller.h:154
diffbot::BaseController::UpdateRate::imu_
double imu_
Definition: base_controller.h:105
diffbot_msgs::AngularVelocities::joint
_joint_type * joint
Definition: AngularVelocities.h:18
diffbot::BaseController::publishRate
UpdateRate & publishRate()
Definition: base_controller.h:156
diffbot::BaseController::UpdateRate::Period::imu_
double imu_
Definition: base_controller.h:116
diffbot::BaseController::printDebug
void printDebug()
Definition: base_controller.h:565
diffbot::BaseController::wheel_cmd_velocity_right_
float wheel_cmd_velocity_right_
Definition: base_controller.h:362
diffbot::BaseController::LastUpdateTime::LastUpdateTime
LastUpdateTime(ros::Time start)
Construct a new Last Update Time object.
Definition: base_controller.h:186
diffbot::BaseController::p_motor_controller_right_
MotorControllerIntf< TMotorDriver > * p_motor_controller_right_
Definition: base_controller.h:357
diffbot::Encoder
Decorates the Teensy Encoder Library to read the angular wheel velocity from quadrature wheel encoder...
Definition: encoder_diffbot.h:35
diffbot_msgs::PID::kp
_kp_type kp
Definition: PID.h:16
UPDATE_RATE_DEBUG
#define UPDATE_RATE_DEBUG
Definition: diffbot_base_config.h:27
diffbot_msgs::PID::kd
_kd_type kd
Definition: PID.h:20
diffbot::PID
Definition: scripts/base_controller/lib/pid/pid.h:6
diffbot::BaseController::UpdateRate::Period::control_
double control_
Definition: base_controller.h:117
diffbot::BaseController::ticks_right_
long ticks_right_
Definition: base_controller.h:340
diffbot::BaseController::UpdateRate::Period::Period
Period(double imu_frequency, double control_frequency, double debug_frequency)
Definition: base_controller.h:120
ros::Subscriber
diffbot_msgs::PIDStamped
Definition: PIDStamped.h:14
diffbot::BaseController::LastUpdateTime::control
ros::Time control
Definition: base_controller.h:172
motor_controller_right
AdafruitMotorController motor_controller_right
Definition: main.cpp:12
diffbot::BaseController::UpdateRate::Period
Inverse of the update rates for control, (optional) imu and debug output.
Definition: base_controller.h:114
diffbot::MotorControllerIntf
Abstract base interface class for a motor controller.
Definition: motor_controller_interface.h:17
diffbot::BaseController::debug_
bool debug_
Definition: base_controller.h:373
diffbot::BaseController::pub_encoders_
ros::Publisher pub_encoders_
Definition: base_controller.h:352
diffbot::BaseController::write
void write()
Uses the PIDs to compute capped PWM signals for the left and right motor.
Definition: base_controller.h:536
diffbot::BaseController::pub_measured_joint_states_
ros::Publisher pub_measured_joint_states_
Definition: base_controller.h:355
diffbot::BaseController::resetEncodersCallback
void resetEncodersCallback(const std_msgs::Empty &reset_msg)
Callback method to reset both encoder's tick count to zero.
Definition: base_controller.h:480
encoder_diffbot.h
PIDStamped.h
ros::NodeHandle
diffbot::BaseController::sub_pid_right_
ros::Subscriber< diffbot_msgs::PIDStamped, BaseController< TMotorController, TMotorDriver > > sub_pid_right_
Definition: base_controller.h:368


diffbot_base
Author(s):
autogenerated on Thu Sep 7 2023 02:35:23