state.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 // Base class for all state types. All states must be able to output a position
40 // in 3D space and an arbitrary-dimensional configuration. This configuration
41 // will be used for geometric planning.
42 //
44 
45 #ifndef FASTRACK_STATE_STATE_H
46 #define FASTRACK_STATE_STATE_H
47 
48 #include <fastrack/utils/types.h>
49 #include <fastrack_msgs/State.h>
50 
51 namespace fastrack {
52 namespace state {
53 
54 class State {
55 public:
56  virtual ~State() {}
57 
58  // Accessors. All states must be able to output a position in 3D space
59  // and an arbitrary-dimensional configuration. This configuration will
60  // be used for geometric planning.
61  virtual double X() const = 0;
62  virtual double Y() const = 0;
63  virtual double Z() const = 0;
64  virtual Vector3d Position() const = 0;
65  virtual VectorXd Configuration() const = 0;
66 
67  // What are the positions that the system occupies at the current state.
68  // NOTE! For simplicity, this is a finite set. In future, this could
69  // be generalized to a collection of generic obstacles.
70  virtual std::vector<Vector3d> OccupiedPositions() const = 0;
71 
72  // Convert from/to VectorXd.
73  virtual void FromVector(const VectorXd& x) = 0;
74  virtual VectorXd ToVector() const = 0;
75 
76  // Convert from/to ROS message.
77  void FromRosPtr(const fastrack_msgs::State::ConstPtr& msg) { FromRos(*msg); }
78  virtual void FromRos(const fastrack_msgs::State& msg) = 0;
79  virtual fastrack_msgs::State ToRos() const = 0;
80 
81  // Re-seed the random engine.
82  static inline void Seed(unsigned int seed) { rng_.seed(seed); }
83 
84 protected:
85  explicit State() {}
86 
87  // Random number generator shared across all instances of states.
88  static std::random_device rd_;
89  static std::default_random_engine rng_;
90 }; //\class State
91 
92 } //\namespace state
93 } //\namespace fastrack
94 
95 #endif
virtual Vector3d Position() const =0
virtual VectorXd Configuration() const =0
static std::random_device rd_
Definition: state.h:88
virtual void FromRos(const fastrack_msgs::State &msg)=0
virtual ~State()
Definition: state.h:56
Definition: box.h:53
virtual VectorXd ToVector() const =0
virtual double X() const =0
virtual double Z() const =0
static std::default_random_engine rng_
Definition: state.h:89
void FromRosPtr(const fastrack_msgs::State::ConstPtr &msg)
Definition: state.h:77
virtual void FromVector(const VectorXd &x)=0
static void Seed(unsigned int seed)
Definition: state.h:82
virtual fastrack_msgs::State ToRos() const =0
virtual double Y() const =0
virtual std::vector< Vector3d > OccupiedPositions() const =0


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