00001 #ifndef ROS_H
00002 #define ROS_H
00003
00004 #include <QThread>
00005
00006 #include "ros/ros.h"
00007 #include "corobot_srvs/SetSpeed.h"
00008 #include "corobot_srvs/SetOdom.h"
00009 #include "corobot_srvs/MoveArm.h"
00010 #include "nav_msgs/Odometry.h"
00011 #include "corobot_msgs/IrMsg.h"
00012 #include "corobot_msgs/PowerMsg.h"
00013 #include "corobot_msgs/BumperMsg.h"
00014 #include "corobot_msgs/GripperMsg.h"
00015 #include "corobot_msgs/PanTilt.h"
00016 #include "corobot_msgs/spatial.h"
00017 #include "corobot_msgs/ssc32_info.h"
00018 #include "corobot_msgs/phidget_info.h"
00019 #include "corobot_msgs/takepic.h"
00020 #include "corobot_msgs/MoveArm.h"
00021 #include "sensor_msgs/CameraInfo.h"
00022 #include "sensor_msgs/Image.h"
00023 #include "sensor_msgs/CompressedImage.h"
00024 #include "sensor_msgs/LaserScan.h"
00025 #include "corobot_msgs/velocityValue.h"
00026
00027 #include "corobot_msgs/MotorCommand.h"
00028
00029
00030
00031
00032 #include "sensor_msgs/NavSatFix.h"
00033
00034 #include <QGraphicsScene>
00035
00036
00037
00038
00039
00040
00041 #include "Point.h"
00042 #include "Image.h"
00043 #include "ImageBig.h"
00044 #include "Hokuyo.h"
00045
00046 const float BATTERY_EMPTY= 12* 7/10;
00047
00048 class Ros : public QThread {
00049
00050 Q_OBJECT
00051
00052 private:
00053
00054 ros::ServiceClient setOdom_client;
00055
00056
00057 ros::Timer timer;
00058
00059 ros::Subscriber velocity,ir,power,bumper,ptz,gripper,arm,cameraInfo,cameraImage,spatial,map_image;
00060 ros::Subscriber gps,scan,kinect_rgb,kinect_depth,kinect_skel;
00061 ros::Subscriber rear_cam,ptz_cam;
00062
00063
00064 ros::Publisher driveControl_pub, velocityValue_pub, moveArm_pub;
00065
00066
00067 ros::Subscriber ssc32_info_sub,phidget_info_sub;
00068
00069
00070
00071 ros::Subscriber takepic_sub;
00072
00073
00074
00075
00076
00077
00078 bool cameraRear_jpeg_compression, cameraFront_jpeg_compression;
00079 bool arm_al5a, arm_pincher, arm_reactor, arm_old_ssc32, arm_old_phidget;
00080
00081 float speed_x,speed_a;
00082 int speed_value;
00083 bool initialized;
00084 float arm_px,arm_py;
00085 float speed_left, speed_right;
00086 bool turningLeft, turningRight;
00087
00088
00089
00090 bool kinect_selected;
00091
00092
00093 QGraphicsScene * scenes_map_image;
00094 QGraphicsScene * scenes_front_image;
00095 QGraphicsScene * scenes_rear_cam;
00096 QGraphicsScene * scenes_ptz_cam;
00097 QGraphicsScene * scenes;
00098 QGraphicsScene * scenes_kinect_rgb;
00099 QGraphicsScene * scenes_kinect_depth;
00100
00101
00102 bool Corobot;
00103
00104 Image image_kinect_depth;
00105 Image image_kinect_rgb;
00106 Image image_camera;
00107 Image image_rear_cam;
00108 Image image_ptz_cam;
00109 Image image_front_cam;
00110 Image image_map_image;
00111
00112 void timerCallback(const ros::TimerEvent& event);
00113
00114
00115 signals :
00116 void posArmReal(double x, double y);
00117 void angleWristReal (double angle);
00118 void irData(double ir01, double ir02);
00119 void battery_percent(int value);
00120
00121 void griperState(int state);
00122 void gps_lat(double lat);
00123 void gps_lon(double lon);
00124 void gps_coord(double lat, double lon);
00125 void arm_model(bool arm_al5a,bool arm_pincher,bool arm_reactor,bool arm_old_corobot);
00126
00127 void update_mapimage(QImage image);
00128 void update_rearcam(QImage image);
00129 void update_ptzcam(QImage image);
00130 void update_kinectDepthcam(QImage image);
00131 void update_kinectRGBcam(QImage image);
00132 void battery_volts(double volts);
00133 void bumper_update(int bumper1, int bumper2, int bumper3, int bumper4);
00134
00135 void velocity_info(double linear, double angular);
00136
00137 void spatial_data(double acc_x,double acc_y, double acc_z, double ang_x, double ang_y, double ang_z, double mag_x, double mag_y, double mag_z);
00138
00139 void hokuyo_update(Hokuyo_Points* hokuyo_points);
00140
00141 public slots:
00142
00143 void turnWrist(float angle);
00144 void moveGripper(bool state);
00145 void corobot(bool value);
00146 void select_kinect(bool value);
00147
00148
00149 bool turn_left();
00150 bool turn_right();
00151 bool motor_stop();
00152 void moveShoulderArm(double shoulder);
00153 void moveElbowArm(double elbow);
00154 void rotateArm(double angle);
00155 void ResetArm();
00156 bool decrease_speed();
00157 bool increase_speed();
00158 bool increase_backward_speed();
00159 bool stop_turn();
00160 void setSpeedFast(bool toggled);
00161 void setSpeedModerate(bool toggled);
00162 void setSpeedSlow(bool toggled);
00163 void currentCameraTabChanged(int index);
00164
00165 public:
00166 void run();
00167 ~Ros();
00168 Ros();
00169 void init();
00170 void init(const std::string & master, const std::string & host);
00171
00172 ros::Publisher pan_tilt_control;
00173 void subscribe();
00174
00175
00176 void velocityCallback(const nav_msgs::Odometry::ConstPtr& msg);
00177 void irCallback(const corobot_msgs::IrMsg::ConstPtr& msg);
00178 void powerCallback(const corobot_msgs::PowerMsgConstPtr& msg);
00179 void bumperCallback(const corobot_msgs::BumperMsg::ConstPtr& msg);
00180 void gripperCallback(const corobot_msgs::GripperMsg::ConstPtr& msg);
00181 void cameraInfoCallback(const sensor_msgs::CameraInfo::ConstPtr& msg);
00182 void cameraImageCallback(const sensor_msgs::Image::ConstPtr& msg);
00183 void gpsCallback(const sensor_msgs::NavSatFix::ConstPtr& msg);
00184 void scanCallback(const sensor_msgs::LaserScan::ConstPtr& msg);
00185 void kinectdepthCallback(const sensor_msgs::Image::ConstPtr& msg);
00186 void kinectrgbCallback(const sensor_msgs::CompressedImage::ConstPtr& msg);
00187 void spatialCallback(const corobot_msgs::spatial::ConstPtr& msg);
00188
00189 void takepicCallback(const corobot_msgs::takepic::ConstPtr& msg);
00190
00191
00192
00193
00194
00195
00196 void mapCallback(const sensor_msgs::CompressedImage::ConstPtr& msg);
00197 void rear_camCallback_compressed(const sensor_msgs::CompressedImage::ConstPtr& msg);
00198 void ptz_camCallback_compressed(const sensor_msgs::CompressedImage::ConstPtr& msg);
00199 void rear_camCallback(const sensor_msgs::Image::ConstPtr& msg);
00200 void ptz_camCallback(const sensor_msgs::Image::ConstPtr& msg);
00201
00202
00203
00204
00205 void ssc32infoCallback(const corobot_msgs::ssc32_info::ConstPtr& msg);
00206 void phidgetinfoCallback(const corobot_msgs::phidget_info::ConstPtr& msg);
00207
00208 void add_map_image_scene(QGraphicsScene * scene);
00209 void add_front_image_scene(QGraphicsScene * scene);
00210 void add_camera_info_scene(QGraphicsScene * scene);
00211 void add_rear_cam_scene(QGraphicsScene * scene);
00212 void add_ptz_cam_scene(QGraphicsScene * scene);
00213
00214 void add_kinect_rgb_scene(QGraphicsScene * scene);
00215 void add_kinect_depth_scene(QGraphicsScene * scene);
00216 void add_allcam_scene(QGraphicsScene * scene);
00217 bool setOdom(float x, float y);
00218 bool resetOdom();
00219 void resetArm();
00220
00221 void openGripper();
00222 void closeGripper();
00223 bool setPtzcommand(int pan,int tilt);
00224 bool setPtzmode(int mode);
00225 bool setCameraControl(int id, int value);
00226 bool setCameraState(bool state);
00227 bool setCameraMode(int width, int weight, bool immediately, int fps, bool auto_exposure);
00228
00229
00230
00231
00232 int pan,tilt;
00233 int forwardspeed[3];
00234 int backwardspeed[3];
00235 int forwardspeed_chosen;
00236 int turnleftspeed;
00237 int turnrightspeed;
00238
00239 int left_motor_value;
00240 int right_motor_value;
00241 int move_speed_level;
00242 int turning_speed_level;
00243
00244 Hokuyo_Points* hokuyo_points_;
00245
00246 };
00247
00248
00249 #endif // ROS_H