Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Garden] Wildlife scoring plugin - Part2 #547

Merged
merged 6 commits into from
Dec 1, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Feedback
Signed-off-by: Carlos Agüero <caguero@osrfoundation.org>
  • Loading branch information
caguero committed Dec 1, 2022
commit 2f77bdf922221ca204aa17714c9f7d4bb021b1fd
17 changes: 4 additions & 13 deletions vrx_gz/src/WildlifeScoringPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@ VirtualGate::VirtualGate(const sim::Entity _leftMarkerEntity,
/////////////////////////////////////////////////
void VirtualGate::Update()
{
if (this->leftMarkerEntity == sim::kNullEntity)
return;

// The pose of the markers delimiting the virtual gate.
auto comp =
this->ecm.Component<sim::components::WorldPose>(this->leftMarkerEntity);
M1chaelM marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -271,7 +268,6 @@ Buoy::Buoy(const std::string &_entityName,
offset.X(this->engagementDistance * cos(alpha));
offset.Y(this->engagementDistance * sin(alpha));

sim::enableComponent<sim::components::WorldPose>(_ecm, this->entity, true);
auto comp = this->ecm.Component<sim::components::WorldPose>(this->entity);
if (!comp)
{
Expand Down Expand Up @@ -615,7 +611,7 @@ void WildlifeScoringPlugin::PreUpdate(const sim::UpdateInfo &_info,
if (taskCompleted)
{
gzmsg << "Course completed!" << std::endl;
this->SetScore(std::max(0.0, this->Score() - this->dataPtr->TimeBonus()));
this->SetScore(this->Score() - this->dataPtr->TimeBonus());
this->Exit();
}
}
Expand Down Expand Up @@ -770,12 +766,8 @@ double WildlifeScoringPlugin::Implementation::TimeBonus() const
{
totalBonus += this->timeBonus;
}
else if (buoy.goal == BuoyGoal::CIRCUMNAVIGATE_CLOCKWISE &&
buoy.state == BuoyState::CIRCUMNAVIGATED)
{
totalBonus += this->timeBonus;
}
else if (buoy.goal == BuoyGoal::CIRCUMNAVIGATE_COUNTERCLOCKWISE &&
else if ((buoy.goal == BuoyGoal::CIRCUMNAVIGATE_CLOCKWISE ||
buoy.goal == BuoyGoal::CIRCUMNAVIGATE_COUNTERCLOCKWISE) &&
buoy.state == BuoyState::CIRCUMNAVIGATED)
{
totalBonus += this->timeBonus;
Expand All @@ -795,8 +787,7 @@ void WildlifeScoringPlugin::OnCollision()
//////////////////////////////////////////////////
void WildlifeScoringPlugin::OnFinished()
{
this->SetTimeoutScore(
std::max(0.0, this->Score() - this->dataPtr->TimeBonus()));
this->SetTimeoutScore(this->Score() - this->dataPtr->TimeBonus());
ScoringPlugin::OnFinished();
}

Expand Down