Skip to content
This repository has been archived by the owner on Jul 22, 2021. It is now read-only.

Commit

Permalink
IDs are now part of request and response, not within params/values
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronchongth committed May 6, 2020
1 parent 6d2deb5 commit 3b93e51
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
27 changes: 12 additions & 15 deletions rmf_planning_visualizer/src/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,31 +147,30 @@ auto Server::get_request_type(const server::message_ptr& msg)
{
json j = json::parse(msg_payload);

if (j.size() != 2 || j.count("request") != 1 || j.count("param") != 1)
if (j.size() != 3 ||
j.count("request") != 1 ||
j.count("id") != 1 ||
j.count("param") != 1)
return RequestType::Undefined;

if (j["request"] == "planner_config" &&
j["param"].count("id") == 1 &&
if (j["request"] == "planner_config" &&
j["param"].count("profile_radius") == 1 &&
j["param"].count("linear_velocity") == 1 &&
j["param"].count("linear_acceleration") == 1 &&
j["param"].count("angular_velocity") == 1 &&
j["param"].count("angular_acceleration") == 1 &&
j["param"].count("graph_file_path") == 1)
return RequestType::PlannerConfig;
else if (j["request"] == "start_planning" &&
j["param"].count("id") == 1 &&
else if (j["request"] == "start_planning" &&
j["param"].count("start") == 1 &&
j["param"]["start"].count("x") == 1 &&
j["param"]["start"].count("y") == 1 &&
j["param"]["start"].count("yaw") == 1 &&
j["param"].count("goal") == 1)
return RequestType::StartPlanning;
else if (j["request"] == "step" &&
j["param"].count("id") == 1)
else if (j["request"] == "step")
return RequestType::Step;
else if (j["request"] == "close_planner" &&
j["param"].count("id") == 1)
else if (j["request"] == "close_planner")
return RequestType::ClosePlanner;
else
return RequestType::Undefined;
Expand All @@ -190,8 +189,8 @@ void Server::get_planner_config_response(
{
std::string msg_payload = msg->get_payload();
json j_req = json::parse(msg_payload);
std::string planning_instance_id = j_req["id"];
json j_param = j_req["param"];
std::string planning_instance_id = j_param["id"];

json j_res = _j_res;
j_res["response"] = "planner_config";
Expand Down Expand Up @@ -291,8 +290,8 @@ void Server::get_start_planning_response(

std::string msg_payload = msg->get_payload();
json j_req = json::parse(msg_payload);
std::string planning_instance_id = j_req["id"];
json j_param = j_req["param"];
std::string planning_instance_id = j_param["id"];

// TODO: Allow multiple planning instances, identified by their ID
if (planning_instance_id != _planning_instance->id)
Expand Down Expand Up @@ -354,8 +353,7 @@ void Server::get_step_response(

std::string msg_payload = msg->get_payload();
json j_req = json::parse(msg_payload);
json j_param = j_req["param"];
std::string planning_instance_id = j_param["id"];
std::string planning_instance_id = j_req["id"];

// TODO: Allow multiple planning instances, identified by their ID
if (planning_instance_id != _planning_instance->id)
Expand Down Expand Up @@ -387,8 +385,7 @@ void Server::get_close_planner_response(

std::string msg_payload = msg->get_payload();
json j_req = json::parse(msg_payload);
json j_param = j_req["param"];
std::string planning_instance_id = j_param["id"];
std::string planning_instance_id = j_req["id"];

// TODO: Allow multiple planning instances, identified by their ID
if (planning_instance_id != _planning_instance->id)
Expand Down
26 changes: 15 additions & 11 deletions rmf_planning_visualizer/src/test_server_response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,24 +192,28 @@ int main(int argc, char** argv)
return 1;
}

int step_num = planning_inspector->step_num();
auto planning_state = planning_inspector->get_state();
std::string state_printout =
rmf_visualizer::planning::print_planning_state_response(
planning_state, b1.id(), 0.3);
std::cout << "STEP [" << step_num << "]:" << std::endl;
std::cout << state_printout << std::endl << std::endl;

bool plan_completed = false;
while (!plan_completed)
{
planning_inspector->step();

int step_num = planning_inspector->step_num();
auto planning_state = planning_inspector->get_state();
// planning_state->print();
step_num = planning_inspector->step_num();
planning_state = planning_inspector->get_state();
state_printout =
rmf_visualizer::planning::print_planning_state_response(
planning_state, b1.id(), 0.3);
std::cout << "STEP [" << step_num << "]:" << std::endl;
std::cout << state_printout << std::endl << std::endl;

plan_completed = planning_inspector->plan_completed();
}

auto final_state = planning_inspector->get_state();
std::string printout =
rmf_visualizer::planning::print_planning_state_response(
final_state, b1.id(), 0.3);
std::cout << "HERE COMES THE PRINTOUT:" << std::endl;
std::cout << printout << std::endl;

return 0;
}

0 comments on commit 3b93e51

Please sign in to comment.