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