controller.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Software License Agreement
4  *
5  * Copyright (c) 2020, Christoph Rösmann, All rights reserved.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  *
20  * Authors: Christoph Rösmann
21  *********************************************************************/
22 
23 #ifndef CONTROLLER_H_
24 #define CONTROLLER_H_
25 
27 
33 
34 #include <mpc_local_planner_msgs/StateFeedback.h>
35 
37 
38 #include <ros/subscriber.h>
39 #include <ros/time.h>
40 
41 #include <memory>
42 #include <mutex>
43 
44 namespace mpc_local_planner {
45 
54 {
55  public:
56  using Ptr = std::shared_ptr<Controller>;
58 
59  Controller() = default;
60 
62  const std::vector<teb_local_planner::PoseSE2>& via_points);
63  bool step(const PoseSE2& start, const PoseSE2& goal, const geometry_msgs::Twist& vel, double dt, ros::Time t, corbo::TimeSeries::Ptr u_seq,
65 
66  bool step(const std::vector<geometry_msgs::PoseStamped>& initial_plan, const geometry_msgs::Twist& vel, double dt, ros::Time t,
68 
69  // implements interface method
70  corbo::ControllerInterface::Ptr getInstance() const override { return std::make_shared<Controller>(); }
71  static corbo::ControllerInterface::Ptr getInstanceStatic() { return std::make_shared<Controller>(); }
72 
74 
77 
78  void stateFeedbackCallback(const mpc_local_planner_msgs::StateFeedback::ConstPtr& msg);
79 
81 
83 
99  virtual bool isPoseTrajectoryFeasible(base_local_planner::CostmapModel* costmap_model, const std::vector<geometry_msgs::Point>& footprint_spec,
100  double inscribed_radius = 0.0, double circumscribed_radius = 0.0,
101  double min_resolution_collision_check_angular = M_PI, int look_ahead_idx = -1);
102 
103  // implements interface method
104  void reset() override;
105 
106  protected:
112  const std::vector<teb_local_planner::PoseSE2>& via_points);
113 
114  bool generateInitialStateTrajectory(const Eigen::VectorXd& x0, const Eigen::VectorXd& xf,
115  const std::vector<geometry_msgs::PoseStamped>& initial_plan, bool backward);
116 
117  std::string _robot_type;
123 
125  bool _ocp_successful = false;
126  std::size_t _ocp_seq = 0;
127  bool _publish_ocp_results = false;
128  bool _print_cpu_time = false;
129 
130  bool _prefer_x_feedback = false; // prefer state feedback over odometry feedback
132  std::mutex _x_feedback_mutex;
134  Eigen::VectorXd _recent_x_feedback;
135 
138  double _force_reinit_new_goal_angular = 0.5 * M_PI;
143 };
144 
145 } // namespace mpc_local_planner
146 
147 #endif // CONTROLLER_H_
std::shared_ptr< StageInequalitySE2 > Ptr
RobotDynamicsInterface::Ptr getRobotDynamics()
Definition: controller.h:75
teb_local_planner::PoseSE2 _last_goal
Definition: controller.h:136
Eigen::VectorXd _recent_x_feedback
Definition: controller.h:134
corbo::DiscretizationGridInterface::Ptr _grid
Definition: controller.h:118
bool step(const PoseSE2 &start, const PoseSE2 &goal, const geometry_msgs::Twist &vel, double dt, ros::Time t, corbo::TimeSeries::Ptr u_seq, corbo::TimeSeries::Ptr x_seq)
Definition: controller.cpp:102
static corbo::ControllerInterface::Ptr getInstanceStatic()
Definition: controller.h:71
corbo::StructuredOptimalControlProblem::Ptr _structured_ocp
Definition: controller.h:122
bool generateInitialStateTrajectory(const Eigen::VectorXd &x0, const Eigen::VectorXd &xf, const std::vector< geometry_msgs::PoseStamped > &initial_plan, bool backward)
Definition: controller.cpp:807
std::shared_ptr< OptimalControlProblemInterface > Ptr
corbo::ControllerInterface::Ptr getInstance() const override
Definition: controller.h:70
std::shared_ptr< RobotDynamicsInterface > Ptr
corbo::NlpSolverInterface::Ptr configureSolver(const ros::NodeHandle &nh)
Definition: controller.cpp:380
RobotDynamicsInterface::Ptr _dynamics
Definition: controller.h:119
corbo::StructuredOptimalControlProblem::Ptr configureOcp(const ros::NodeHandle &nh, const teb_local_planner::ObstContainer &obstacles, teb_local_planner::RobotFootprintModelPtr robot_model, const std::vector< teb_local_planner::PoseSE2 > &via_points)
Definition: controller.cpp:483
MPC controller for mobile robots.
Definition: controller.h:53
void setOptimalControlProblem(corbo::OptimalControlProblemInterface::Ptr ocp)=delete
void stateFeedbackCallback(const mpc_local_planner_msgs::StateFeedback::ConstPtr &msg)
Definition: controller.cpp:181
std::vector< ObstaclePtr > ObstContainer
corbo::DiscretizationGridInterface::Ptr configureGrid(const ros::NodeHandle &nh)
Definition: controller.cpp:225
RobotDynamicsInterface::Ptr configureRobotDynamics(const ros::NodeHandle &nh)
Definition: controller.cpp:344
ros::Subscriber _x_feedback_sub
Definition: controller.h:131
StageInequalitySE2::Ptr _inequality_constraint
Definition: controller.h:121
std::shared_ptr< DiscretizationGridInterface > Ptr
std::shared_ptr< NlpSolverInterface > Ptr
ros::Publisher _ocp_result_pub
Definition: controller.h:124
ViaPointContainer via_points
std::shared_ptr< TimeSeries > Ptr
void setInitialPlanEstimateOrientation(bool estimate)
Definition: controller.h:82
bool configure(ros::NodeHandle &nh, const teb_local_planner::ObstContainer &obstacles, teb_local_planner::RobotFootprintModelPtr robot_model, const std::vector< teb_local_planner::PoseSE2 > &via_points)
Definition: controller.cpp:58
corbo::DiscreteTimeReferenceTrajectory _x_seq_init
Definition: controller.h:139
std::shared_ptr< ControllerInterface > Ptr
corbo::NlpSolverInterface::Ptr _solver
Definition: controller.h:120
StageInequalitySE2::Ptr getInequalityConstraint()
Definition: controller.h:76
std::shared_ptr< StructuredOptimalControlProblem > Ptr
virtual bool isPoseTrajectoryFeasible(base_local_planner::CostmapModel *costmap_model, const std::vector< geometry_msgs::Point > &footprint_spec, double inscribed_radius=0.0, double circumscribed_radius=0.0, double min_resolution_collision_check_angular=M_PI, int look_ahead_idx=-1)
Check whether the planned trajectory is feasible or not.
Definition: controller.cpp:859


mpc_local_planner
Author(s): Christoph Rösmann
autogenerated on Mon Feb 28 2022 22:53:18