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 
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_ */
void StateCallback(const xpp_msgs::RobotStateJoint &msg)
tf::TransformBroadcaster tf_broadcaster_
UrdfnameToJointAngle AssignAngleToURDFJointName(const sensor_msgs::JointState &msg) const
virtual ~UrdfVisualizer()=default
std::map< URDFName, double > UrdfnameToJointAngle
std::shared_ptr< robot_state_publisher::RobotStatePublisher > robot_publisher
std::vector< URDFName > joint_names_in_urdf_
std::string rviz_fixed_frame_
std::string state_msg_name_
Publishes RVIZ transforms used to visualize a robot&#39;s URDF.
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.
URDFName base_joint_in_urdf_
geometry_msgs::TransformStamped GetBaseFromRos(const ::ros::Time &stamp, const geometry_msgs::Pose &msg) const
ros::Subscriber state_sub_des_


xpp_vis
Author(s): Alexander W. Winkler
autogenerated on Tue Mar 1 2022 00:07:16