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 {
50  robot_builder.SetTerrainParameters(terrain_msg);
51 }
52 
53 static void ParamsCallback (const xpp_msgs::RobotParameters& params_msg)
54 {
55  robot_builder.SetRobotParameters(params_msg);
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 }
void publish(const boost::shared_ptr< M > &message) const
static const std::string robot_state_desired("/xpp/state_des")
int main(int argc, char *argv[])
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void SetTerrainParameters(const xpp_msgs::TerrainInfo &msg)
Additional information that can be used for visualization.
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void SetRobotParameters(const xpp_msgs::RobotParameters &msg)
Provides additional robot info that can be used for visualization.
ROSCPP_DECL void spin(Spinner &spinner)
static void ParamsCallback(const xpp_msgs::RobotParameters &params_msg)
static xpp::RvizRobotBuilder robot_builder
static void StateCallback(const xpp_msgs::RobotStateCartesian &state_msg)
static void TerrainInfoCallback(const xpp_msgs::TerrainInfo &terrain_msg)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
MarkerArray BuildRobotState(const xpp_msgs::RobotStateCartesian &msg) const
Constructs the RVIZ markers from the ROS message.
static ros::Publisher rviz_marker_pub
static const std::string terrain_info("/xpp/terrain_info")
Constructs RVIZ markers that visualize a Cartesian robot state.
static const std::string robot_parameters("/xpp/params")


xpp_vis
Author(s): Alexander W. Winkler
autogenerated on Tue Dec 8 2020 03:10:32