Ros.h
Go to the documentation of this file.
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 //#include "body_msgs/Skeletons.h"
00031 
00032 #include "sensor_msgs/NavSatFix.h"
00033 
00034 #include <QGraphicsScene>
00035 
00036 //#include "dynamic_uvc_cam/control.h"
00037 //#include "dynamic_uvc_cam/setcontrol.h"
00038 //#include "dynamic_uvc_cam/state.h"
00039 //#include "dynamic_uvc_cam/videomode.h"
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     //ros variables to call services and to get messages from a topic
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; // subsriber for rear_cam and PTZ_cam
00062 
00063 
00064     ros::Publisher driveControl_pub, velocityValue_pub, moveArm_pub;
00065     //*************************************************************************
00066     //Hardware component "ctf" subscriber
00067     ros::Subscriber ssc32_info_sub,phidget_info_sub;
00068 
00069     //*************************************************************************
00070     //Receive message from Joy stick
00071     ros::Subscriber takepic_sub;
00072 
00073     //Motion speed options
00074     //Forward speed Backward speed
00075     //Turning speed
00076 
00077 
00078     bool cameraRear_jpeg_compression, cameraFront_jpeg_compression; //True if the jpeg compression is activated
00079     bool arm_al5a, arm_pincher, arm_reactor, arm_old_ssc32, arm_old_phidget; //is there a lynxmotion al5a arm? a PhantomX pincher? a Phantom X reactor? Or maybe an old corobot_arm? 
00080 
00081     float speed_x,speed_a; //linear and angular speed
00082     int speed_value; //Maximum speed of the wheels. Between 0 and 100.
00083     bool initialized;
00084     float arm_px,arm_py; //arm position
00085     float speed_left, speed_right; //Speed of the left wheel and right wheel. Between -100 and 100
00086     bool turningLeft, turningRight; //Is the robot turning left, is the robot turning right
00087 
00088    // float last_x_pos,last_y_pos; for kinect hand gesture detection
00089 
00090     bool kinect_selected; //is kinect selected?
00091 
00092 
00093     QGraphicsScene * scenes_map_image;//map image scene
00094     QGraphicsScene * scenes_front_image;//front camera view in the easy view tab
00095     QGraphicsScene * scenes_rear_cam;//rear camera scene
00096     QGraphicsScene * scenes_ptz_cam;//ptz camera scene
00097     QGraphicsScene * scenes;//hd camera scene
00098     QGraphicsScene * scenes_kinect_rgb; //kinect rgb scene
00099     QGraphicsScene * scenes_kinect_depth; //kinect depth scene
00100 
00101 
00102     bool Corobot; //is Corobot
00103 
00104     Image image_kinect_depth;// allcamera scene : bottom right image
00105     Image image_kinect_rgb;// allcamera scene : bottom right image
00106     Image image_camera;// allcamera scene : bottom right image
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); //position of the robot arm
00117        void angleWristReal (double angle);//angle of the robot wrist
00118        void irData(double ir01, double ir02);
00119        void battery_percent(int value); //percentage of battery left
00120      //  void ptzData();
00121        void griperState(int state); //gripper state
00122        void gps_lat(double lat); //robot lattitude
00123        void gps_lon(double lon); //robot longitude
00124        void gps_coord(double lat, double lon); //gps coordinate
00125        void arm_model(bool arm_al5a,bool arm_pincher,bool arm_reactor,bool arm_old_corobot); //give the model of the arm connected to the robot
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); //turn the robor wrist
00144        void moveGripper(bool state);//change gripper state
00145        void corobot(bool value);//is robot a corobot or explorer
00146        void select_kinect(bool value);//is kinect selected
00147     //   bool move_forward();
00148    //    bool move_backward();
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); //subscribe to only the camera topics we are interested in
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(); //function that initialize every ros variables declared above.
00174 
00175 
00176         void velocityCallback(const nav_msgs::Odometry::ConstPtr& msg);//just receive position data from the robot
00177         void irCallback(const corobot_msgs::IrMsg::ConstPtr& msg); //just received ir data from the robot
00178         void powerCallback(const corobot_msgs::PowerMsgConstPtr& msg);//just received power data from the robot
00179         void bumperCallback(const corobot_msgs::BumperMsg::ConstPtr& msg);//just received bumper data from the robot
00180         void gripperCallback(const corobot_msgs::GripperMsg::ConstPtr& msg);//just received gripper data from the robot
00181         void cameraInfoCallback(const sensor_msgs::CameraInfo::ConstPtr& msg);//just reiceved camera information from the robot
00182         void cameraImageCallback(const sensor_msgs::Image::ConstPtr& msg);//just received hd camera image from the robot
00183         void gpsCallback(const sensor_msgs::NavSatFix::ConstPtr& msg);//just receive gps information from the robot
00184         void scanCallback(const sensor_msgs::LaserScan::ConstPtr& msg);//just receive hokuyo information from the robot
00185         void kinectdepthCallback(const sensor_msgs::Image::ConstPtr& msg);//just received kinect depth image from the robot
00186         void kinectrgbCallback(const sensor_msgs::CompressedImage::ConstPtr& msg);//just received kinect rgb image from the robot
00187         void spatialCallback(const corobot_msgs::spatial::ConstPtr& msg);
00188 
00189         void takepicCallback(const corobot_msgs::takepic::ConstPtr& msg);
00190 
00191 
00192         //*****************************************************************
00193         //Modified to compress image for the sake of wifi transmitting
00194         //void rear_camCallback(const sensor_msgs::CompressedImage::ConstPtr& msg);
00195         //void ptz_camCallback(const sensor_msgs::CompressedImage::ConstPtr& msg);
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        // void kinectskelCallback(const body_msgs::Skeletons::ConstPtr& msg);
00202 
00203 
00204         //Hardware info callback
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);//change the encoders
00218        bool resetOdom();//reset the encoders
00219        void resetArm();//reset arm position
00220 
00221        void openGripper();//open the gripepr
00222        void closeGripper();//close the gripper
00223        bool setPtzcommand(int pan,int tilt);//change pan, tilt
00224        bool setPtzmode(int mode);
00225        bool setCameraControl(int id, int value);
00226        bool setCameraState(bool state);//true = start, falsedriveControl_client = stop
00227        bool setCameraMode(int width, int weight, bool immediately, int fps, bool auto_exposure);
00228 
00229        //void setRangeWidgetParent(QWidget* parent);
00230        //void setRangeWidget2Parent(QWidget* parent);
00231 
00232        int pan,tilt; //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;//SSC32 control value for two main DC motors, range from 500 - 2500
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


corobot_teleop
Author(s): Morgan Cormier/Gang Li/mcormier@coroware.com
autogenerated on Tue Jan 7 2014 11:39:41