NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
trajectory_solver.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_PRO_TRAJECTORY_SOLVER_H_
20 #define TRAJ_OPT_PRO_TRAJECTORY_SOLVER_H_
21 
23 
24 #include <boost/smart_ptr/shared_ptr.hpp>
25 #include <iostream>
26 #include <utility>
27 #include <vector>
28 
29 namespace traj_opt {
30 
31 struct Waypoint {
32  int knot_id{0}; // 0: first, 1: second, -1: last -2: second to last, etc
33  VecD pos{VecD::Zero(4, 1)};
34  VecD vel{VecD::Zero(4, 1)};
35  VecD acc{VecD::Zero(4, 1)};
36  VecD jrk{VecD::Zero(4, 1)};
37  bool use_pos{false};
38  bool use_vel{false};
39  bool use_acc{false};
40  bool use_jrk{false};
41 
42  // stack constraint into matrix form
43  std::pair<Eigen::VectorXi, MatD> getIndexForm() const;
44 };
45 
47  public:
49  virtual bool solveTrajectory(
50  const std::vector<Waypoint> &waypnts, const std::vector<MatD> &A,
51  const std::vector<VecD> &b, const std::vector<decimal_t> &ds,
52  decimal_t epsilon = 0,
53  boost::shared_ptr<Vec3Vec> points = boost::shared_ptr<Vec3Vec>(),
54  decimal_t upsilon = 0);
55 
56  virtual bool trajectoryStatus();
57  virtual boost::shared_ptr<Trajectory> getTrajectory();
58 
59  virtual bool adjustTimes(decimal_t epsilon);
60  virtual void setParams(decimal_t v_max, decimal_t a_max, decimal_t j_max,
61  int time_its, decimal_t time_eps);
62 
63  virtual bool checkMax(decimal_t r) { return false; }
64 
65  protected:
66  std::vector<Waypoint> waypoints_;
68  boost::shared_ptr<Trajectory> traj_;
69 
70  // parameters
72  int time_its_;
73 };
74 } // namespace traj_opt
75 #endif // TRAJ_OPT_PRO_TRAJECTORY_SOLVER_H_
traj_opt::Waypoint::vel
VecD vel
Definition: trajectory_solver.h:34
trajectory.h
traj_opt::Waypoint::use_acc
bool use_acc
Definition: trajectory_solver.h:39
traj_opt::TrajectorySolver::adjustTimes
virtual bool adjustTimes(decimal_t epsilon)
Definition: trajectory_solver.cpp:39
traj_opt::TrajectorySolver::solveTrajectory
virtual bool solveTrajectory(const std::vector< Waypoint > &waypnts, const std::vector< MatD > &A, const std::vector< VecD > &b, const std::vector< decimal_t > &ds, decimal_t epsilon=0, boost::shared_ptr< Vec3Vec > points=boost::shared_ptr< Vec3Vec >(), decimal_t upsilon=0)
Definition: trajectory_solver.cpp:27
traj_opt::Waypoint::jrk
VecD jrk
Definition: trajectory_solver.h:36
traj_opt::TrajectorySolver::j_max_
decimal_t j_max_
Definition: trajectory_solver.h:71
traj_opt::TrajectorySolver::trajectory_solved_
bool trajectory_solved_
Definition: trajectory_solver.h:67
traj_opt::Waypoint::use_pos
bool use_pos
Definition: trajectory_solver.h:37
traj_opt::TrajectorySolver::setParams
virtual void setParams(decimal_t v_max, decimal_t a_max, decimal_t j_max, int time_its, decimal_t time_eps)
Definition: trajectory_solver.cpp:41
traj_opt::TrajectorySolver::traj_
boost::shared_ptr< Trajectory > traj_
Definition: trajectory_solver.h:68
traj_opt::TrajectorySolver::time_its_
int time_its_
Definition: trajectory_solver.h:72
traj_opt::Waypoint
Definition: trajectory_solver.h:31
traj_opt::decimal_t
double decimal_t
Definition: types.h:35
traj_opt::TrajectorySolver::getTrajectory
virtual boost::shared_ptr< Trajectory > getTrajectory()
Definition: trajectory_solver.cpp:36
traj_opt::TrajectorySolver::time_eps_
decimal_t time_eps_
Definition: trajectory_solver.h:71
traj_opt::Waypoint::knot_id
int knot_id
Definition: trajectory_solver.h:32
traj_opt::Waypoint::acc
VecD acc
Definition: trajectory_solver.h:35
traj_opt::Waypoint::getIndexForm
std::pair< Eigen::VectorXi, MatD > getIndexForm() const
Definition: trajectory_solver.cpp:51
traj_opt
Definition: msg_traj.h:27
traj_opt::TrajectorySolver::checkMax
virtual bool checkMax(decimal_t r)
Definition: trajectory_solver.h:63
traj_opt::TrajectorySolver::TrajectorySolver
TrajectorySolver()
Definition: trajectory_solver.cpp:25
traj_opt::TrajectorySolver::waypoints_
std::vector< Waypoint > waypoints_
Definition: trajectory_solver.h:66
traj_opt::TrajectorySolver::a_max_
decimal_t a_max_
Definition: trajectory_solver.h:71
traj_opt::TrajectorySolver
Definition: trajectory_solver.h:46
traj_opt::TrajectorySolver::trajectoryStatus
virtual bool trajectoryStatus()
Definition: trajectory_solver.cpp:35
traj_opt::Waypoint::use_vel
bool use_vel
Definition: trajectory_solver.h:38
traj_opt::Waypoint::use_jrk
bool use_jrk
Definition: trajectory_solver.h:40
traj_opt::Waypoint::pos
VecD pos
Definition: trajectory_solver.h:33
traj_opt::TrajectorySolver::v_max_
decimal_t v_max_
Definition: trajectory_solver.h:71
traj_opt::VecD
Eigen::Matrix< decimal_t, Eigen::Dynamic, 1 > VecD
Definition: types.h:49