Go to the documentation of this file.00001
00026 #include <ros/ros.h>
00027 #include "grizzly_motion/change_limiter.h"
00028
00029 #include "diagnostic_updater/diagnostic_updater.h"
00030 #include "diagnostic_updater/publisher.h"
00031
00032 using boost::shared_ptr;
00033
00034 namespace grizzly_msgs {
00035 ROS_DECLARE_MESSAGE(Drive);
00036 ROS_DECLARE_MESSAGE(RawStatus);
00037 }
00038
00039 namespace std_msgs {
00040 ROS_DECLARE_MESSAGE(Bool);
00041 }
00042
00043 namespace diagnostic_updater {
00044 class Updater;
00045 class HeaderlessTopicDiagnostic;
00046 }
00047
00048 class EncodersMonitor;
00049 class MotorsMonitor;
00050
00051 typedef ChangeLimiter<grizzly_msgs::Drive> DriveChangeLimiter;
00052
00053 namespace MotionStates
00054 {
00055 enum MotionState
00056 {
00057
00058
00059
00060
00061 Stopped,
00062
00063
00064
00065 Starting,
00066
00067
00068 Moving,
00069
00070
00071
00072
00073 PendingStopped,
00074
00075
00076
00077 Fault
00078 };
00079 }
00080 typedef MotionStates::MotionState MotionState;
00081
00082 class MotionSafety
00083 {
00084 public:
00085 MotionSafety() {}
00086 MotionSafety(ros::NodeHandle* nh);
00087
00088 bool isEstopped();
00089 void setStop(const std::string reason, bool estop, bool fault);
00090 void checkFaults();
00091
00092 protected:
00093 ros::NodeHandle* nh_;
00094
00095
00096
00097
00098 void watchdogCallback(const ros::TimerEvent&);
00099 ros::Timer watchdog_timer_;
00100 MotionState state_;
00101 std::string reason_;
00102
00103
00104
00105 ros::Time last_commanded_movement_time_;
00106 ros::Time last_non_precharge_time_;
00107
00108
00109 ros::Duration starting_duration_;
00110
00111
00112
00113 ros::Time transition_to_moving_time_;
00114
00115
00116 void driveCallback(const grizzly_msgs::DriveConstPtr&);
00117 void estopCallback(const std_msgs::BoolConstPtr&);
00118 void mcuStatusCallback(const grizzly_msgs::RawStatusConstPtr&);
00119 ros::Subscriber sub_drive_, sub_mcu_status_, sub_user_estop_;
00120 grizzly_msgs::RawStatusConstPtr last_mcu_status_;
00121
00122
00123 ros::Publisher pub_safe_drive_;
00124
00125
00126 ros::Publisher pub_ambience_;
00127 ros::Publisher pub_estop_;
00128
00129
00130 shared_ptr<diagnostic_updater::Updater> diagnostic_updater_;
00131 void diagnostic(diagnostic_updater::DiagnosticStatusWrapper& stat);
00132
00133
00134
00135 double expected_mcu_status_frequency_;
00136 double min_cmd_drive_freq_, max_cmd_drive_freq_;
00137 shared_ptr<diagnostic_updater::HeaderlessTopicDiagnostic> diag_mcu_status_freq_, diag_cmd_drive_freq_;
00138
00139
00140 shared_ptr<EncodersMonitor> encoders_monitor_;
00141 shared_ptr<MotorsMonitor> motor_drivers_monitor_;
00142 shared_ptr<DriveChangeLimiter> accel_limiters_[4];
00143
00144 double width_;
00145 double radius_;
00146 double max_accel_;
00147 };
00148
00149