-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Control] move LQI-based controller to fundamental package (aerial_ro…
…bot_control)
- Loading branch information
Showing
19 changed files
with
972 additions
and
666 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
113 changes: 113 additions & 0 deletions
113
aerial_robot_control/include/aerial_robot_control/control/under_actuated_lqi_controller.h
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,113 @@ | ||
// -*- mode: c++ -*- | ||
/********************************************************************* | ||
* Software License Agreement (BSD License) | ||
* | ||
* Copyright (c) 2022, JSK Lab | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/o2r other materials provided | ||
* with the distribution. | ||
* * Neither the name of the JSK Lab nor the names of its | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*********************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <aerial_robot_control/control/under_actuated_controller.h> | ||
#include <aerial_robot_control/control/utils/care.h> | ||
#include <aerial_robot_control/LQIConfig.h> | ||
#include <aerial_robot_msgs/FourAxisGain.h> | ||
#include <dynamic_reconfigure/server.h> | ||
#include <spinal/RollPitchYawTerms.h> | ||
#include <spinal/PMatrixPseudoInverseWithInertia.h> | ||
#include <ros/ros.h> | ||
#include <thread> | ||
|
||
namespace aerial_robot_control | ||
{ | ||
class UnderActuatedLQIController: public PoseLinearController | ||
{ | ||
|
||
public: | ||
UnderActuatedLQIController(); | ||
virtual ~UnderActuatedLQIController(); | ||
|
||
void initialize(ros::NodeHandle nh, ros::NodeHandle nhp, | ||
boost::shared_ptr<aerial_robot_model::RobotModel> robot_model, | ||
boost::shared_ptr<aerial_robot_estimation::StateEstimator> estimator, | ||
boost::shared_ptr<aerial_robot_navigation::BaseNavigator> navigator, | ||
double ctrl_loop_rate); | ||
|
||
protected: | ||
|
||
ros::Publisher flight_cmd_pub_; // for spinal | ||
ros::Publisher rpy_gain_pub_; // for spinal | ||
ros::Publisher four_axis_gain_pub_; | ||
ros::Publisher p_matrix_pseudo_inverse_inertia_pub_; | ||
|
||
bool verbose_; | ||
boost::shared_ptr<dynamic_reconfigure::Server<aerial_robot_control::LQIConfig> > lqi_server_; | ||
dynamic_reconfigure::Server<aerial_robot_control::LQIConfig>::CallbackType dynamic_reconf_func_lqi_; | ||
|
||
double target_roll_, target_pitch_; | ||
double candidate_yaw_term_; | ||
std::vector<float> target_base_thrust_; | ||
|
||
int lqi_mode_; | ||
bool clamp_gain_; | ||
Eigen::MatrixXd K_; | ||
|
||
Eigen::Vector3d lqi_roll_pitch_weight_, lqi_yaw_weight_, lqi_z_weight_; | ||
std::vector<double> r_; // matrix R | ||
|
||
std::vector<Eigen::Vector3d> pitch_gains_, roll_gains_, yaw_gains_, z_gains_; | ||
|
||
bool gyro_moment_compensation_; | ||
|
||
bool realtime_update_; | ||
std::thread gain_generator_thread_; | ||
|
||
//private functions | ||
virtual bool checkRobotModel(); | ||
void resetGain() { K_ = Eigen::MatrixXd(); } | ||
|
||
virtual void rosParamInit(); | ||
virtual void controlCore() override; | ||
|
||
virtual bool optimalGain(); | ||
virtual void clampGain(); | ||
virtual void publishGain(); | ||
|
||
virtual void sendCmd() override; | ||
virtual void sendFourAxisCommand(); | ||
|
||
virtual void allocateYawTerm(); | ||
void cfgLQICallback(aerial_robot_control::LQIConfig &config, uint32_t level); //dynamic reconfigure | ||
|
||
void sendRotationalInertiaComp(); | ||
|
||
void gainGeneratorFunc(); | ||
}; | ||
}; |
70 changes: 70 additions & 0 deletions
70
...robot_control/include/aerial_robot_control/control/under_actuated_tilted_lqi_controller.h
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,70 @@ | ||
// -*- mode: c++ -*- | ||
/********************************************************************* | ||
* Software License Agreement (BSD License) | ||
* | ||
* Copyright (c) 2022, JSK Lab | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/o2r other materials provided | ||
* with the distribution. | ||
* * Neither the name of the JSK Lab nor the names of its | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*********************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <aerial_robot_control/control/under_actuated_lqi_controller.h> | ||
#include <spinal/DesireCoord.h> | ||
|
||
namespace aerial_robot_control | ||
{ | ||
class UnderActuatedTiltedLQIController: public UnderActuatedLQIController | ||
{ | ||
public: | ||
UnderActuatedTiltedLQIController() {} | ||
virtual ~UnderActuatedTiltedLQIController() = default; | ||
|
||
void initialize(ros::NodeHandle nh, ros::NodeHandle nhp, | ||
boost::shared_ptr<aerial_robot_model::RobotModel> robot_model, | ||
boost::shared_ptr<aerial_robot_estimation::StateEstimator> estimator, | ||
boost::shared_ptr<aerial_robot_navigation::BaseNavigator> navigator, | ||
double ctrl_loop_rate); | ||
|
||
protected: | ||
|
||
ros::Publisher desired_baselink_rot_pub_; | ||
|
||
double trans_constraint_weight_; | ||
double att_control_weight_; | ||
|
||
double z_limit_; | ||
|
||
void controlCore() override; | ||
bool optimalGain() override; | ||
void publishGain() override; | ||
void rosParamInit() override; | ||
|
||
}; | ||
}; |
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
Oops, something went wrong.