footcoords.h
Go to the documentation of this file.
1 // -*- mode: C++ -*-
2 /*********************************************************************
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2013, Ryohei Ueda and JSK Lab
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/o2r other materials provided
17  * with the distribution.
18  * * Neither the name of the Willow Garage nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *********************************************************************/
35 
36 #ifndef JSK_FOOTSTEP_CONTROLLER_FOOTCOORDS_H_
37 #define JSK_FOOTSTEP_CONTROLLER_FOOTCOORDS_H_
38 #include <Eigen/Geometry>
39 #include <sensor_msgs/Imu.h>
40 #include <geometry_msgs/WrenchStamped.h>
41 #include <tf/transform_listener.h>
47 #include <tf/transform_listener.h>
50 #include <pcl_msgs/ModelCoefficients.h>
51 #include <jsk_footstep_controller/GroundContactState.h>
52 #include <jsk_footstep_controller/FootCoordsLowLevelInfo.h>
53 #include <jsk_footstep_controller/SynchronizedForces.h>
54 #include <std_msgs/Empty.h>
55 #include <nav_msgs/Odometry.h>
56 #include <urdf/model.h>
57 #include <kdl/tree.hpp>
58 #include <kdl/chainjnttojacsolver.hpp>
60 
62 {
63  template <class T>
64  class TimeStampedVector: public std::vector<T>
65  {
66  public:
67  typedef typename std::vector<T>::iterator iterator;
68  void removeBefore(const ros::Time& stamp)
69  {
70  for (iterator it = std::vector<T>::begin();
71  it != std::vector<T>::end();) {
72  if (((*it)->header.stamp - stamp) < ros::Duration(0.0)) {
73  it = this->erase(it);
74  }
75  else {
76  ++it;
77  }
78  }
79  }
80  protected:
81  private:
82  };
83 
84 
86  {
87  public:
89  std_msgs::Header header;
90  double value;
91  ValueStamped(const std_msgs::Header& aheader, double avalue):
92  header(aheader), value(avalue) {
93  }
95  };
96 
97  class Footcoords
98  {
99  public:
101  geometry_msgs::WrenchStamped,
102  geometry_msgs::WrenchStamped,
103  sensor_msgs::JointState,
104  geometry_msgs::PointStamped> SyncPolicy;
106  nav_msgs::Odometry,
107  sensor_msgs::Imu> OdomImuSyncPolicy;
108 
109  Footcoords();
110  virtual ~Footcoords();
111 
113  {
114  LLEG_GROUND, RLEG_GROUND, AIR, BOTH_GROUND
115  };
116 
118  {
119  UNINITIALIZED, INITIALIZING, LLEG_SUPPORT, RLEG_SUPPORT
120  };
121 
122  protected:
123 
124  // methods
125 
126  /*
127  * virtual void filter(const geometry_msgs::WrenchStamped::ConstPtr& lfoot,
128  * const geometry_msgs::WrenchStamped::ConstPtr& rfoot);
129  */
130  virtual void filter(const jsk_footstep_controller::SynchronizedForces::ConstPtr& msg);
131  virtual bool computeMidCoords(const ros::Time& stamp);
132  virtual bool computeMidCoordsFromSingleLeg(const ros::Time& stamp,
133  bool use_left_leg);
134  virtual bool waitForEndEffectorTransformation(const ros::Time& stamp);
135  virtual bool waitForSensorFrameTransformation(const ros::Time& lstamp,
136  const ros::Time& rstamp,
137  const std::string& lsensor_frame,
138  const std::string& rsensor_frame);
139  virtual bool updateGroundTF();
140  virtual void publishTF(const ros::Time& stamp);
141  virtual void publishState(const std::string& state);
142  virtual void updateLegDiagnostics(diagnostic_updater::DiagnosticStatusWrapper &stat);
143  virtual void publishContactState(const ros::Time& stamp);
144  virtual double applyLowPassFilter(double current_val, double prev_val) const;
145  virtual bool allValueLargerThan(TimeStampedVector<ValueStamped::Ptr>& values,
146  double threshold);
147  virtual bool allValueSmallerThan(TimeStampedVector<ValueStamped::Ptr>& values,
148  double threshold);
149  virtual bool resolveForceTf(const geometry_msgs::WrenchStamped& lfoot,
150  const geometry_msgs::WrenchStamped& rfoot,
151  tf::Vector3& lfoot_force, tf::Vector3& rfoot_force);
152  virtual void periodicTimerCallback(const ros::TimerEvent& event);
153  virtual void odomInitTriggerCallback(const std_msgs::Empty& trigger);
154  virtual void floorCoeffsCallback(const pcl_msgs::ModelCoefficients& coeffs);
155  virtual void odomImuCallback(const nav_msgs::Odometry::ConstPtr& odom_msg,
156  const sensor_msgs::Imu::ConstPtr& imu_msg);
157  // This callback is called when robot is put on the ground.
158  // virtual void odomInitCallback(const std_msgs::Empty& odom_init_msg);
159  virtual void synchronizeForces(const geometry_msgs::WrenchStamped::ConstPtr& lfoot,
160  const geometry_msgs::WrenchStamped::ConstPtr& rfoot,
161  const sensor_msgs::JointState::ConstPtr& joint_states,
162  const geometry_msgs::PointStamped::ConstPtr& zmp);
163  virtual void estimateOdometry();
164  virtual void estimateOdometryNaive();
165  virtual void estimateOdometryMainSupportLeg();
166  virtual void estimateOdometryZMPSupportLeg();
167  virtual void updateRobotModel(std::map<std::string, double>& joint_angles);
168  virtual void updateChain(std::map<std::string, double>& joint_angles,
169  KDL::Chain& chain,
170  tf::Pose& output_pose);
171  virtual void estimateVelocity(const ros::Time& stamp, std::map<std::string, double>& joint_angles);
172  virtual void computeVelicity(double dt,
173  std::map<std::string, double>& joint_angles,
174  KDL::Chain& chain,
175  geometry_msgs::Twist& output);
176  virtual float getYaw(const Eigen::Affine3d& pose);
177  virtual void getRollPitch(const Eigen::Affine3d& pose, float& roll, float& pitch);
178  // ros variables
179  boost::mutex mutex_;
180  Eigen::Affine3d odom_pose_;
181  Eigen::Affine3d odom_init_pose_;
184  //ros::Subscriber odom_sub_;
195  std::vector<float> floor_coeffs_;
215  // parameters
216  std::string zmp_frame_id_;
217  std::string output_frame_id_;
218  std::string parent_frame_id_;
219  std::string midcoords_frame_id_;
222  Eigen::Vector3f zmp_;
223  double force_thr_;
225  std::map<std::string, double> prev_joints_;
226  bool use_imu_;
229  std::string lfoot_frame_id_;
230  std::string rfoot_frame_id_;
231  std::string lfoot_sensor_frame_;
232  std::string rfoot_sensor_frame_;
233  std::string root_frame_id_;
234  std::string body_on_odom_frame_;
235  std::string odom_init_frame_id_;
242  double prev_lforce_;
243  double prev_rforce_;
244  double alpha_;
247  private:
248  };
249 }
250 #endif
ros::Subscriber synchronized_forces_sub_
Definition: footcoords.h:188
ValueStamped(const std_msgs::Header &aheader, double avalue)
Definition: footcoords.h:91
tf::Transform locked_midcoords_to_odom_on_ground_
Definition: footcoords.h:240
ros::Publisher pub_odom_init_pose_stamped_
Definition: footcoords.h:212
boost::shared_ptr< ValueStamped > Ptr
Definition: footcoords.h:88
message_filters::Subscriber< geometry_msgs::WrenchStamped > sub_rfoot_force_
Definition: footcoords.h:190
message_filters::Subscriber< geometry_msgs::WrenchStamped > sub_lfoot_force_
Definition: footcoords.h:189
boost::shared_ptr< tf::TransformListener > tf_listener_
Definition: footcoords.h:213
boost::shared_ptr< message_filters::Synchronizer< SyncPolicy > > sync_
Definition: footcoords.h:193
message_filters::Subscriber< sensor_msgs::JointState > sub_joint_states_
Definition: footcoords.h:191
double getYaw(const tf2::Quaternion &q)
ros::Subscriber odom_init_trigger_sub_
Definition: footcoords.h:183
std::map< std::string, double > prev_joints_
Definition: footcoords.h:225
message_filters::sync_policies::ExactTime< nav_msgs::Odometry, sensor_msgs::Imu > OdomImuSyncPolicy
Definition: footcoords.h:107
message_filters::sync_policies::ExactTime< geometry_msgs::WrenchStamped, geometry_msgs::WrenchStamped, sensor_msgs::JointState, geometry_msgs::PointStamped > SyncPolicy
Definition: footcoords.h:104
boost::shared_ptr< message_filters::Synchronizer< OdomImuSyncPolicy > > odom_imu_sync_
Definition: footcoords.h:187
message_filters::Subscriber< sensor_msgs::Imu > imu_sub_
Definition: footcoords.h:186
std::vector< T >::iterator iterator
Definition: footcoords.h:67
message_filters::Subscriber< nav_msgs::Odometry > odom_sub_
Definition: footcoords.h:185
boost::shared_ptr< diagnostic_updater::Updater > diagnostic_updater_
Definition: footcoords.h:241
tf::TransformBroadcaster tf_broadcaster_
Definition: footcoords.h:214
message_filters::Subscriber< geometry_msgs::PointStamped > sub_zmp_
Definition: footcoords.h:192
std::vector< float > floor_coeffs_
Definition: footcoords.h:195
void removeBefore(const ros::Time &stamp)
Definition: footcoords.h:68


jsk_footstep_controller
Author(s):
autogenerated on Fri May 14 2021 02:52:04