forked from jsk-ros-pkg/jsk_aerial_robot
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request jsk-ros-pkg#556 from tongtybj/develop/navigation/t…
…rajectory_generation [Navigation][merge after jsk-ros-pkg#554 jsk-ros-pkg#555] trajectory generation based on optimization methods (e.g. minimum snap trajectory)
- Loading branch information
Showing
43 changed files
with
3,987 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
aerial_robot_control/include/aerial_robot_control/trajectory/base/module.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
|
||
#include "aerial_robot_control/trajectory/utils/logger.hpp" | ||
|
||
namespace agi { | ||
|
||
template<typename Derived> | ||
class Module { | ||
public: | ||
Module(const std::string& name) : logger_(name) {} | ||
virtual ~Module() {} | ||
|
||
inline const std::string& name() const { return logger_.name(); } | ||
virtual void logTiming() const {}; | ||
|
||
protected: | ||
Logger logger_; | ||
}; | ||
|
||
} // namespace agi |
31 changes: 31 additions & 0 deletions
31
aerial_robot_control/include/aerial_robot_control/trajectory/base/parameter_base.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include <aerial_robot_control/trajectory/utils/filesystem.hpp> | ||
#include <exception> | ||
#include <sstream> | ||
|
||
#include "aerial_robot_control/trajectory/math/types.hpp" | ||
#include "aerial_robot_control/trajectory/utils/filesystem.hpp" | ||
#include "aerial_robot_control/trajectory/utils/yaml.hpp" | ||
|
||
namespace agi { | ||
|
||
|
||
struct ParameterException : public std::exception { | ||
ParameterException() = default; | ||
ParameterException(const std::string& msg) | ||
: msg(std::string("Dodgelib Parameter Exception: ") + msg) {} | ||
const char* what() const throw() { return msg.c_str(); } | ||
|
||
const std::string msg{"Dodgelib Parameter Exception"}; | ||
}; | ||
|
||
struct ParameterBase { | ||
virtual ~ParameterBase() = default; | ||
virtual bool load(const fs::path& filename); | ||
virtual bool load(const Yaml& yaml); | ||
|
||
virtual bool valid() const; | ||
}; | ||
|
||
} // namespace agi |
22 changes: 22 additions & 0 deletions
22
aerial_robot_control/include/aerial_robot_control/trajectory/math/gravity.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
#include "aerial_robot_control/trajectory/math/types.hpp" | ||
|
||
namespace agi { | ||
|
||
/** | ||
* Gravity Value [m/s^2] | ||
* | ||
* This is the gravity value used in the whole project. | ||
*/ | ||
static constexpr Scalar G = 9.8066; | ||
|
||
|
||
/** | ||
* Gravity Vector [m/s^2] | ||
* | ||
* This is the gravity vector pointing in negative z-direction. | ||
* It uses the value of #G. | ||
*/ | ||
const Vector<3> GVEC{0, 0, -G}; | ||
|
||
} // namespace agi |
47 changes: 47 additions & 0 deletions
47
aerial_robot_control/include/aerial_robot_control/trajectory/math/math.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#pragma once | ||
|
||
#include <aerial_robot_control/trajectory/math/types.hpp> | ||
|
||
namespace agi { | ||
|
||
Matrix<3, 3> skew(const Vector<3>& v); | ||
|
||
Matrix<4, 4> Q_left(const Quaternion& q); | ||
|
||
Matrix<4, 4> Q_right(const Quaternion& q); | ||
|
||
Matrix<4, 3> qFromQeJacobian(const Quaternion& q); | ||
|
||
Matrix<4, 4> qConjugateJacobian(); | ||
|
||
Matrix<3, 3> qeRotJacobian(const Quaternion& q, const Matrix<3, 1>& t); | ||
|
||
Matrix<3, 3> qeInvRotJacobian(const Quaternion& q, const Matrix<3, 1>& t); | ||
|
||
void matrixToTripletList(const SparseMatrix& matrix, | ||
std::vector<SparseTriplet>* const list, | ||
const int row_offset = 0, const int col_offset = 0); | ||
|
||
void matrixToTripletList(const Matrix<>& matrix, | ||
std::vector<SparseTriplet>* const list, | ||
const int row_offset = 0, const int col_offset = 0); | ||
|
||
void insert(const SparseMatrix& from, SparseMatrix* const into, | ||
const int row_offset = 0, const int col_offset = 0); | ||
|
||
void insert(const Matrix<>& from, SparseMatrix* const into, | ||
const int row_offset = 0, const int col_offset = 0); | ||
|
||
void insert(const Matrix<>& from, Matrix<>* const into, | ||
const int row_offset = 0, const int col_offset = 0); | ||
|
||
Vector<> clip(const Vector<>& v, const Vector<>& bound); | ||
|
||
inline constexpr Scalar toRad(const Scalar angle_deg) { | ||
return angle_deg * M_PI / 180.0; | ||
} | ||
inline constexpr Scalar toDeg(const Scalar angle_deg) { | ||
return angle_deg / M_PI * 180.0; | ||
} | ||
|
||
} // namespace agi |
53 changes: 53 additions & 0 deletions
53
aerial_robot_control/include/aerial_robot_control/trajectory/math/types.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#pragma once | ||
|
||
#include <Eigen/Eigen> | ||
#include <limits> | ||
|
||
namespace agi { | ||
|
||
// Define the scalar type used. | ||
using Scalar = double; | ||
static constexpr Scalar INF = std::numeric_limits<Scalar>::infinity(); | ||
|
||
// Define `Dynamic` matrix size. | ||
static constexpr int Dynamic = Eigen::Dynamic; | ||
|
||
// Using shorthand for `Matrix<rows, cols>` with scalar type. | ||
template<int rows = Dynamic, int cols = rows> | ||
using Matrix = Eigen::Matrix<Scalar, rows, cols>; | ||
|
||
// Using shorthand for `Vector<rows>` with scalar type. | ||
template<int rows = Dynamic> | ||
using Vector = Matrix<rows, 1>; | ||
|
||
// Using shorthand for `Array<rows, cols>` with scalar type. | ||
template<int rows = Dynamic, int cols = rows> | ||
using Array = Eigen::Array<Scalar, rows, cols>; | ||
|
||
template<int rows = Dynamic> | ||
using ArrayVector = Array<rows, 1>; | ||
|
||
// Using `SparseMatrix` with type. | ||
using SparseMatrix = Eigen::SparseMatrix<Scalar>; | ||
|
||
// Using SparseTriplet with type. | ||
using SparseTriplet = Eigen::Triplet<Scalar>; | ||
|
||
// Using `Quaternion` with type. | ||
using Quaternion = Eigen::Quaternion<Scalar>; | ||
|
||
// Using `Ref` for modifier references. | ||
template<class Derived> | ||
using Ref = Eigen::Ref<Derived>; | ||
|
||
// Using `ConstRef` for constant references. | ||
template<class Derived> | ||
using ConstRef = const Eigen::Ref<const Derived>; | ||
|
||
// Using `Map`. | ||
template<class Derived> | ||
using Map = Eigen::Map<Derived>; | ||
|
||
using DynamicsFunction = | ||
std::function<bool(const Ref<const Vector<>>, Ref<Vector<>>)>; | ||
} // namespace agi |
51 changes: 51 additions & 0 deletions
51
aerial_robot_control/include/aerial_robot_control/trajectory/reference_base.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "aerial_robot_control/trajectory/base/module.hpp" | ||
#include "aerial_robot_control/trajectory/math/types.hpp" | ||
#include "aerial_robot_control/trajectory/types/setpoint.hpp" | ||
#include "aerial_robot_control/trajectory/utils/logger.hpp" | ||
|
||
namespace agi { | ||
|
||
class ReferenceBase { | ||
public: | ||
ReferenceBase(const std::string& name = "ReferenceBase"); | ||
ReferenceBase(const QuadState& state, const Scalar duration, | ||
const std::string& name = "ReferenceBase"); | ||
virtual ~ReferenceBase(); | ||
|
||
virtual Setpoint getSetpoint(const QuadState& state, const Scalar t) = 0; | ||
virtual Setpoint getSetpoint(const QuadState& state) final; | ||
virtual Setpoint getSetpoint(const Scalar t, | ||
const Scalar heading = NAN) final; | ||
virtual Setpoint getStartSetpoint(); | ||
virtual Setpoint getEndSetpoint(); | ||
|
||
inline Scalar getStartTime() const { return start_state_.t; } | ||
inline Scalar getEndTime() const { return start_state_.t + duration_; } | ||
inline Scalar getDuration() const { return duration_; } | ||
bool isTimeInRange(const Scalar time) const; | ||
std::string time_in_HH_MM_SS_MMM(const Scalar time) const; | ||
|
||
virtual bool valid() const { return start_state_.valid(); } | ||
const std::string& name() const { return name_; } | ||
virtual bool isHover() const { return false; } | ||
virtual bool isVelocityRefernce() const { return false; } | ||
virtual bool isAbsolute() const { return true; } | ||
|
||
bool truncate(const Scalar& t); | ||
friend std::ostream& operator<<(std::ostream& os, const ReferenceBase& ref); | ||
|
||
protected: | ||
QuadState start_state_; | ||
Scalar duration_; | ||
const std::string name_; | ||
}; | ||
|
||
using ReferenceVector = std::vector<std::shared_ptr<ReferenceBase>>; | ||
|
||
} // namespace agi |
Oops, something went wrong.