]> rtime.felk.cvut.cz Git - hubacji1/iamcar2.git/blob - src/test2.cc
Add necessary input check
[hubacji1/iamcar2.git] / src / test2.cc
1 #include <chrono>
2 #include <iostream>
3 #include <jsoncpp/json/json.h>
4
5 #include "rrts.h"
6
7 std::chrono::high_resolution_clock::time_point TSTART_;
8 std::chrono::high_resolution_clock::time_point TEND_;
9 inline void TSTART() { TSTART_ = std::chrono::high_resolution_clock::now(); }
10 inline void TEND() { TEND_ = std::chrono::high_resolution_clock::now(); }
11 inline double TDIFF()
12 {
13         std::chrono::duration<double> DT_;
14         DT_ = std::chrono::duration_cast<std::chrono::duration<double>>(
15                 TEND_ - TSTART_
16         );
17         return DT_.count();
18 }
19 inline void TPRINT(const char *what)
20 {
21         std::cerr << what << ": " << TDIFF() << std::endl;
22 }
23
24 int main()
25 {
26         Json::Value jvi; // JSON input
27         Json::Value jvo; // JSON output
28         std::cin >> jvi;
29
30         if (jvi["init"] == Json::nullValue) {
31                 std::cerr << "I need `init` in JSON input scenario";
32                 std::cerr << std::endl;
33                 return 1;
34         }
35
36         if (jvi["goal"] == Json::nullValue) {
37                 std::cerr << "I need `goal` in JSON input scenario";
38                 std::cerr << std::endl;
39                 return 1;
40         }
41
42         if (jvi["goals"] == Json::nullValue) {
43                 std::cerr << "I need `goals` in JSON input scenario";
44                 std::cerr << std::endl;
45                 return 1;
46         }
47
48         if (jvi["obst"] == Json::nullValue) {
49                 std::cerr << "I need `obst` in JSON input scenario";
50                 std::cerr << std::endl;
51                 return 1;
52         }
53
54         std::cout << jvo << std::endl;
55         return 0;
56 }