urdf_visualizer.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_URDF_VISUALIZER_H_
31 #define XPP_VIS_URDF_VISUALIZER_H_
32 
33 #include <cstdlib>
34 #include <iostream>
35 #include <map>
36 #include <memory>
37 #include <string>
38 #include <vector>
39 
40 #include <ros/ros.h>
42 #include <ros/package.h>
43 #include <urdf/model.h>
44 #include <sensor_msgs/JointState.h>
47 
48 #include <xpp_msgs/RobotStateJoint.h>
49 #include <xpp_states/joints.h>
50 
51 
52 namespace xpp {
53 
60 class UrdfVisualizer {
61 public:
62  using URDFName = std::string;
63  using UrdfnameToJointAngle = std::map<URDFName, double>;
64 
78  UrdfVisualizer(const std::string& urdf_name,
79  const std::vector<URDFName>& joint_names_in_urdf,
80  const URDFName& base_link_in_urdf,
81  const std::string& rviz_fixed_frame,
82  const std::string& state_topic,
83  const std::string& tf_prefix = "");
84  virtual ~UrdfVisualizer() = default;
85 
86 private:
89  std::shared_ptr<robot_state_publisher::RobotStatePublisher> robot_publisher;
90 
91  void StateCallback(const xpp_msgs::RobotStateJoint& msg);
92 
93  UrdfnameToJointAngle AssignAngleToURDFJointName(const sensor_msgs::JointState &msg) const;
94  geometry_msgs::TransformStamped GetBaseFromRos(const ::ros::Time& stamp,
95  const geometry_msgs::Pose &msg) const;
96 
97  std::vector<URDFName> joint_names_in_urdf_;
99 
100  std::string state_msg_name_;
101  std::string rviz_fixed_frame_;
102  std::string tf_prefix_;
103 };
104 
105 } // namespace xpp
106 
107 #endif /* XPP_VIS_URDF_VISUALIZER_H_ */
joints.h
xpp::UrdfVisualizer::joint_names_in_urdf_
std::vector< URDFName > joint_names_in_urdf_
Definition: urdf_visualizer.h:151
ros.h
xpp::UrdfVisualizer::state_sub_des_
ros::Subscriber state_sub_des_
Definition: urdf_visualizer.h:141
xpp::UrdfVisualizer::rviz_fixed_frame_
std::string rviz_fixed_frame_
Definition: urdf_visualizer.h:155
transform_broadcaster.h
robot_state_publisher.h
xpp::UrdfVisualizer::base_joint_in_urdf_
URDFName base_joint_in_urdf_
Definition: urdf_visualizer.h:152
xpp::UrdfVisualizer::UrdfnameToJointAngle
std::map< URDFName, double > UrdfnameToJointAngle
Definition: urdf_visualizer.h:117
xpp::UrdfVisualizer::state_msg_name_
std::string state_msg_name_
Definition: urdf_visualizer.h:154
xpp::UrdfVisualizer::robot_publisher
std::shared_ptr< robot_state_publisher::RobotStatePublisher > robot_publisher
Definition: urdf_visualizer.h:143
xpp::UrdfVisualizer::UrdfVisualizer
UrdfVisualizer(const std::string &urdf_name, const std::vector< URDFName > &joint_names_in_urdf, const URDFName &base_link_in_urdf, const std::string &rviz_fixed_frame, const std::string &state_topic, const std::string &tf_prefix="")
Constructs the visualizer for a specific URDF urdf_name.
Definition: urdf_visualizer.cc:61
tf::TransformBroadcaster
model.h
xpp::UrdfVisualizer::StateCallback
void StateCallback(const xpp_msgs::RobotStateJoint &msg)
Definition: urdf_visualizer.cc:94
xpp
package.h
kdl_parser.hpp
xpp::UrdfVisualizer::GetBaseFromRos
geometry_msgs::TransformStamped GetBaseFromRos(const ::ros::Time &stamp, const geometry_msgs::Pose &msg) const
Definition: urdf_visualizer.cc:116
xpp::UrdfVisualizer::~UrdfVisualizer
virtual ~UrdfVisualizer()=default
xpp::UrdfVisualizer::tf_prefix_
std::string tf_prefix_
Definition: urdf_visualizer.h:156
xpp::UrdfVisualizer::tf_broadcaster_
tf::TransformBroadcaster tf_broadcaster_
Definition: urdf_visualizer.h:142
xpp::UrdfVisualizer::AssignAngleToURDFJointName
UrdfnameToJointAngle AssignAngleToURDFJointName(const sensor_msgs::JointState &msg) const
Definition: urdf_visualizer.cc:105
xpp::UrdfVisualizer::URDFName
std::string URDFName
Definition: urdf_visualizer.h:116
ros::Subscriber


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