NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
traj_data.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, United States Government, as represented by the
2  * Administrator of the National Aeronautics and Space Administration.
3  *
4  * All rights reserved.
5  *
6  * The Astrobee platform is licensed under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  * License for the specific language governing permissions and limitations
16  * under the License.
17  */
18 
19 #ifndef TRAJ_OPT_BASIC_TRAJ_DATA_H_
20 #define TRAJ_OPT_BASIC_TRAJ_DATA_H_
21 
22 #include <string>
23 #include <vector>
24 
25 namespace traj_opt {
26 
27 enum PolyType {
33  LIU,
35 };
36 
38  int degree;
39  float dt;
41  std::vector<float> coeffs;
42  // polynomials are stored with parameterization s \in [0,1]
43  // time duration dt is used to evaluate polynomial p(t/dt) for t \in [0,dt]
44 
45  // define with and without space allocating constructor
47  explicit PolynomialData(int d) : degree(d), coeffs(degree + 1) {}
48 };
49 struct SplineData {
50  int segments;
51  float t_total;
52  // t_total should equal the sum of dt for each segment
53  std::vector<PolynomialData> segs;
54 
55  // define with and without space allocating constructor
57  SplineData(int deg, int seg)
58  : segments(seg), segs(segments, PolynomialData(deg)) {}
59 };
60 
61 struct TrajData {
63  std::vector<SplineData> data;
64  std::vector<std::string> dimension_names;
65  // dimension_names are optional, but are useful for determining what this
66  // trajectory parametrizes
67  // ex. dimension_names = {'x','y',z'}
68 
69  // define with and without space allocating constructor
70  TrajData() {}
71  TrajData(int dim, int segs, int deg)
72  : dimensions(dim), data(dimensions, SplineData(deg, segs)) {}
73 };
74 struct SolverInfo {
75  std::vector<float> gap_history;
76  std::vector<float> cost_history;
77  int iterations{0};
78  std::vector<float> slack;
79  float cost;
80  float gap;
81  std::vector<std::vector<float> > var_history;
82  std::vector<std::vector<float> > time_history;
83 };
84 
85 } // namespace traj_opt
86 #endif // TRAJ_OPT_BASIC_TRAJ_DATA_H_
traj_opt::TrajData::dimension_names
std::vector< std::string > dimension_names
Definition: traj_data.h:64
traj_opt::PolyType
PolyType
Definition: traj_data.h:27
traj_opt::PolynomialData::PolynomialData
PolynomialData(int d)
Definition: traj_data.h:47
traj_opt::LEGENDRE
@ LEGENDRE
Definition: traj_data.h:29
traj_opt::SolverInfo::slack
std::vector< float > slack
Definition: traj_data.h:78
traj_opt::SolverInfo::cost_history
std::vector< float > cost_history
Definition: traj_data.h:76
traj_opt::TrajData
Definition: traj_data.h:61
traj_opt::SplineData::SplineData
SplineData()
Definition: traj_data.h:56
traj_opt::SplineData::segs
std::vector< PolynomialData > segs
Definition: traj_data.h:53
traj_opt::SolverInfo::gap_history
std::vector< float > gap_history
Definition: traj_data.h:75
traj_opt::SolverInfo::var_history
std::vector< std::vector< float > > var_history
Definition: traj_data.h:81
traj_opt::PolynomialData::basis
PolyType basis
Definition: traj_data.h:40
traj_opt::SplineData::SplineData
SplineData(int deg, int seg)
Definition: traj_data.h:57
traj_opt::SolverInfo::time_history
std::vector< std::vector< float > > time_history
Definition: traj_data.h:82
traj_opt::SplineData
Definition: traj_data.h:49
traj_opt::TrajData::data
std::vector< SplineData > data
Definition: traj_data.h:63
traj_opt::SolverInfo
Definition: traj_data.h:74
traj_opt::PolynomialData::dt
float dt
Definition: traj_data.h:39
traj_opt
Definition: msg_traj.h:27
traj_opt::SplineData::segments
int segments
Definition: traj_data.h:50
traj_opt::STANDARD
@ STANDARD
Definition: traj_data.h:28
traj_opt::CHEBYSHEV
@ CHEBYSHEV
Definition: traj_data.h:34
traj_opt::WATTERSON
@ WATTERSON
Definition: traj_data.h:30
traj_opt::ENDPOINT
@ ENDPOINT
Definition: traj_data.h:32
traj_opt::SolverInfo::cost
float cost
Definition: traj_data.h:79
traj_opt::PolynomialData::coeffs
std::vector< float > coeffs
Definition: traj_data.h:41
traj_opt::TrajData::TrajData
TrajData(int dim, int segs, int deg)
Definition: traj_data.h:71
traj_opt::SolverInfo::gap
float gap
Definition: traj_data.h:80
traj_opt::LIU
@ LIU
Definition: traj_data.h:33
traj_opt::PolynomialData::degree
int degree
Definition: traj_data.h:38
traj_opt::SolverInfo::iterations
int iterations
Definition: traj_data.h:77
traj_opt::SplineData::t_total
float t_total
Definition: traj_data.h:51
traj_opt::TrajData::dimensions
int dimensions
Definition: traj_data.h:62
traj_opt::BEZIER
@ BEZIER
Definition: traj_data.h:31
traj_opt::PolynomialData::PolynomialData
PolynomialData()
Definition: traj_data.h:46
traj_opt::PolynomialData
Definition: traj_data.h:37
traj_opt::TrajData::TrajData
TrajData()
Definition: traj_data.h:70