]> rtime.felk.cvut.cz Git - hubacji1/iamcar2.git/commitdiff
Ouput cost in json only if path found
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Thu, 23 Mar 2023 13:22:53 +0000 (14:22 +0100)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Thu, 23 Mar 2023 14:38:50 +0000 (15:38 +0100)
rrts/src/rrts.cc

index 5a142174de1babc904991b1b15d0b680cd29e60f..1520d6166fd90809e027bea7292d1485f6cebb79 100644 (file)
@@ -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();