rviz_marker_node.cc
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 #include <ros/ros.h>
31 
32 #include <xpp_msgs/topic_names.h>
33 #include <xpp_msgs/TerrainInfo.h>
34 
35 #include <xpp_states/convert.h>
37 
38 
41 
42 static void StateCallback (const xpp_msgs::RobotStateCartesian& state_msg)
43 {
44  auto rviz_marker_msg = robot_builder.BuildRobotState(state_msg);
45  rviz_marker_pub.publish(rviz_marker_msg);
46 }
47 
48 static void TerrainInfoCallback (const xpp_msgs::TerrainInfo& terrain_msg)
49 {
51 }
52 
53 static void ParamsCallback (const xpp_msgs::RobotParameters& params_msg)
54 {
56 }
57 
58 int main(int argc, char *argv[])
59 {
60  using namespace ros;
61 
62  init(argc, argv, "rviz_marker_visualizer");
63 
64  NodeHandle n;
65 
66  Subscriber parameters_sub;
67  parameters_sub = n.subscribe(xpp_msgs::robot_parameters, 1, ParamsCallback);
68 
69  Subscriber state_sub_curr, state_sub_des, terrain_info_sub;
71  terrain_info_sub = n.subscribe(xpp_msgs::terrain_info, 1, TerrainInfoCallback);
72 
73  rviz_marker_pub = n.advertise<visualization_msgs::MarkerArray>("xpp/rviz_markers", 1);
74 
75  spin();
76 
77  return 1;
78 }
xpp::RvizRobotBuilder
Constructs RVIZ markers that visualize a Cartesian robot state.
Definition: rviz_robot_builder.h:83
ros::Publisher
xpp_msgs::terrain_info
static const std::string terrain_info("/xpp/terrain_info")
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
xpp::RvizRobotBuilder::SetTerrainParameters
void SetTerrainParameters(const xpp_msgs::TerrainInfo &msg)
Additional information that can be used for visualization.
Definition: rviz_robot_builder.cc:76
ros
main
int main(int argc, char *argv[])
Definition: rviz_marker_node.cc:58
ros.h
rviz_robot_builder.h
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
ros::Publisher::publish
void publish(const boost::shared_ptr< M > &message) const
ros::NodeHandle::advertise
Publisher advertise(AdvertiseOptions &ops)
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
ParamsCallback
static void ParamsCallback(const xpp_msgs::RobotParameters &params_msg)
Definition: rviz_marker_node.cc:53
robot_builder
static xpp::RvizRobotBuilder robot_builder
Definition: rviz_marker_node.cc:40
StateCallback
static void StateCallback(const xpp_msgs::RobotStateCartesian &state_msg)
Definition: rviz_marker_node.cc:42
xpp_msgs::robot_state_desired
static const std::string robot_state_desired("/xpp/state_des")
ros::NodeHandle::subscribe
Subscriber subscribe(const std::string &topic, uint32_t queue_size, const boost::function< void(C)> &callback, const VoidConstPtr &tracked_object=VoidConstPtr(), const TransportHints &transport_hints=TransportHints())
ros::NodeHandle
TerrainInfoCallback
static void TerrainInfoCallback(const xpp_msgs::TerrainInfo &terrain_msg)
Definition: rviz_marker_node.cc:48
xpp_msgs::robot_parameters
static const std::string robot_parameters("/xpp/params")
rviz_marker_pub
static ros::Publisher rviz_marker_pub
Definition: rviz_marker_node.cc:39
ros::spin
ROSCPP_DECL void spin()
convert.h
topic_names.h
ros::Subscriber


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