00001 /* 00002 * Experiment.hpp 00003 * 00004 * Created on: Nov 15, 2011 00005 * Author: mriedel 00006 */ 00007 00008 #ifndef EXPERIMENT_HPP_ 00009 #define EXPERIMENT_HPP_ 00010 00011 #include <telekyb_base/Options.hpp> 00012 00013 #include <sensor_msgs/Joy.h> 00014 00015 #include <telekyb_interface/TeleKybSystem.hpp> 00016 #include <telekyb_interface/MKInterface.hpp> 00017 00018 #include "ExperimentDefines.hpp" 00019 #include "ExperimentOptions.hpp" 00020 00021 #include "udpraw.h" 00022 00023 namespace telekyb { 00024 00025 class Experiment : telekyb_interface::ActiveBehaviorListener { 00026 protected: 00027 // State 00028 State currState; 00029 ExperimentOptions options; 00030 // ROS 00031 ros::NodeHandle mainNodeHandle; 00032 ros::Subscriber joySub; 00033 ros::Subscriber handJoySub; 00034 00035 // the System 00036 telekyb_interface::TeleKybSystem* system; 00037 // BehaviorController 00038 telekyb_interface::BehaviorController* bController; 00039 telekyb_interface::OptionController *oController; 00040 00041 // Optional MKInterface 00042 telekyb_interface::MKInterface* mkInterface; 00043 00044 00045 // System Behaviors 00046 telekyb_interface::Behavior ground; 00047 telekyb_interface::Behavior hover; 00048 telekyb_interface::Behavior normalBreak; 00049 telekyb_interface::Behavior takeOff; 00050 telekyb_interface::Behavior land; 00051 00052 // Custom 00053 telekyb_interface::Behavior handJoystick; 00054 00055 00056 // FlyToBehaviors 00057 telekyb_interface::Behavior flyToTakeOff; 00058 telekyb_interface::Behavior flyTo; 00059 telekyb_interface::Behavior flyToLand; 00060 00061 // Behavior 00062 telekyb_interface::Behavior* activeBehaviorPtr; 00063 00064 // UDP 00065 Udpraw udp; 00066 00067 bool neutralPosSet; 00068 00069 public: 00070 Experiment(); 00071 virtual ~Experiment(); 00072 00073 // setup Behaviors 00074 void setupExperiment(); 00075 00076 void joystickCB(const sensor_msgs::Joy::ConstPtr& msg); 00077 void handJoystickCB(const sensor_msgs::Joy::ConstPtr& msg); 00078 00079 void readSpin(); 00080 00081 void activeBehaviorChanged(telekyb_interface::Behavior newActiveBehavior); 00082 00083 // send message to Virtools 00084 void changeState(const std::string& command, State newState); 00085 }; 00086 00087 } 00088 00089 #endif /* EXPERIMENT_HPP_ */