force_robot_companion_learning_alg_node.h
Go to the documentation of this file.
00001 // Copyright (C) 2010-2011 Institut de Robotica i Informatica Industrial, CSIC-UPC.
00002 // Author 
00003 // All rights reserved.
00004 //
00005 // This file is part of iri-ros-pkg
00006 // iri-ros-pkg is free software: you can redistribute it and/or modify
00007 // it under the terms of the GNU Lesser General Public License as published by
00008 // the Free Software Foundation, either version 3 of the License, or
00009 // at your option) any later version.
00010 //
00011 // This program is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public License
00017 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00018 // 
00019 // IMPORTANT NOTE: This code has been generated through a script from the 
00020 // iri_ros_scripts. Please do NOT delete any comments to guarantee the correctness
00021 // of the scripts. ROS topics can be easly add by using those scripts. Please
00022 // refer to the IRI wiki page for more information:
00023 // http://wikiri.upc.es/index.php/Robotics_Lab
00024 
00025 #ifndef _force_robot_companion_learning_alg_node_h_
00026 #define _force_robot_companion_learning_alg_node_h_
00027 
00028 #include <iri_base_algorithm/iri_base_algorithm.h>
00029 #include "force_robot_companion_learning_alg.h"
00030 
00031 
00032 // [publisher subscriber headers]
00033 #include <std_msgs/Float64.h>
00034 #include <sensor_msgs/LaserScan.h>
00035 #include <geometry_msgs/PoseArray.h>
00036 #include <geometry_msgs/PoseStamped.h>
00037 #include <geometry_msgs/PointStamped.h>
00038 //#include <geometry_msgs/Twist.h>
00039 #include <visualization_msgs/MarkerArray.h>
00040 #include <iri_perception_msgs/peopleTrackingArray.h>
00041 
00042 // [service client headers]
00043 #include <std_srvs/Empty.h>
00044 
00045 // [action server client headers]
00046 //#include <actionlib/client/simple_action_client.h>
00047 //#include <actionlib/client/terminal_state.h>
00048 //#include <move_base_msgs/MoveBaseAction.h>
00049 
00050 #include <tf/transform_listener.h>
00051 #include "nav/force_reactive_robot_companion_learning.h"
00052 #include <string>
00053 
00054 using namespace std;
00055 
00056 
00061 class ForceRobotCompanionLearningAlgNode : public algorithm_base::IriBaseAlgorithm<ForceRobotCompanionLearningAlgorithm>
00062 {
00063     enum sim_state {Init_Sim=0, Find_Nearest, Test_Sim, End_Sim };
00064     enum learning_mode {Density=0, Initial_paramters };
00065   private:
00066      // [publisher attributes]
00067     ros::Publisher angle_robot_person_publisher_;
00068     std_msgs::Float64 angle_robot_person_msg_;
00069     ros::Publisher person_robot_dist_publisher_;
00070     std_msgs::Float64 person_robot_dist_msg_;
00071         ros::Publisher target_person_position_publisher_;
00072     geometry_msgs::PointStamped target_person_position_msg_;
00073         ros::Publisher robot_position_publisher_;
00074     geometry_msgs::PoseStamped robot_position_msg_;
00075     ros::Publisher force_param_publisher_;
00076     geometry_msgs::PointStamped force_param_msg_;
00077     ros::Publisher trajectories_publisher_;
00078     visualization_msgs::MarkerArray MarkerArray_trajectories_msg_;
00079     ros::Publisher forces_publisher_;
00080     visualization_msgs::MarkerArray MarkerArray_forces_msg_;
00081         ros::Publisher destinations_publisher_;
00082     visualization_msgs::MarkerArray MarkerArray_destinations_msg_;
00083         ros::Publisher predictions_publisher_;
00084     visualization_msgs::MarkerArray MarkerArray_predictions_msg_;
00085         //variables and functions to fill the visualization messages
00086         visualization_msgs::Marker traj_marker_, traj_robot_marker_, robot_marker_;
00087         visualization_msgs::Marker target_marker_;
00088         visualization_msgs::Marker dest_marker_;
00089         visualization_msgs::Marker pred_marker_;
00090         visualization_msgs::Marker text_marker_;
00091         visualization_msgs::Marker force_marker_, force_goal_marker_, force_goal2_marker_, force_int_person_marker_,
00092                         force_int_robot_marker_, force_obstacle_map_marker_, force_obstacle_laser_marker_;
00093         void init_node();
00094         void vis_trajectories();
00095         void clear_force_markers();
00096         void vis_intentionality_prediction();
00097         void vis_destinations();
00098         void vis_predictions();
00099   void growing_density_test();
00100   void initial_params_learning();
00101         
00102     // [subscriber attributes]
00103     ros::Subscriber laser_subscriber_;
00104     CMutex laser_mutex_;
00105     ros::Subscriber dest_subscriber_;
00106     void dest_callback(const geometry_msgs::PoseStamped::ConstPtr& msg);
00107     CMutex dest_mutex_;
00108     ros::Subscriber tracks_subscriber_;
00109     void tracks_callback(const iri_perception_msgs::peopleTrackingArray::ConstPtr& msg);
00110     CMutex tracks_mutex_;
00111         
00112 
00113     // [service attributes]
00114 
00115     // [client attributes]
00116     ros::ServiceClient reset_client_;
00117     std_srvs::Empty reset_srv_;
00118 
00119     // [action server attributes]
00120 
00121     // [action client attributes]
00122 //    actionlib::SimpleActionClient<move_base_msgs::MoveBaseAction> move_base_client_;
00123  //   move_base_msgs::MoveBaseGoal move_base_goal_;
00124   //  void move_baseMakeActionRequest();
00125    // void move_baseDone(const actionlib::SimpleClientGoalState& state,  const move_base_msgs::MoveBaseResultConstPtr& result);
00126    // void move_baseActive();
00127     //void move_baseFeedback(const move_base_msgs::MoveBaseFeedbackConstPtr& feedback);
00128 
00129         Cforce_reactive_robot_companion_learning pred_;
00130         std::string target_frame_, robot_frame_;
00131         tf::TransformListener tf_listener_;
00132         
00133         //for the debugging mode
00134         SpointV_cov robot_desired_position_, target_followed_pose_;
00135         Sforce f1_, f2_, f3_, f4_, f5_, f_;
00136   ros::Time now_;
00137 //      bool move_base_mode_, robot_sim_, using_prediction_, robot_stop_;
00138         bool using_prediction_;
00139         double param_f1_, param_f2_, param_f3_;
00140         std::vector<int> prev_buttons_;
00141 //      bool ready_to_read_laser_; //not finally used??
00142         
00143         int nearest_target_;
00144         string force_map_path_,destination_map_path_;
00145         double laser_radi_;
00146 
00147         //simulation variables
00148         sim_state simulation_state_;
00149         int number_of_virtual_people_,num_experiment_,timer_;
00150         FILE * file_results_out_;
00151         bool results_file_is_open_;
00152         string results_folder_;
00153         double robot_x_ini_,robot_y_ini_;
00154 
00155     //learning mode
00156     learning_mode learning_mode_;
00157 
00158   public:
00165     ForceRobotCompanionLearningAlgNode(void);
00166 
00173     ~ForceRobotCompanionLearningAlgNode(void);
00174 
00175   protected:
00188     void mainNodeThread(void);
00189 
00202     void node_config_update(Config &config, uint32_t level);
00203 
00210     void addNodeDiagnostics(void);
00211 
00212     // [diagnostic functions]
00213     
00214     // [test functions]
00215 };
00216 
00217 #endif


iri_force_robot_companion_learning
Author(s): gferrer
autogenerated on Fri Dec 6 2013 21:22:15