Skip to content

Commit

Permalink
fix: working version of soft landing
Browse files Browse the repository at this point in the history
  • Loading branch information
iftahnaf committed Jan 13, 2024
1 parent 12d9225 commit 4480a44
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
find_package(Eigen3 REQUIRED)

add_executable(main src/main.cpp src/common.cpp)
target_include_directories(main PUBLIC ${EIGEN3_INCLUDE_DIR})
target_include_directories(main PUBLIC ${EIGEN3_INCLUDE_DIR})

add_executable(soft_landing src/soft_landing.cpp src/common.cpp)
target_include_directories(soft_landing PUBLIC ${EIGEN3_INCLUDE_DIR})
2 changes: 2 additions & 0 deletions include/soft_landing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class SoftLanding{
private:

public:
SoftLanding(void);
~SoftLanding(void);
double um;
Eigen::Vector3d gravity;

Expand Down
2 changes: 2 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ int main(){
stop = high_resolution_clock::now();
duration = duration_cast<microseconds>(stop - start);
std::cout << "using explicit, tgo = " << exp_tgo << ", measured time is: "<< duration.count() << "[microseconds]" << endl;

return 0;
}
23 changes: 20 additions & 3 deletions src/soft_landing.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#include "../include/soft_landing.hpp"
#include "../include/common.hpp"

SoftLanding::SoftLanding(){
SoftLanding::SoftLanding(void){
this->um = 20.0;
this->gravity << 0.0, 0.0, -9.81;
}

SoftLanding::~SoftLanding(){
SoftLanding::~SoftLanding(void){
return;
}

double SoftLanding::soft_landing_tgo_lq(const Eigen::Vector3d r, const Eigen::Vector3d v, double min_tgo=0.01){
double SoftLanding::soft_landing_tgo_lq(const Eigen::Vector3d r, const Eigen::Vector3d v, double min_tgo){
double tgo_f1, tgo_f2, um_1, um_2, tgo;
Eigen::Matrix<double,5,1> f1;
Eigen::Matrix<double,5,1> f2;
Expand Down Expand Up @@ -52,4 +52,21 @@ double SoftLanding::soft_landing_tgo_lq(const Eigen::Vector3d r, const Eigen::Ve
Eigen::Vector3d SoftLanding::soft_landing_controller_lq(const Eigen::Vector3d r, const Eigen::Vector3d v, double tgo){
Eigen::Vector3d u = (1.0 / (pow(tgo, 2))) * (6.0*r + 4.0*tgo*v) + this->gravity;
return u;
}

int main(){
Eigen::Vector3d r, v, controller;

r << 0.0, 0.0, 110.0;
v << 0.0, 0.0, -10.0;

SoftLanding sl;

double tgo = sl.soft_landing_tgo_lq(r, v);
controller = sl.soft_landing_controller_lq(r, v, tgo);

std::cout << "tgo = " << tgo << std::endl;
std::cout << "controller = " << controller << std::endl;

return 0;
}

0 comments on commit 4480a44

Please sign in to comment.