PID value

This commit is contained in:
acki
2025-11-19 19:30:28 +01:00
parent 7ba7f38197
commit fc63fc910e
2 changed files with 16 additions and 3 deletions

View File

@@ -109,6 +109,6 @@ namespace Modelec
void GetPID(); void GetPID();
void SetPID(const modelec_interfaces::msg::OdometryPid::SharedPtr msg); void SetPID(const modelec_interfaces::msg::OdometryPid::SharedPtr msg);
void SetPID(std::string name, float p, float i, float d); void SetPID(std::string name, float p, float i, float d, std::optional<float> min = std::nullopt, std::optional<float> max = std::nullopt);
}; };
} // namespace Modelec } // namespace Modelec

View File

@@ -63,7 +63,10 @@ namespace Modelec
SetStart(true); SetStart(true);
SetPID("THETA", 8, 0, 0.1); SetPID("THETA", 14, 0, 0);
SetPID("POS", 10, 0, 0);
SetPID("LEFT", 5, 0, 0);
SetPID("RIGHT", 5, 0, 0);
} }
else else
{ {
@@ -424,7 +427,7 @@ namespace Modelec
SetPID(msg->name, msg->p, msg->i, msg->d); SetPID(msg->name, msg->p, msg->i, msg->d);
} }
void PCBOdoInterface::SetPID(std::string name, float p, float i, float d) void PCBOdoInterface::SetPID(std::string name, float p, float i, float d, std::optional<float> min, std::optional<float> max)
{ {
std::vector<std::string> data = { std::vector<std::string> data = {
name, name,
@@ -433,6 +436,16 @@ namespace Modelec
std::to_string(d) std::to_string(d)
}; };
if (min.has_value())
{
data.push_back(std::to_string(min.value()));
}
if (max.has_value())
{
data.push_back(std::to_string(max.value()));
}
SendOrder("PID", data); SendOrder("PID", data);
} }
} // Modelec } // Modelec