goal_pose_publisher.cc
Go to the documentation of this file.
1 /******************************************************************************
2 Copyright (c) 2018, 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 #include <geometry_msgs/PoseStamped.h>
32 
34 #include <xpp_states/convert.h>
35 
36 #include <towr_ros/TowrCommand.h> // listen to goal state
37 #include <towr_ros/topic_names.h>
38 
39 
40 namespace towr {
41 
43 
44 void UserCommandCallback(const towr_ros::TowrCommand& msg_in)
45 {
46  // get which terrain
47  auto terrain_id = static_cast<HeightMap::TerrainID>(msg_in.terrain);
48  auto terrain_ = HeightMap::MakeTerrain(terrain_id);
49 
50  geometry_msgs::PoseStamped goal_msg;
51  goal_msg.header.frame_id = "world";
52 
53  // visualize goal z state on terrain.
54  double x = msg_in.goal_lin.pos.x;
55  double y = msg_in.goal_lin.pos.y;
56  goal_msg.pose.position.x = x;
57  goal_msg.pose.position.y = y;
58  goal_msg.pose.position.z = terrain_->GetHeight(x, y);
59 
60  // orientation according to message
61  Eigen::Quaterniond q = xpp::GetQuaternionFromEulerZYX(msg_in.goal_ang.pos.z,
62  msg_in.goal_ang.pos.y,
63  msg_in.goal_ang.pos.x);
64  goal_msg.pose.orientation = xpp::Convert::ToRos(q);
65  rviz_pub.publish(goal_msg);
66 }
67 
68 } // namespace towr
69 
70 int main(int argc, char *argv[])
71 {
72  ros::init(argc, argv, "goal_pose_publisher");
73 
75 
76  ros::Subscriber goal_sub;
78  towr::rviz_pub = n.advertise<geometry_msgs::PoseStamped>("xpp/goal", 1);
79 
80  ros::spin();
81 
82  return 1;
83 }
static xpp_msgs::StateLin3d ToRos(const StateLin3d &xpp)
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void UserCommandCallback(const towr_ros::TowrCommand &msg_in)
static HeightMap::Ptr MakeTerrain(TerrainID type)
TFSIMD_FORCE_INLINE const tfScalar & y() const
static Quaterniond GetQuaternionFromEulerZYX(double yaw, double pitch, double roll)
ROSCPP_DECL void spin(Spinner &spinner)
TFSIMD_FORCE_INLINE const tfScalar & x() const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
static ros::Publisher rviz_pub
int main(int argc, char *argv[])
static const std::string user_command("/towr/user_command")


towr_ros
Author(s): Alexander W. Winkler
autogenerated on Fri Apr 2 2021 02:14:21