navigation_scoring_plugin.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef VRX_GAZEBO_NAVIGATION_SCORING_PLUGIN_HH_
19 #define VRX_GAZEBO_NAVIGATION_SCORING_PLUGIN_HH_
20 
21 #include <string>
22 #include <vector>
23 #include <gazebo/common/Events.hh>
24 #include <gazebo/physics/Model.hh>
25 #include <gazebo/physics/World.hh>
26 #include <ignition/math/Pose3.hh>
27 #include <sdf/sdf.hh>
29 
88 {
90  private: enum class GateState
91  {
94 
97 
100 
102  CROSSED,
103 
105  INVALID,
106  };
107 
109  private: class Gate
110  {
114  public: Gate(const gazebo::physics::LinkPtr _leftMarkerModel,
115  const gazebo::physics::LinkPtr _rightMarkerModel);
116 
120  public: GateState IsPoseInGate(
121  const ignition::math::Pose3d &_robotWorldPose) const;
122 
124  public: void Update();
125 
127  public: gazebo::physics::LinkPtr leftMarkerModel;
128 
130  public: gazebo::physics::LinkPtr rightMarkerModel;
131 
135  public: ignition::math::Pose3d pose;
136 
138  public: double width;
139 
142  };
143 
144  // Constructor.
145  public: NavigationScoringPlugin();
146 
147  // Documentation inherited.
148  public: void Load(gazebo::physics::WorldPtr _world,
149  sdf::ElementPtr _sdf);
150 
154  private: bool ParseGates(sdf::ElementPtr _sdf);
155 
160  private: bool AddGate(const std::string &_leftMarkerName,
161  const std::string &_rightMarkerName);
162 
164  private: void Update();
165 
167  private: void Fail();
168 
169  // Documentation inherited.
170  private: void OnCollision() override;
171 
172  // Name of Course
173  private: gazebo::physics::ModelPtr course;
174 
176  private: std::vector<Gate> gates;
177 
179  private: int numGates;
180 
182  private: gazebo::event::ConnectionPtr updateConnection;
183 
185  private: unsigned int numCollisions = 0;
186 
188  private: double obstaclePenalty = 10.0;
189 };
190 
191 #endif
192 
std::vector< Gate > gates
All the gates.
gazebo::physics::LinkPtr rightMarkerModel
The right marker model.
Gate invalid. E.g.: if crossed in the wrong direction.
double width
The width of the gate in meters.
ignition::math::Pose3d pose
The center of the gate in the world frame. Note that the roll and pitch are ignored. Only yaw is relevant and it points into the direction in which the gate should be crossed.
gazebo::physics::LinkPtr leftMarkerModel
The left marker model.
gazebo::physics::ModelPtr course
bool ParseGates(sdf::ElementPtr _sdf)
Parse the gates from SDF.
void Load(gazebo::physics::WorldPtr _world, sdf::ElementPtr _sdf)
A plugin that provides common functionality to any scoring plugin. This plugin defines four different...
void Fail()
Set the score to 0 and change to state to "finish".
unsigned int numCollisions
The number of WAM-V collisions.
double obstaclePenalty
Number of points deducted per collision.
bool AddGate(const std::string &_leftMarkerName, const std::string &_rightMarkerName)
Register a new gate.
void OnCollision() override
Callback executed when a collision is detected for the WAMV.
void Update()
Callback executed at every world update.
A gate that is part of the navigation challenge.
gazebo::event::ConnectionPtr updateConnection
Pointer to the update event connection.
A plugin for computing the score of the navigation task. This plugin derives from the generic Scoring...


vrx_gazebo
Author(s): Brian Bingham , Carlos Aguero
autogenerated on Thu May 7 2020 03:54:56