set_datum.cpp
Go to the documentation of this file.
1 
7 #include "ros/ros.h"
8 #include <geographic_msgs/GeoPose.h>
9 #include <robot_localization/SetDatum.h>
10 #include <tf/transform_datatypes.h>
11 #include <math.h>
12 #include <GeographicLib/GeoCoords.hpp>
13 
14 
15 using namespace GeographicLib;
16 
21 int main(int argc, char **argv)
22 {
23  ros::init(argc, argv, "set_datum_client");
25  ros::ServiceClient client = n.serviceClient<robot_localization::SetDatum>("datum");
26  robot_localization::SetDatum srv;
27 
28  double latitude0_param, longitude0_param, altitude0_param, convergence0_param;
29 
30  // Get Params of ENU origin
31  if (ros::param::has("latitude0_deg") && ros::param::has("longitude0_deg") && ros::param::has("altitude0") )
32  {
33  ros::param::get("latitude0_deg", latitude0_param);
34  ros::param::get("longitude0_deg", longitude0_param);
35  ros::param::get("altitude0", altitude0_param);
36  ROS_INFO("Using params from .yaml ");
37  ROS_INFO("latitude0_deg [%f] longitude0_deg [%f] altitude0 [%f]", latitude0_param, longitude0_param, altitude0_param);
38  }
39 
40  // Create geo_pose message
41  geographic_msgs::GeoPose geo_pose;
42  geo_pose.position.latitude = latitude0_param;
43  geo_pose.position.longitude = longitude0_param;
44  geo_pose.position.altitude = altitude0_param;
45  // Find convergence value from location
46  GeoCoords conversion_data(latitude0_param, longitude0_param);
47  float convergence_radians = conversion_data.Convergence() * M_PI/180.0;
48  geo_pose.orientation = tf::createQuaternionMsgFromYaw( convergence_radians ); // Create this quaternion from yaw (in radians)
49  ROS_INFO("convergence [%f] ", convergence_radians);
50 
51  // Call service
52  srv.request.geo_pose = geo_pose;
53  if (client.call(srv))
54  {
55  }
56  else
57  {
58  ROS_ERROR("Failed to call datum service");
59  return 1;
60  }
61 
62  return 0;
63 }
64 
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
int main(int argc, char **argv)
Client Node. Takes localization parameters to set orogin of map.
Definition: set_datum.cpp:21
#define M_PI
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool call(MReq &req, MRes &res)
ROSCPP_DECL bool get(const std::string &key, std::string &s)
#define ROS_INFO(...)
ROSCPP_DECL bool has(const std::string &key)
static geometry_msgs::Quaternion createQuaternionMsgFromYaw(double yaw)
#define ROS_ERROR(...)


earth_rover_localization
Author(s):
autogenerated on Wed Apr 28 2021 02:15:34