pattern_generator.h
Go to the documentation of this file.
00001 //=================================================================================================
00002 // Copyright (c) 2017, Alexander Stumpf, TU Darmstadt
00003 // All rights reserved.
00004 
00005 // Redistribution and use in source and binary forms, with or without
00006 // modification, are permitted provided that the following conditions are met:
00007 //     * Redistributions of source code must retain the above copyright
00008 //       notice, this list of conditions and the following disclaimer.
00009 //     * Redistributions in binary form must reproduce the above copyright
00010 //       notice, this list of conditions and the following disclaimer in the
00011 //       documentation and/or other materials provided with the distribution.
00012 //     * Neither the name of the Simulation, Systems Optimization and Robotics
00013 //       group, TU Darmstadt nor the names of its contributors may be used to
00014 //       endorse or promote products derived from this software without
00015 //       specific prior written permission.
00016 
00017 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00018 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00019 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00020 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
00021 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00022 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00023 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00024 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00026 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027 //=================================================================================================
00028 
00029 #ifndef VIGIR_PATTERN_GENERATOR_H__
00030 #define VIGIR_PATTERN_GENERATOR_H__
00031 
00032 #include <map>
00033 
00034 #include <ros/ros.h>
00035 #include <tf/tf.h>
00036 
00037 #include <actionlib/client/simple_action_client.h>
00038 
00039 #include <geometry_msgs/Pose.h>
00040 #include <geometry_msgs/PoseStamped.h>
00041 #include <geometry_msgs/PoseWithCovarianceStamped.h>
00042 
00043 #include <vigir_footstep_planning_lib/helper.h>
00044 #include <vigir_footstep_planning_msgs/footstep_planning_msgs.h>
00045 
00046 #include <vigir_pattern_generator/joystick_handler.h>
00047 
00048 
00049 
00050 namespace vigir_footstep_planning
00051 {
00052 class PatternGenerator
00053 {
00054 public:
00055   PatternGenerator(ros::NodeHandle& nh);
00056   virtual ~PatternGenerator();
00057 
00058   void reset();
00059   void setParams(const msgs::PatternGeneratorParameters& params);
00060   void setEnabled(bool enabled);
00061   bool isEnabled() const;
00062   bool isSimulationMode() const;
00063 
00064   bool hasSteps() const;
00065   bool hasNewSteps() const;
00066   void getCompleteStepPlan(msgs::StepPlan& step_plan) const;
00067   void getNewestStepPlan(msgs::StepPlan& step_plan) const;
00068   void clearStepPlan();
00069 
00070   bool setNextStartStepIndex(int step_index);
00071   int getNextStartStepIndex() const;
00072 
00073   void update(const ros::TimerEvent& timer);
00074   void updateLastPerformedStepIndex(int last_performed_step_index);
00075   void updateFirstChangeableStepIndex(int first_changeable_step_index);
00076 
00077   // simple pattern generator
00078   msgs::ErrorStatus generatePattern(const msgs::StepPlanRequest& step_plan_request, msgs::StepPlan& step_plan);
00079 
00080   // typedefs
00081   typedef boost::shared_ptr<PatternGenerator> Ptr;
00082   typedef boost::shared_ptr<PatternGenerator> ConstPtr;
00083 
00084 private:
00085   void updateFeetStartPose(uint8_t foot_index, const geometry_msgs::Pose& pose);
00086   void updateFeetStartPose(const msgs::Foot& foot);
00087   void updateFeetStartPose(const msgs::Feet& feet);
00088   void updateFeetStartPose(const msgs::Step& step);
00089   bool updateFeetStartPoseByStepMap(const std::map<unsigned int, msgs::Step>& map, unsigned int step_index);
00090 
00091   void updateFootstepMap(std::map<unsigned int, msgs::Step>& map, const std::vector<msgs::Step>& vec) const;
00092   void mapToVectorIndexed(const std::map<unsigned int, msgs::Step>& map, std::vector<msgs::Step>& vec, unsigned int start_index, unsigned int end_index) const;
00093 
00094   void generateSteps(unsigned int n, bool close_step = false);
00095 
00096   // service clients
00097   ros::ServiceClient generate_feet_pose_client;
00098   ros::ServiceClient step_plan_request_client;
00099   ros::ServiceClient stitch_step_plan_client;
00100 
00101   // action clients
00102   boost::shared_ptr<actionlib::SimpleActionClient<msgs::ExecuteStepPlanAction> > execute_step_plan_ac;
00103 
00104   // handler for joystick input
00105   JoystickHandler::Ptr joystick_handler;
00106   geometry_msgs::Pose joy_d_step;
00107 
00108   // generator params
00109   std::string world_frame_id;
00110   unsigned int number_of_steps_needed;
00111   msgs::PatternGeneratorParameters params;
00112 
00113   // controller feedback
00114   int last_performed_step_index; // last executed step (executing step is current + 1)
00115   int first_changeable_step_index;
00116   int next_step_index_needed;
00117 
00118   // state of pattern generator
00119   msgs::Feet::Ptr start_feet_pose;
00120   unsigned int foot_start_step_index_left;
00121   unsigned int foot_start_step_index_right;
00122   mutable bool has_new_steps;
00123 
00124   // generated step plan
00125   msgs::StepPlan complete_step_plan;
00126   msgs::StepPlan newest_step_plan;
00127   std::map<unsigned int, msgs::Step> step_map;
00128 };
00129 }
00130 
00131 #endif


vigir_pattern_generator
Author(s): Alexander Stumpf
autogenerated on Fri Apr 7 2017 02:59:51