perception_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 
19 /* Note - this code was originally derived from the ARIAC
20  * PopulationPlugin https://bitbucket.org/osrf/ariac/src/master/osrf_gear/include/osrf_gear/PopulationPlugin.hh
21 */
22 
23 #ifndef VRX_GAZEBO_PERCEPTION_SCORING_PLUGIN_HH_
24 #define VRX_GAZEBO_PERCEPTION_SCORING_PLUGIN_HH_
25 
26 #include <geographic_msgs/GeoPoseStamped.h>
27 #include <ros/ros.h>
28 #include <vector>
29 #include <memory>
30 #include <string>
31 #include <gazebo/physics/PhysicsTypes.hh>
32 #include <gazebo/physics/World.hh>
33 #include <gazebo/transport/transport.hh>
34 #include <sdf/sdf.hh>
36 
37 
40 {
42  public: double time;
43 
45  public: double duration;
46 
48  public: std::string type;
49 
51  public: std::string name;
52 
54  public: ignition::math::Pose3d trialPose;
55 
57  private: ignition::math::Pose3d origPose;
58 
60  public: gazebo::physics::EntityPtr modelPtr;
61 
63  public: bool active = false;
64 
66  public: double error = -1.0;
67 
69  public: PerceptionObject(const double& _time,
70  const double& _duration,
71  const std::string& _type,
72  const std::string& _name,
73  const ignition::math::Pose3d& _trialPose,
74  const gazebo::physics::WorldPtr _world);
75 
78  public: void SetError(const double& _error);
79 
82  public: void StartTrial(const gazebo::physics::EntityPtr& _frame);
83 
85  public: void EndTrial();
86 
88  public: std::string Str();
89 };
90 
91 
151 {
153  public: PerceptionScoringPlugin();
154 
156  public: virtual ~PerceptionScoringPlugin();
157 
158  // Documentation inherited.
159  public: virtual void Load(gazebo::physics::WorldPtr _world,
160  sdf::ElementPtr _sdf);
161 
163  protected: void OnUpdate();
164 
165  private: void OnAttempt(
166  const geographic_msgs::GeoPoseStamped::ConstPtr &_msg);
167 
169  private: void Restart();
170 
171  // Documentation inherited.
172  private: void OnRunning() override;
173 
174  // Documentation inherited.
175  private: void ReleaseVehicle() override;
176 
177  private: int attemptBal = 0;
178 
180  private: std::string ns;
181 
183  private: std::string objectTopic;
184 
186  private: ros::NodeHandle nh;
187 
190 
192  public: gazebo::physics::WorldPtr world;
193 
195  public: sdf::ElementPtr sdf;
196 
198  public: std::vector<PerceptionObject> objects;
199 
201  public: gazebo::event::ConnectionPtr connection;
202 
204  public: gazebo::common::Time startTime;
205 
208  public: bool loopForever = false;
209 
212  public: std::string frameName = std::string();
213 
215  public: gazebo::physics::EntityPtr frame;
216 
218  public: gazebo::common::Time lastUpdateTime;
219 
221  private: int objectsDespawned =0;
222 };
223 
224 #endif
std::string name
PerceptionObject type.
std::string ns
ROS namespace.
ros::Subscriber objectSub
ROS subscriber.
std::string type
PerceptionObject type.
void SetError(const double &_error)
set the error of this boject if this object is active and this is the lowest seen error ...
A plugin that allows models to be spawned at a given location in a specific simulation time and then ...
gazebo::physics::EntityPtr frame
Link/model that the object poses use as their frame of reference.
double duration
amount of time in which the object should be spawned.
sdf::ElementPtr sdf
SDF pointer.
gazebo::event::ConnectionPtr connection
Connection event.
gazebo::common::Time lastUpdateTime
Last time (sim time) that the plugin was updated.
A plugin that provides common functionality to any scoring plugin. This plugin defines four different...
void EndTrial()
move the object back to its original location and make inactive
Class to store information about each object to be populated.
gazebo::common::Time startTime
The time specified in the object is relative to this time.
double error
error associated with the guess of a moel
void StartTrial(const gazebo::physics::EntityPtr &_frame)
move the object to where it is supposed to be relative to the frame
ignition::math::Pose3d trialPose
Pose in which the object should be placed in wam-v&#39;s frame.
std::vector< PerceptionObject > objects
Collection of objects to be spawned.
double time
Simulation time in which the object should be spawned.
gazebo::physics::EntityPtr modelPtr
ModelPtr to the model that this object is representing.
PerceptionObject(const double &_time, const double &_duration, const std::string &_type, const std::string &_name, const ignition::math::Pose3d &_trialPose, const gazebo::physics::WorldPtr _world)
constructor of perception object
ros::NodeHandle nh
ROS Node handle.
ignition::math::Pose3d origPose
Pose in which the object should be placed in global frame.
gazebo::physics::WorldPtr world
World pointer.
std::string objectTopic
ROS topic where the object id/pose is received.
bool active
bool to tell weather or not the object is open for attempts


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