ver3
This commit is contained in:
@@ -31,7 +31,10 @@ private:
|
||||
void jsonToString(std::string data);
|
||||
void StringToJson(std::string data);
|
||||
float heading;
|
||||
global_location leader_position;
|
||||
rapidjson::Document document;
|
||||
json j_data;
|
||||
|
||||
// SUBSCRIBE
|
||||
ros::Subscriber mqtt_data;
|
||||
ros::Subscriber formation_data;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
global_location leader_position;
|
||||
json j_data;
|
||||
int command;
|
||||
|
||||
RequestClass::RequestClass() : node_handle_(""){
|
||||
@@ -131,35 +129,37 @@ void RequestClass::jsonToString(std::string data){
|
||||
}
|
||||
|
||||
void RequestClass::StringToJson(std::string data){
|
||||
|
||||
std::string lat = "",lon = "",alt = "",degree = "";
|
||||
// j_data = json::parse(data);
|
||||
|
||||
std::cout << data << std::endl;
|
||||
document.Parse(data.c_str());
|
||||
|
||||
// document.Parse(data.c_str()); //china's library
|
||||
// leader_position.lat=document["lat"].GetInt();
|
||||
// leader_position.lon=document["lon"].GetInt();
|
||||
// leader_position.alt=document["alt"].GetInt();
|
||||
// heading = document["heading"].GetInt();
|
||||
|
||||
// std::cout << document["lat"].GetInt() << std::endl;
|
||||
// std::cout << document["lon"].GetInt() << std::endl;
|
||||
// std::cout << document["alt"].GetInt() << std::endl;
|
||||
// std::cout << document["heading"].GetInt() << std::endl;
|
||||
|
||||
//********************************************//
|
||||
j_data = json::parse(data); //open source
|
||||
|
||||
// std::string lat = "",lon = "",alt = "",degree = "";
|
||||
// lat = j_data["lat"];
|
||||
// lon = j_data["lon"];
|
||||
// alt = j_data["alt"];
|
||||
// degree = j_data["heading"];
|
||||
|
||||
// leader_position.lat=std::stoi(lat);
|
||||
// leader_position.lon=std::stoi(lon);
|
||||
// leader_position.alt=std::stoi(alt);
|
||||
// heading = std::stoi(degree);
|
||||
|
||||
leader_position.lat=document["lat"].GetInt();
|
||||
leader_position.lon=document["lon"].GetInt();
|
||||
leader_position.alt=document["alt"].GetInt();
|
||||
heading = document["heading"].GetInt();
|
||||
|
||||
|
||||
leader_position.lat=j_data["lat"];
|
||||
leader_position.lon=j_data["lon"];
|
||||
leader_position.alt=j_data["alt"];
|
||||
heading = j_data["heading"];
|
||||
|
||||
//std::cout << "sensor" << sensor->data << std::endl;
|
||||
std::cout << document["lat"].GetInt() << std::endl;
|
||||
std::cout << document["lon"].GetInt() << std::endl;
|
||||
std::cout << document["alt"].GetInt() << std::endl;
|
||||
std::cout << document["heading"].GetInt() << std::endl;
|
||||
// std::cout << leader_position.lat << std::endl;
|
||||
// std::cout << leader_position.lon << std::endl;
|
||||
// std::cout << leader_position.alt << std::endl;
|
||||
// std::cout << heading << std::endl;
|
||||
std::cout << leader_position.lat << std::endl;
|
||||
std::cout << leader_position.lon << std::endl;
|
||||
std::cout << leader_position.alt << std::endl;
|
||||
std::cout << heading << std::endl;
|
||||
}
|
||||
Reference in New Issue
Block a user