This commit is contained in:
acki
2025-05-07 06:54:10 -04:00
parent b852b95177
commit 598d3ae7e4
4 changed files with 21 additions and 13 deletions

View File

@@ -171,6 +171,9 @@ namespace ModelecGUI
{
isGameStarted_ = false;
lastWapointWasEnd = true;
score_ = 0;
score_label_->setText(QString("Score: %1").arg(score_));
timer_label_->setText("00");
qpoints.clear();

View File

@@ -1,3 +1,8 @@
<pami_zone>
<middle id="1000" x="1500" y="1500" theta="-1.5708" width="1700" height="600" type="pami-middle" />
<zone id="1000" x="725" y="1625" theta="-1.5708" width="150" height="450" type="pami-middle" />
<zone id="1001" x="900" y="1550" theta="-1.5708" width="200" height="500" type="pami-middle" />
<zone id="1002" x="1500" y="1500" theta="-1.5708" width="1000" height="600" type="pami-middle" />
<zone id="1003" x="2100" y="1550" theta="-1.5708" width="200" height="500" type="pami-middle" />
<zone id="1004" x="2275" y="1625" theta="-1.5708" width="150" height="450" type="pami-middle" />
</pami_zone>

View File

@@ -22,7 +22,7 @@ namespace Modelec {
bool ReadFromXML(const std::string& filename);
protected:
Obstacle zone;
std::vector<Obstacle> zones_;
int time_to_put_zone_ = 0;
int time_to_remove_top_pot_ = 0;

View File

@@ -56,11 +56,14 @@ namespace Modelec
second_goal - now,
[this]()
{
add_obs_pub_->publish(zone.toMsg());
for (const auto & obs : zones_)
{
add_obs_pub_->publish(obs.toMsg());
std_msgs::msg::Int64 msg;
msg.data = score_to_add_;
score_pub_->publish(msg);
std_msgs::msg::Int64 msg;
msg.data = score_to_add_;
score_pub_->publish(msg);
}
timer_add_->cancel();
});
@@ -98,16 +101,13 @@ namespace Modelec
return false;
}
tinyxml2::XMLElement* elem = root->FirstChildElement("middle");
if (!elem)
for (tinyxml2::XMLElement* elem = root->FirstChildElement("zone");
elem;
elem = elem->NextSiblingElement("zone"))
{
RCLCPP_ERROR(get_logger(), "No <middle> element in file");
return false;
zones_.push_back(Obstacle(elem));
}
zone = Obstacle(elem);
RCLCPP_INFO(get_logger(), "Loaded zone obstacles from XML");
return true;
}