balls_in_box_occupancy_map.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 // BallsInBoxOccupancyMap is derived from OccupancyMap, and models space as
40 // a collection of spherical sensor fields of view and spherical obstacles,
41 // which may overlap.
42 //
44 
45 #ifndef FASTRACK_ENVIRONMENT_BALLS_IN_BOX_OCCUPANCY_MAP_H
46 #define FASTRACK_ENVIRONMENT_BALLS_IN_BOX_OCCUPANCY_MAP_H
47 
52 #include <fastrack_msgs/SensedSpheres.h>
53 
54 namespace fastrack {
55 namespace environment {
56 
57 using bound::Box;
58 using sensor::SphereSensorParams;
59 
61  : public OccupancyMap<fastrack_msgs::SensedSpheres, SphereSensorParams> {
62  public:
65  : OccupancyMap<fastrack_msgs::SensedSpheres, SphereSensorParams>(),
68 
69  // Derived classes must provide an OccupancyProbability function for both
70  // single points and tracking error bounds centered on a point.
71  // Ignores time since this is a time-invariant environment.
72  double OccupancyProbability(
73  const Vector3d& p,
74  double time = std::numeric_limits<double>::quiet_NaN()) const;
75  double OccupancyProbability(
76  const Vector3d& p, const TrackingBound& bound,
77  double time = std::numeric_limits<double>::quiet_NaN()) const;
78 
79  // Generate a sensor measurement.
80  fastrack_msgs::SensedSpheres SimulateSensor(
81  const SphereSensorParams& params) const;
82 
83  // Derived classes must have some sort of visualization through RViz.
84  void Visualize() const;
85 
86  private:
87  // Load parameters. This may be overridden by derived classes if needed
88  // (they should still call this one via OccupancyMap::LoadParameters).
89  bool LoadParameters(const ros::NodeHandle& n);
90 
91  // Update this environment with the information contained in the given
92  // sensor measurement.
93  // NOTE! This function needs to publish on `updated_topic_`.
94  void SensorCallback(
95  const typename fastrack_msgs::SensedSpheres::ConstPtr& msg);
96 
97  // KdtreeMaps to store spherical obstacle and sensor locations, as well as
98  // radii for each.
101 
102  // Remember the largest obstacle/sensor radius yet, for intersection checks.
105 
106  // Static constants for occupied/unknown/free probabilities.
107  static constexpr double kOccupiedProbability = 1.0;
108  static constexpr double kUnknownProbability = 0.5;
109  static constexpr double kFreeProbability = 0.0;
110 }; //\class BallsInBoxOccupancyMap
111 
112 } //\namespace environment
113 } //\namespace fastrack
114 
115 #endif
fastrack_msgs::SensedSpheres SimulateSensor(const SphereSensorParams &params) const
double OccupancyProbability(const Vector3d &p, double time=std::numeric_limits< double >::quiet_NaN()) const
void SensorCallback(const typename fastrack_msgs::SensedSpheres::ConstPtr &msg)
Definition: box.h:53


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