balls_in_box.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018, The Regents of the University of California (Regents).
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following
14  * disclaimer in the documentation and/or other materials provided
15  * with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  * Please contact the author(s) of this library if you have any questions.
34  * Authors: David Fridovich-Keil ( dfk@eecs.berkeley.edu )
35  */
36 
38 //
39 // BallsInBox is derived from the Environment base class. This class models
40 // obstacles as spheres to provide a simple demo.
41 //
43 
44 #ifndef FASTRACK_ENVIRONMENT_BALLS_IN_BOX_H
45 #define FASTRACK_ENVIRONMENT_BALLS_IN_BOX_H
46 
49 #include <fastrack_msgs/SensedSpheres.h>
50 
51 #include <geometry_msgs/Point.h>
52 #include <geometry_msgs/Vector3.h>
53 #include <ros/ros.h>
54 #include <visualization_msgs/Marker.h>
55 
56 namespace fastrack {
57 namespace environment {
58 
61 
63  : public Environment<fastrack_msgs::SensedSpheres, SphereSensorParams> {
64  public:
66  explicit BallsInBox()
67  : Environment<fastrack_msgs::SensedSpheres, SphereSensorParams>() {}
68 
69  // Derived classes must provide a collision checker which returns true if
70  // and only if the provided position is a valid collision-free configuration.
71  // Ignores 'time' since this is a time-invariant environment.
72  bool IsValid(const Vector3d &position, const TrackingBound &bound,
73  double time = std::numeric_limits<double>::quiet_NaN()) const;
74 
75  // Generate a sensor measurement.
76  fastrack_msgs::SensedSpheres SimulateSensor(
77  const SphereSensorParams &params) const;
78 
79  // Derived classes must have some sort of visualization through RViz.
80  void Visualize() const;
81 
82  private:
83  // Load parameters. This may be overridden by derived classes if needed
84  // (they should still call this one via Environment::LoadParameters).
85  bool LoadParameters(const ros::NodeHandle &n);
86 
87  // Update this environment with the information contained in the given
88  // sensor measurement.
89  // NOTE! This function needs to publish on `updated_topic_`.
90  void SensorCallback(const fastrack_msgs::SensedSpheres::ConstPtr &msg);
91 
92  // Generate random obstacles.
93  void GenerateObstacles(size_t num, double min_radius, double max_radius,
94  unsigned int seed = 0);
95 
96  // Obstacle centers and radii.
97  std::vector<Vector3d> centers_;
98  std::vector<double> radii_;
99 }; //\class Environment
100 
101 } //\namespace environment
102 } //\namespace fastrack
103 
104 #endif
bool LoadParameters(const ros::NodeHandle &n)
std::vector< Vector3d > centers_
Definition: balls_in_box.h:97
fastrack_msgs::SensedSpheres SimulateSensor(const SphereSensorParams &params) const
void GenerateObstacles(size_t num, double min_radius, double max_radius, unsigned int seed=0)
Definition: box.h:53
std::vector< double > radii_
Definition: balls_in_box.h:98
bool IsValid(const Vector3d &position, const TrackingBound &bound, double time=std::numeric_limits< double >::quiet_NaN()) const
void SensorCallback(const fastrack_msgs::SensedSpheres::ConstPtr &msg)


fastrack
Author(s): David Fridovich-Keil
autogenerated on Mon Aug 3 2020 21:28:37