1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
| #pragma once #include "../src/main.h" #include "json.hpp" #include <cmath> #include <fstream> #include <iostream>
using namespace std;
class ValueConfig { private:
public: struct Params { int out_count = 10;
int short_count = 3;
int slow_count = 30;
int fast_count = 30;
bool speed_debug = false; int speed_bridge = 20; int speed_danger = 10; int speed_parking = 10; int speed_racing = 20; int speed_rescue = 10;
int speed_normal = 38; int speed_fast = 38; int speed_slow = 30; int speed_slowest = speed_slow - 15; int speed_add = 40;
int speed_circle_begin = 26; int speed_circle_min = 25;
int speed_circle_runningl_s = speed_circle_min; int speed_circle_runningl_m = speed_circle_min + 2; int speed_circle_runningl_l = speed_circle_min + 4;
int speed_circle_runningr_s = speed_circle_min; int speed_circle_runningr_m = speed_circle_min + 2; int speed_circle_runningr_l = speed_circle_min + 4;
int bias_speed_limit = 150;
int LR_num1 = 8; int LR_num2 = 16; int LR_num3 = 24;
int RR_num1 = 8; int RR_num2 = 16; int RR_num3 = 24;
int LR_F_num1 = 24; int LR_F_num2 = 34; int LR_F_num3 = 44; int RR_F_num1 = 24; int RR_F_num2 = 34; int RR_F_num3 = 44;
double aim_distance = 0.62; double servo_pid_P1 = 1.7; double servo_pid_P2 = 0.1; double servo_pid_f = 0.1; double servo_pid_D = 0; double servo_pid_k1 = 2.25; double servo_pid_k2 = 1.34; double servo_pid_k3 = 3;
bool ai_debug = false; bool bi_debug = false; bool track_debug = false; bool nts_debug = false; bool saveImage = false; float disGarageEntry = 0.7;
float cone_score = 0.6; float bomb_score = 0.6; float block_score = 0.6; float bridge_score = 0.6; float crosswalk_score = 0.6; float people_score = 0.6; float car_score = 0.75;
char BLOCK_POI = 'L';
float L_MID_L = 154; float L_MID_R = 179; float L_BLOCK_MID_L = 158; float L_BLOCK_MID_R = 166; int L_BOMB_Y_TOP = 15; int L_CONE_Y_TOP = 67; int L_CONE_Y_DOWN = 207;
float R_MID_L = 150; float R_MID_R = 170.1; float R_BLOCK_MID_L = 158; float R_BLOCK_MID_R = 166; int R_BOMB_Y_TOP = 15; int R_CONE_Y_TOP = 67; int R_CONE_Y_DOWN = 207;
bool it_AI = true; bool it_RESCUE = true; bool it_RACING = true; bool it_DANGER = true; bool it_BRIDGE = true;
NLOHMANN_DEFINE_TYPE_INTRUSIVE( Params, out_count, short_count, slow_count,fast_count, speed_debug, speed_bridge, speed_danger, speed_parking, speed_racing, speed_rescue, speed_normal, speed_fast, speed_slow, speed_slowest, speed_add, speed_circle_begin, speed_circle_min, speed_circle_runningl_s, speed_circle_runningl_m, speed_circle_runningl_l, speed_circle_runningr_s, speed_circle_runningr_m, speed_circle_runningr_l, bias_speed_limit, aim_distance, servo_pid_P1, servo_pid_P2, servo_pid_f, servo_pid_D, ai_debug, bi_debug, track_debug, nts_debug, saveImage, disGarageEntry, cone_score,bomb_score,block_score,bridge_score,crosswalk_score,people_score,car_score, BLOCK_POI, L_MID_L, L_MID_R, L_BLOCK_MID_L, L_BLOCK_MID_R, L_BOMB_Y_TOP, L_CONE_Y_TOP, L_CONE_Y_DOWN, R_MID_L, R_MID_R, R_BLOCK_MID_L, R_BLOCK_MID_R, R_BOMB_Y_TOP, R_CONE_Y_TOP, R_CONE_Y_DOWN, it_AI, it_RESCUE, it_RACING, it_DANGER, it_BRIDGE); };
Params params;
ValueConfig() { string jsonPath = "../src/config/value_config.json"; std::ifstream config_is(jsonPath); if (!config_is.good()) { std::cout << "Error: Params file path:[" << jsonPath << "] not find .\n"; exit(-1); }
nlohmann::json js_value; config_is >> js_value;
try { params = js_value.get<Params>(); } catch (const nlohmann::detail::exception &e) { std::cerr << "Json Params Parse failed :" << e.what() << '\n'; exit(-1); } cout <<"--- out_count: " << params.out_count << endl << " | short_count: " << params.short_count << endl << " | slow_count: " << params.slow_count << endl; cout <<"--- speed_debug: " << (params.speed_debug ? "true" : "false") << endl; cout <<"--- speed_normal: " << params.speed_normal << endl; printf("cone_score : %.2f\t", params.cone_score); printf("bomb_score : %.2f\t", params.bomb_score); printf("block_score : %.2f\t", params.block_score); printf("bridge_score : %.2f\t", params.bridge_score); printf("crosswalk_score : %.2f\n", params.crosswalk_score); printf("rescue_score : %.2f\n", params.people_score); printf("car_score : %.2f\n", params.car_score); } };
|