lee_position_controller.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2015 Fadri Furrer, ASL, ETH Zurich, Switzerland
00003  * Copyright 2015 Michael Burri, ASL, ETH Zurich, Switzerland
00004  * Copyright 2015 Mina Kamel, ASL, ETH Zurich, Switzerland
00005  * Copyright 2015 Janosch Nikolic, ASL, ETH Zurich, Switzerland
00006  * Copyright 2015 Markus Achtelik, ASL, ETH Zurich, Switzerland
00007  *
00008  * Licensed under the Apache License, Version 2.0 (the "License");
00009  * you may not use this file except in compliance with the License.
00010  * You may obtain a copy of the License at
00011  *
00012  *     http://www.apache.org/licenses/LICENSE-2.0
00013 
00014  * Unless required by applicable law or agreed to in writing, software
00015  * distributed under the License is distributed on an "AS IS" BASIS,
00016  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00017  * See the License for the specific language governing permissions and
00018  * limitations under the License.
00019  */
00020 
00021 #ifndef ROTORS_CONTROL_LEE_POSITION_CONTROLLER_H
00022 #define ROTORS_CONTROL_LEE_POSITION_CONTROLLER_H
00023 
00024 #include <mav_msgs/conversions.h>
00025 #include <mav_msgs/eigen_mav_msgs.h>
00026 
00027 #include "rotors_control/common.h"
00028 #include "rotors_control/parameters.h"
00029 
00030 namespace rotors_control {
00031 
00032 // Default values for the lee position controller and the Asctec Firefly.
00033 static const Eigen::Vector3d kDefaultPositionGain = Eigen::Vector3d(6, 6, 6);
00034 static const Eigen::Vector3d kDefaultVelocityGain = Eigen::Vector3d(4.7, 4.7, 4.7);
00035 static const Eigen::Vector3d kDefaultAttitudeGain = Eigen::Vector3d(3, 3, 0.035);
00036 static const Eigen::Vector3d kDefaultAngularRateGain = Eigen::Vector3d(0.52, 0.52, 0.025);
00037 
00038 class LeePositionControllerParameters {
00039  public:
00040   EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00041   LeePositionControllerParameters()
00042       : position_gain_(kDefaultPositionGain),
00043         velocity_gain_(kDefaultVelocityGain),
00044         attitude_gain_(kDefaultAttitudeGain),
00045         angular_rate_gain_(kDefaultAngularRateGain) {
00046     calculateAllocationMatrix(rotor_configuration_, &allocation_matrix_);
00047   }
00048 
00049   Eigen::Matrix4Xd allocation_matrix_;
00050   Eigen::Vector3d position_gain_;
00051   Eigen::Vector3d velocity_gain_;
00052   Eigen::Vector3d attitude_gain_;
00053   Eigen::Vector3d angular_rate_gain_;
00054   RotorConfiguration rotor_configuration_;
00055 };
00056 
00057 class LeePositionController {
00058  public:
00059   LeePositionController();
00060   ~LeePositionController();
00061   void InitializeParameters();
00062   void CalculateRotorVelocities(Eigen::VectorXd* rotor_velocities) const;
00063 
00064   void SetOdometry(const EigenOdometry& odometry);
00065   void SetTrajectoryPoint(
00066     const mav_msgs::EigenTrajectoryPoint& command_trajectory);
00067 
00068   LeePositionControllerParameters controller_parameters_;
00069   VehicleParameters vehicle_parameters_;
00070 
00071   EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00072  private:
00073   bool initialized_params_;
00074   bool controller_active_;
00075 
00076   Eigen::Vector3d normalized_attitude_gain_;
00077   Eigen::Vector3d normalized_angular_rate_gain_;
00078   Eigen::MatrixX4d angular_acc_to_rotor_velocities_;
00079 
00080   mav_msgs::EigenTrajectoryPoint command_trajectory_;
00081   EigenOdometry odometry_;
00082 
00083   void ComputeDesiredAngularAcc(const Eigen::Vector3d& acceleration,
00084                                 Eigen::Vector3d* angular_acceleration) const;
00085   void ComputeDesiredAcceleration(Eigen::Vector3d* acceleration) const;
00086 };
00087 }
00088 
00089 #endif // ROTORS_CONTROL_LEE_POSITION_CONTROLLER_H


rotors_control
Author(s): Fadri Furrer, Michael Burri, Mina Kamel, Janosch Nikolic, Markus Achtelik
autogenerated on Thu Apr 18 2019 02:43:38