- 3.0.2 optimal control module.
CostFunction-impl.hpp
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4  **********************************************************************************************************************/
5 
6 #pragma once
7 
8 namespace ct {
9 namespace optcon {
10 
11 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
13 {
14  x_.setZero();
15  u_.setZero();
16 }
17 
18 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
20 {
21 }
22 
23 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
25  : x_(arg.x_), u_(arg.u_), t_(arg.t_), t_shift_(arg.t_shift_)
26 {
27 }
28 
29 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
31  const control_vector_t& u,
32  const SCALAR& t)
33 {
34  x_ = x;
35  u_ = u;
36  t_ = t + t_shift_;
37 }
38 
39 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
41  Eigen::Matrix<SCALAR, CONTROL_DIM, 1>& u,
42  SCALAR& t) const
43 {
44  x = this->x_;
45  u = this->u_;
46  t = this->t_;
47 }
48 
49 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
51 {
52  t_shift_ = t;
53 }
54 
55 } // namespace optcon
56 } // namespace ct
state_vector_t x_
Definition: CostFunction.hpp:103
A base function for cost functions. All cost functions should derive from this.
Definition: CostFunction.hpp:25
virtual void setCurrentStateAndControl(const state_vector_t &x, const control_vector_t &u, const SCALAR &t=SCALAR(0.0))
Definition: CostFunction-impl.hpp:30
ct::core::ControlVector< control_dim > u
Definition: LoadFromFileTest.cpp:21
virtual ~CostFunction()
Destructor.
Definition: CostFunction-impl.hpp:19
SCALAR t_
Definition: CostFunction.hpp:105
clear all close all load ct GNMSLog0 mat reformat t
Definition: gnmsPlot.m:6
CppAD::AD< CppAD::cg::CG< double > > SCALAR
ct::core::StateVector< state_dim > x
Definition: LoadFromFileTest.cpp:20
control_vector_t u_
Definition: CostFunction.hpp:104
virtual void shiftTime(const SCALAR t)
Definition: CostFunction-impl.hpp:50
CostFunction()
Default constructor.
Definition: CostFunction-impl.hpp:12
Eigen::Matrix< double, nStates, 1 > state_vector_t
virtual void getCurrentStateAndControl(Eigen::Matrix< SCALAR, STATE_DIM, 1 > &x, Eigen::Matrix< SCALAR, CONTROL_DIM, 1 > &u, SCALAR &t) const
sets current state, control and time
Definition: CostFunction-impl.hpp:40
SCALAR t_shift_
Definition: CostFunction.hpp:107