rviz_robot_builder.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 Copyright (c) 2017, Alexander W. Winkler. All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008   list of conditions and the following disclaimer.
00009 
00010 * Redistributions in binary form must reproduce the above copyright notice,
00011   this list of conditions and the following disclaimer in the documentation
00012   and/or other materials provided with the distribution.
00013 
00014 * Neither the name of the copyright holder nor the names of its
00015   contributors may be used to endorse or promote products derived from
00016   this software without specific prior written permission.
00017 
00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00021 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00022 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00023 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00024 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00025 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00026 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00027 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00028 ******************************************************************************/
00029 
00030 #ifndef XPP_VIS_RVIZ_ROBOT_BUILDER_H_
00031 #define XPP_VIS_RVIZ_ROBOT_BUILDER_H_
00032 
00033 #include <string>
00034 #include <vector>
00035 
00036 #include <visualization_msgs/MarkerArray.h>
00037 
00038 #include <xpp_msgs/RobotParameters.h>
00039 #include <xpp_msgs/RobotStateCartesian.h>
00040 #include <xpp_msgs/TerrainInfo.h>
00041 
00042 #include <xpp_states/state.h>
00043 #include <xpp_states/robot_state_cartesian.h>
00044 
00045 
00046 namespace xpp {
00047 
00056 class RvizRobotBuilder {
00057 public:
00058   using Marker          = visualization_msgs::Marker;
00059   using MarkerVec       = std::vector<Marker>;
00060   using MarkerArray     = visualization_msgs::MarkerArray;
00061 
00062   using ContactState    = EndeffectorsContact;
00063   using EEPos           = EndeffectorsPos;
00064   using EEForces        = Endeffectors<Vector3d>;
00065   using TerrainNormals  = Endeffectors<Vector3d>;
00066   using RobotState      = RobotStateCartesian;
00067 
00068 public:
00072   RvizRobotBuilder();
00073   virtual ~RvizRobotBuilder () = default;
00074 
00080   MarkerArray BuildRobotState(const xpp_msgs::RobotStateCartesian& msg) const;
00081 
00090   void SetRobotParameters(const xpp_msgs::RobotParameters& msg);
00091 
00100   void SetTerrainParameters(const xpp_msgs::TerrainInfo& msg);
00101 
00102 private:
00103   // various modular functions that are stitched together to generate the
00104   // robot state.
00105   // pos_W = position expressed in world frame
00106   // f_W   = forces expressed in world frame.
00107   // c     = which leg is currently in contact with the environment.
00108   MarkerVec CreateEEPositions(const EEPos& pos_W,
00109                               const ContactState& c) const;
00110   MarkerVec CreateEEForces(const EEForces& f_W,
00111                            const EEPos& pos_W,
00112                            const ContactState& c) const;
00113   MarkerVec CreateFrictionCones(const EEPos& pos_W,
00114                                 const ContactState& c) const;
00115   MarkerVec CreateSupportArea(const ContactState& c,
00116                               const EEPos& pos_W) const;
00117   MarkerVec CreateRangeOfMotion(const State3d& base) const;
00118   Marker    CreateGravityForce (const Vector3d& base_pos) const;
00119   Marker    CreateBasePose(const Vector3d& pos,
00120                            Eigen::Quaterniond ori,
00121                            const ContactState& c) const;
00122   Marker    CreateCopPos(const EEForces& f_W,
00123                          const EEPos& pos_W) const;
00124   Marker    CreatePendulum(const Vector3d& base_pos,
00125                            const EEForces& f_W,
00126                            const EEPos& pos_W) const;
00127   Marker    CreateFrictionCone(const Vector3d& pos_W,
00128                                const Vector3d& terrain_normal,
00129                                double friction_coeff) const;
00130   Marker    CreateForceArrow(const Vector3d& f,
00131                              const Vector3d& pos) const;
00132   Marker    CreateSphere(const Vector3d& pos,
00133                          double diameter = 0.03) const;
00134   Marker    CreateBox(const Vector3d& pos, Eigen::Quaterniond ori,
00135                       const Vector3d& edge_length) const;
00136 
00137   xpp_msgs::RobotParameters params_msg_;
00138   xpp_msgs::TerrainInfo terrain_msg_;
00139 
00140   const std::string frame_id_ = "world";
00141 
00147   void FillWithInvisible(int max_size, MarkerVec& vec) const;
00148   const static int max_ee_ = 10; // maximum number of endeffectors
00149 };
00150 
00151 } /* namespace xpp */
00152 
00153 #endif /* XPP_VIS_RVIZ_ROBOT_BUILDER_H_ */


xpp_vis
Author(s): Alexander W. Winkler
autogenerated on Fri Apr 5 2019 02:55:52