rviz_robot_builder.h
Go to the documentation of this file.
1 /******************************************************************************
2 Copyright (c) 2017, Alexander W. Winkler. All rights reserved.
3 
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6 
7 * Redistributions of source code must retain the above copyright notice, this
8  list of conditions and the following disclaimer.
9 
10 * Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation
12  and/or other materials provided with the distribution.
13 
14 * Neither the name of the copyright holder nor the names of its
15  contributors may be used to endorse or promote products derived from
16  this software without specific prior written permission.
17 
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 ******************************************************************************/
29 
30 #ifndef XPP_VIS_RVIZ_ROBOT_BUILDER_H_
31 #define XPP_VIS_RVIZ_ROBOT_BUILDER_H_
32 
33 #include <string>
34 #include <vector>
35 
36 #include <visualization_msgs/MarkerArray.h>
37 
38 #include <xpp_msgs/RobotParameters.h>
39 #include <xpp_msgs/RobotStateCartesian.h>
40 #include <xpp_msgs/TerrainInfo.h>
41 
42 #include <xpp_states/state.h>
44 
45 
46 namespace xpp {
47 
56 class RvizRobotBuilder {
57 public:
58  using Marker = visualization_msgs::Marker;
59  using MarkerVec = std::vector<Marker>;
60  using MarkerArray = visualization_msgs::MarkerArray;
61 
62  using ContactState = EndeffectorsContact;
63  using EEPos = EndeffectorsPos;
66  using RobotState = RobotStateCartesian;
67 
68 public:
73  virtual ~RvizRobotBuilder () = default;
74 
80  MarkerArray BuildRobotState(const xpp_msgs::RobotStateCartesian& msg) const;
81 
90  void SetRobotParameters(const xpp_msgs::RobotParameters& msg);
91 
100  void SetTerrainParameters(const xpp_msgs::TerrainInfo& msg);
101 
102 private:
103  // various modular functions that are stitched together to generate the
104  // robot state.
105  // pos_W = position expressed in world frame
106  // f_W = forces expressed in world frame.
107  // c = which leg is currently in contact with the environment.
108  MarkerVec CreateEEPositions(const EEPos& pos_W,
109  const ContactState& c) const;
110  MarkerVec CreateEEForces(const EEForces& f_W,
111  const EEPos& pos_W,
112  const ContactState& c) const;
114  const ContactState& c) const;
116  const EEPos& pos_W) const;
118  Marker CreateGravityForce (const Vector3d& base_pos) const;
120  Eigen::Quaterniond ori,
121  const ContactState& c) const;
122  Marker CreateCopPos(const EEForces& f_W,
123  const EEPos& pos_W) const;
124  Marker CreatePendulum(const Vector3d& base_pos,
125  const EEForces& f_W,
126  const EEPos& pos_W) const;
127  Marker CreateFrictionCone(const Vector3d& pos_W,
128  const Vector3d& terrain_normal,
129  double friction_coeff) const;
131  const Vector3d& pos) const;
132  Marker CreateSphere(const Vector3d& pos,
133  double diameter = 0.03) const;
134  Marker CreateBox(const Vector3d& pos, Eigen::Quaterniond ori,
135  const Vector3d& edge_length) const;
136 
137  xpp_msgs::RobotParameters params_msg_;
138  xpp_msgs::TerrainInfo terrain_msg_;
139 
140  const std::string frame_id_ = "world";
141 
147  void FillWithInvisible(int max_size, MarkerVec& vec) const;
148  const static int max_ee_ = 10; // maximum number of endeffectors
149 };
150 
151 } /* namespace xpp */
152 
153 #endif /* XPP_VIS_RVIZ_ROBOT_BUILDER_H_ */
state.h
xpp::RvizRobotBuilder::CreateEEPositions
MarkerVec CreateEEPositions(const EEPos &pos_W, const ContactState &c) const
Definition: rviz_robot_builder.cc:140
xpp::RvizRobotBuilder::CreateFrictionCones
MarkerVec CreateFrictionCones(const EEPos &pos_W, const ContactState &c) const
Definition: rviz_robot_builder.cc:190
xpp::State3d
xpp::EndeffectorsContact
xpp::RvizRobotBuilder::params_msg_
xpp_msgs::RobotParameters params_msg_
Definition: rviz_robot_builder.h:191
xpp::RvizRobotBuilder::FillWithInvisible
void FillWithInvisible(int max_size, MarkerVec &vec) const
Definition: rviz_robot_builder.cc:82
xpp::RvizRobotBuilder::SetTerrainParameters
void SetTerrainParameters(const xpp_msgs::TerrainInfo &msg)
Additional information that can be used for visualization.
Definition: rviz_robot_builder.cc:76
xpp::RvizRobotBuilder::max_ee_
const static int max_ee_
Definition: rviz_robot_builder.h:202
xpp::RvizRobotBuilder::CreateBasePose
Marker CreateBasePose(const Vector3d &pos, Eigen::Quaterniond ori, const ContactState &c) const
Definition: rviz_robot_builder.cc:243
xpp::RvizRobotBuilder::ContactState
EndeffectorsContact ContactState
Definition: rviz_robot_builder.h:116
xpp::RvizRobotBuilder::SetRobotParameters
void SetRobotParameters(const xpp_msgs::RobotParameters &msg)
Provides additional robot info that can be used for visualization.
Definition: rviz_robot_builder.cc:70
xpp::RvizRobotBuilder::BuildRobotState
MarkerArray BuildRobotState(const xpp_msgs::RobotStateCartesian &msg) const
Constructs the RVIZ markers from the ROS message.
Definition: rviz_robot_builder.cc:90
xpp::RvizRobotBuilder::CreateRangeOfMotion
MarkerVec CreateRangeOfMotion(const State3d &base) const
Definition: rviz_robot_builder.cc:317
xpp::RvizRobotBuilder::terrain_msg_
xpp_msgs::TerrainInfo terrain_msg_
Definition: rviz_robot_builder.h:192
xpp::RvizRobotBuilder::CreateFrictionCone
Marker CreateFrictionCone(const Vector3d &pos_W, const Vector3d &terrain_normal, double friction_coeff) const
Definition: rviz_robot_builder.cc:219
Endeffectors< Vector3d >
xpp::RvizRobotBuilder::~RvizRobotBuilder
virtual ~RvizRobotBuilder()=default
xpp
xpp::RvizRobotBuilder::CreatePendulum
Marker CreatePendulum(const Vector3d &base_pos, const EEForces &f_W, const EEPos &pos_W) const
Definition: rviz_robot_builder.cc:289
xpp::RvizRobotBuilder::CreateCopPos
Marker CreateCopPos(const EEForces &f_W, const EEPos &pos_W) const
Definition: rviz_robot_builder.cc:262
xpp::RvizRobotBuilder::CreateEEForces
MarkerVec CreateEEForces(const EEForces &f_W, const EEPos &pos_W, const ContactState &c) const
Definition: rviz_robot_builder.cc:169
xpp::RvizRobotBuilder::CreateBox
Marker CreateBox(const Vector3d &pos, Eigen::Quaterniond ori, const Vector3d &edge_length) const
Definition: rviz_robot_builder.cc:338
xpp::RvizRobotBuilder::EEPos
EndeffectorsPos EEPos
Definition: rviz_robot_builder.h:117
xpp::RvizRobotBuilder::EEForces
Endeffectors< Vector3d > EEForces
Definition: rviz_robot_builder.h:118
xpp::RvizRobotBuilder::CreateForceArrow
Marker CreateForceArrow(const Vector3d &f, const Vector3d &pos) const
Definition: rviz_robot_builder.cc:366
xpp::RvizRobotBuilder::CreateGravityForce
Marker CreateGravityForce(const Vector3d &base_pos) const
Definition: rviz_robot_builder.cc:157
xpp::RvizRobotBuilder::frame_id_
const std::string frame_id_
Definition: rviz_robot_builder.h:194
xpp::RvizRobotBuilder::MarkerVec
std::vector< Marker > MarkerVec
Definition: rviz_robot_builder.h:113
xpp::EndeffectorsPos
Endeffectors< Eigen::Vector3d > EndeffectorsPos
xpp::RvizRobotBuilder::TerrainNormals
Endeffectors< Vector3d > TerrainNormals
Definition: rviz_robot_builder.h:119
xpp::RvizRobotBuilder::CreateSphere
Marker CreateSphere(const Vector3d &pos, double diameter=0.03) const
Definition: rviz_robot_builder.cc:352
xpp::RvizRobotBuilder::MarkerArray
visualization_msgs::MarkerArray MarkerArray
Definition: rviz_robot_builder.h:114
xpp::RvizRobotBuilder::RvizRobotBuilder
RvizRobotBuilder()
Builds an uninitialized visualizer.
Definition: rviz_robot_builder.cc:64
xpp::RvizRobotBuilder::RobotState
RobotStateCartesian RobotState
Definition: rviz_robot_builder.h:120
xpp::RvizRobotBuilder::CreateSupportArea
MarkerVec CreateSupportArea(const ContactState &c, const EEPos &pos_W) const
Definition: rviz_robot_builder.cc:388
robot_state_cartesian.h
xpp::Vector3d
Eigen::Vector3d Vector3d
xpp::RvizRobotBuilder::Marker
visualization_msgs::Marker Marker
Definition: rviz_robot_builder.h:112


xpp_vis
Author(s): Alexander W. Winkler
autogenerated on Wed Mar 2 2022 01:14:16