Skip to content

Commit b58d33a

Browse files
committed
Issue #21 -2: Adding PID coeficients parametres
1 parent 0d8c17e commit b58d33a

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/kpi_rover_ecu/src/main.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,14 @@ int main(int argc, char* argv[]) {
4141
const int kBase = 10; // Named constant for base 10
4242
int server_portnum = kDefaultPortNum;
4343
int log_level = 1;
44+
float coef_p = 0;
45+
float coef_i = 0;
46+
float coef_d = 0;
4447
std::string logging_directory = "./log";
4548

4649
// Command-line options
4750
int opt = 0;
48-
while ((opt = getopt(argc, argv, "a:p:l:o:")) != -1) {
51+
while ((opt = getopt(argc, argv, "a:p:l:o:q:w:e:")) != -1) {
4952
switch (opt) {
5053
case 'a':
5154
server_address = optarg;
@@ -59,6 +62,15 @@ int main(int argc, char* argv[]) {
5962
case 'o':
6063
logging_directory = optarg;
6164
break;
65+
case 'q':
66+
coef_p = strtof(optarg, nullptr);
67+
break;
68+
case 'w':
69+
coef_i = strtof(optarg, nullptr);
70+
break;
71+
case 'e':
72+
coef_d = strtof(optarg, nullptr);
73+
break;
6274
default:
6375
std::cout << "Usage: " << argv[0];
6476
std::cout << " [-a server_address] ";
@@ -100,10 +112,10 @@ int main(int argc, char* argv[]) {
100112
// MotorConfig(2, true, {1.5, 0.056, 1.5}),
101113
// };
102114
const std::vector<MotorConfig> kShassisVector = {
103-
MotorConfig(3, false, {0, 0, 0}),
104-
MotorConfig(4, false, {0, 0, 0}),
105-
MotorConfig(1, true, {0, 0, 0}),
106-
MotorConfig(2, true, {0, 0, 0}),
115+
MotorConfig(3, false, {coef_p, coef_i, coef_d}),
116+
MotorConfig(4, false, {coef_p, coef_i, coef_d}),
117+
MotorConfig(1, true, {coef_p, coef_i, coef_d}),
118+
MotorConfig(2, true, {coef_p, coef_i, coef_d}),
107119
};
108120

109121
motors_processor.Init(kShassisVector, kMotorNumber);

0 commit comments

Comments
 (0)