From: Jiri Vlasak Date: Thu, 23 Mar 2023 13:22:53 +0000 (+0100) Subject: Ouput cost in json only if path found X-Git-Url: https://rtime.felk.cvut.cz/gitweb/hubacji1/iamcar2.git/commitdiff_plain/41afde61c4a85d0eb68521a232c43a012330b4aa Ouput cost in json only if path found --- diff --git a/rrts/src/rrts.cc b/rrts/src/rrts.cc index 5a14217..1520d61 100644 --- a/rrts/src/rrts.cc +++ b/rrts/src/rrts.cc @@ -492,7 +492,9 @@ RRTS::json(void) const jvo["path"][i - 1][3] = jvo["path"][i - 2][3]; jvo["path"][i - 1][4] = jvo["path"][i - 2][4]; // -- - jvo["costs"][j] = this->_path.back()->cc(); + if (this->_path.size() > 0) { + jvo["costs"][j] = this->_path.back()->cc(); + } jvo["goal_cc"] = this->_goal.cc(); // TODO remove, use the following jvo["cost"] = this->path_cost(); jvo["time"] = this->scnt();