start pcb action

This commit is contained in:
acki
2025-05-14 12:07:00 -04:00
parent 711cce8b41
commit 3d4cee2efe
2 changed files with 41 additions and 0 deletions

View File

@@ -16,6 +16,11 @@ namespace Modelec
~PCBActionInterface() override;
protected:
std::map<std::string, int> asc_v_;
std::map<int, std::map<int, int>> servo_pos_v_;
std::map<std::string, bool> relay_v_;
private:
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pcb_publisher_;
rclcpp::Subscription<std_msgs::msg::String>::SharedPtr pcb_subscriber_;

View File

@@ -73,6 +73,19 @@ namespace Modelec
{
RCLCPP_ERROR(this->get_logger(), "Service call failed");
}
/**
* TODO : def
* action/x/y/...
*
* x -> asc | servo | relay
* y -> get | set | move
*
*
*/
}
PCBActionInterface::~PCBActionInterface()
@@ -88,6 +101,29 @@ namespace Modelec
{
RCLCPP_DEBUG(this->get_logger(), "Received message: '%s'", msg->data.c_str());
std::vector<std::string> tokens = split(msg->data, ';');
if (tokens.size() < 3)
{
RCLCPP_ERROR(this->get_logger(), "Invalid message format");
return;
}
if (tokens[0] == "SET")
{
if (tokens[1] == "ASC")
{
}
else if (startsWith(tokens[2], "SERVO"))
{
int servo_id = std::stoi(tokens[2].substr(5));
}
}
else if (tokens[0] == "OK")
{
}
}
void PCBActionInterface::SendToPCB(const std::string& data) const