Vector Guidance are 3D optimal control methods for aerial systems.
The guidance laws based on a controller that minimized an finite LQ cost function with the form of:
Where:
-
$y$ is the Zero-Effort-Miss (ZEM) / Zero-Effort-Velocity (ZEV) variable. -
$k$ is the weight on the integration part of the cost. -
$u$ is the controller. -
$t_0$ is the initial time and$t_f$ is the final time.
Because the controller that minimized the LQ cost function is unbound, we define the maximum acceleration of the system as
Note: The value of
Clone the repository:
git clone https://github.com/iftahnaf/vectorguidance.git
Build:
mkdir build
cd build
cmake -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON ..
make
#include "../include/soft_landing.hpp"
#include "../include/common.hpp"
#include <thread>
#include <chrono>
void integrate_state(Eigen::Vector3d &r, Eigen::Vector3d &v, Eigen::Vector3d &controller, double dt, SoftLanding &sl){
Eigen::Vector3d u;
u << controller[0], controller[1], controller[2];
u = u - sl.gravity;
v = v + u*dt;
r = r + v*dt + 0.5*u*dt*dt;
return;
}
int main(){
Eigen::Vector3d rp, vp, controller, rt, vt, r, v;
rp << 240000.0, 0.0, 13000.0;
vp << -1800.0, 0.0, -10.0;
rt << 0.0, 0.0, 0.0;
vt << 0.0, 0.0, 0.0;
SoftLanding sl;
float dt = 0.01;
int counter = 0;
while(rp[2] > 0.0){
r = rt - rp;
v = vt - vp;
double tgo = sl.soft_landing_tgo_lq(r, v);
controller = sl.soft_landing_controller_lq(r, v, tgo);
integrate_state(rp, vp, controller, dt, sl);
std::cout << "tgo = " << tgo << ", controller = (" << controller[0] << ", " << controller[1] << ", " << controller[2] << "), r = (" << rp[0] << ", " << rp[1] << ", " << rp[2] << "), v = (" << vp[0] << ", " << vp[1] << ", " << vp[2] << ")" << std::endl;
counter++;
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
std::cout << "Final Miss Distance: " << r.norm() << " [m], Final Miss Velocity: " << v.norm() << " [m/s], Total Time: " << counter * dt << " [s]"<< std::endl;
return 0;
}
Thank you for considering contributing to Vector Guidance! Contributions are welcome, and we appreciate your help in improving this project. To get started, please follow these guidelines:
- Fork the repository and create your branch from
main
. - Make your changes, ensuring that your code adheres to the project's coding style.
- Write clear and concise commit messages.
- Test your changes thoroughly.
- Open a pull request, providing a detailed description of your changes and the problem or feature they address.
If you find any bugs or have suggestions for new features, please open an issue on the issue tracker.
To set up the development environment, follow the Installation instructions in the README. Additionally, consider running the tests to ensure everything is functioning as expected.
When submitting a pull request, make sure to:
- Clearly describe the problem or feature.
- Provide steps to reproduce the issue if it's a bug.
- Include relevant test cases.
- Ensure that your code passes the existing tests.
We appreciate your contributions to Vector Guidance!
This project can being use via MIT license