Skip to content

Commit e66d832

Browse files
rename from ocs2_pipg to ocs2_slp
1 parent 8b59b1b commit e66d832

20 files changed

+111
-64
lines changed

ocs2/package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<exec_depend>ocs2_oc</exec_depend>
1717
<exec_depend>ocs2_qp_solver</exec_depend>
1818
<exec_depend>ocs2_ddp</exec_depend>
19+
<exec_depend>ocs2_slp</exec_depend>
1920
<exec_depend>ocs2_sqp</exec_depend>
20-
<exec_depend>ocs2_pipg</exec_depend>
2121
<exec_depend>ocs2_ros_interfaces</exec_depend>
2222
<exec_depend>ocs2_python_interface</exec_depend>
2323
<exec_depend>ocs2_pinocchio</exec_depend>

ocs2_pipg/CMakeLists.txt renamed to ocs2_slp/CMakeLists.txt

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.0.2)
2-
project(ocs2_pipg)
2+
project(ocs2_slp)
33

44
set(CATKIN_PACKAGE_DEPENDENCIES
55
ocs2_core
@@ -45,11 +45,11 @@ include_directories(
4545
)
4646

4747
add_library(${PROJECT_NAME}
48+
src/pipg/PipgSettings.cpp
49+
src/pipg/PipgSolver.cpp
4850
src/Helpers.cpp
49-
src/PipgSettings.cpp
50-
src/PipgSolver.cpp
5151
src/SlpSettings.cpp
52-
src/mpc/PipgMpcSolver.cpp
52+
src/SlpSolver.cpp
5353
)
5454
add_dependencies(${PROJECT_NAME}
5555
${catkin_EXPORTED_TARGETS}
@@ -60,14 +60,18 @@ target_link_libraries(${PROJECT_NAME}
6060
)
6161
target_compile_options(${PROJECT_NAME} PUBLIC ${OCS2_CXX_FLAGS})
6262

63+
add_executable(${PROJECT_NAME}_lintTarget
64+
src/lintTarget.cpp
65+
)
66+
6367
#########################
6468
### CLANG TOOLING ###
6569
#########################
6670
find_package(cmake_clang_tools QUIET)
6771
if(cmake_clang_tools_FOUND)
68-
message(STATUS "Run clang tooling for target " ${PROJECT_NAME})
72+
message(STATUS "Run clang tooling for target " ${PROJECT_NAME}_lintTarget)
6973
add_clang_tooling(
70-
TARGETS ${PROJECT_NAME}
74+
TARGETS ${PROJECT_NAME}_lintTarget ${PROJECT_NAME}
7175
SOURCE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/test
7276
CT_HEADER_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include
7377
CF_WERROR

ocs2_pipg/include/ocs2_pipg/mpc/PipgMpc.h renamed to ocs2_slp/include/ocs2_slp/SlpMpc.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,32 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929

3030
#pragma once
3131

32-
#include "ocs2_pipg/mpc/PipgMpcSolver.h"
33-
3432
#include <ocs2_mpc/MPC_BASE.h>
3533

34+
#include "ocs2_slp/SlpSolver.h"
35+
3636
namespace ocs2 {
37-
class PipgMpc final : public MPC_BASE {
37+
class SlpMpc final : public MPC_BASE {
3838
public:
3939
/**
4040
* Constructor
4141
*
4242
* @param mpcSettings : settings for the mpc wrapping of the solver. Do not use this for maxIterations and stepsize, use multiple shooting
4343
* settings directly.
44-
* @param settings : settings for the multiple shooting solver.
44+
* @param settings : settings for the multiple shooting SLP solver.
4545
* @param [in] optimalControlProblem: The optimal control problem formulation.
4646
* @param [in] initializer: This class initializes the state-input for the time steps that no controller is available.
4747
*/
48-
PipgMpc(mpc::Settings mpcSettings, multiple_shooting::Settings settings, pipg::Settings pipgSetting,
49-
const OptimalControlProblem& optimalControlProblem, const Initializer& initializer)
48+
SlpMpc(mpc::Settings mpcSettings, slp::Settings slpSettings, const OptimalControlProblem& optimalControlProblem,
49+
const Initializer& initializer)
5050
: MPC_BASE(std::move(mpcSettings)) {
51-
solverPtr_.reset(new PipgMpcSolver(std::move(settings), std::move(pipgSetting), optimalControlProblem, initializer));
51+
solverPtr_.reset(new SlpSolver(std::move(slpSettings), optimalControlProblem, initializer));
5252
};
5353

54-
~PipgMpc() override = default;
54+
~SlpMpc() override = default;
5555

56-
PipgMpcSolver* getSolverPtr() override { return solverPtr_.get(); }
57-
const PipgMpcSolver* getSolverPtr() const override { return solverPtr_.get(); }
56+
SlpSolver* getSolverPtr() override { return solverPtr_.get(); }
57+
const SlpSolver* getSolverPtr() const override { return solverPtr_.get(); }
5858

5959
protected:
6060
void calculateController(scalar_t initTime, const vector_t& initState, scalar_t finalTime) override {
@@ -65,6 +65,6 @@ class PipgMpc final : public MPC_BASE {
6565
}
6666

6767
private:
68-
std::unique_ptr<PipgMpcSolver> solverPtr_;
68+
std::unique_ptr<SlpSolver> solverPtr_;
6969
};
7070
} // namespace ocs2

ocs2_pipg/include/ocs2_pipg/SlpSettings.h renamed to ocs2_slp/include/ocs2_slp/SlpSettings.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3232
#include <ocs2_core/Types.h>
3333
#include <ocs2_core/integration/SensitivityIntegrator.h>
3434

35-
#include "ocs2_pipg/PipgSettings.h"
35+
#include "ocs2_slp/pipg/PipgSettings.h"
3636

3737
namespace ocs2 {
3838
namespace slp {

ocs2_pipg/include/ocs2_pipg/mpc/PipgMpcSolver.h renamed to ocs2_slp/include/ocs2_slp/SlpSolver.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3939
#include <ocs2_oc/oc_solver/SolverBase.h>
4040
#include <ocs2_oc/search_strategy/FilterLinesearch.h>
4141

42-
#include "ocs2_pipg/PipgSolver.h"
43-
#include "ocs2_pipg/SlpSettings.h"
44-
#include "ocs2_pipg/SlpSolverStatus.h"
42+
#include "ocs2_slp/SlpSettings.h"
43+
#include "ocs2_slp/SlpSolverStatus.h"
44+
#include "ocs2_slp/pipg/PipgSolver.h"
4545

4646
namespace ocs2 {
4747

48-
class PipgMpcSolver : public SolverBase {
48+
class SlpSolver : public SolverBase {
4949
public:
5050
/**
5151
* Constructor
@@ -54,9 +54,9 @@ class PipgMpcSolver : public SolverBase {
5454
* @param [in] optimalControlProblem: The optimal control problem formulation.
5555
* @param [in] initializer: This class initializes the state-input for the time steps that no controller is available.
5656
*/
57-
PipgMpcSolver(slp::Settings settings, const OptimalControlProblem& optimalControlProblem, const Initializer& initializer);
57+
SlpSolver(slp::Settings settings, const OptimalControlProblem& optimalControlProblem, const Initializer& initializer);
5858

59-
~PipgMpcSolver() override;
59+
~SlpSolver() override;
6060

6161
void reset() override;
6262

@@ -79,15 +79,15 @@ class PipgMpcSolver : public SolverBase {
7979
const std::vector<PerformanceIndex>& getIterationsLog() const override;
8080

8181
ScalarFunctionQuadraticApproximation getValueFunction(scalar_t time, const vector_t& state) const override {
82-
throw std::runtime_error("[PipgMpcSolver] getValueFunction() not available yet.");
82+
throw std::runtime_error("[SlpSolver] getValueFunction() not available yet.");
8383
};
8484

8585
ScalarFunctionQuadraticApproximation getHamiltonian(scalar_t time, const vector_t& state, const vector_t& input) override {
86-
throw std::runtime_error("[PipgMpcSolver] getHamiltonian() not available yet.");
86+
throw std::runtime_error("[SlpSolver] getHamiltonian() not available yet.");
8787
}
8888

8989
vector_t getStateInputEqualityConstraintLagrangian(scalar_t time, const vector_t& state) const override {
90-
throw std::runtime_error("[PipgMpcSolver] getStateInputEqualityConstraintLagrangian() not available yet.");
90+
throw std::runtime_error("[SlpSolver] getStateInputEqualityConstraintLagrangian() not available yet.");
9191
}
9292

9393
MultiplierCollection getIntermediateDualSolution(scalar_t time) const override {
@@ -101,7 +101,7 @@ class PipgMpcSolver : public SolverBase {
101101
if (externalControllerPtr == nullptr) {
102102
runImpl(initTime, initState, finalTime);
103103
} else {
104-
throw std::runtime_error("[PipgMpcSolver::run] This solver does not support external controller!");
104+
throw std::runtime_error("[SlpSolver::run] This solver does not support external controller!");
105105
}
106106
}
107107

ocs2_pipg/include/ocs2_pipg/PipgSolver.h renamed to ocs2_slp/include/ocs2_slp/pipg/PipgSolver.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3838
#include <ocs2_core/thread_support/ThreadPool.h>
3939
#include <ocs2_oc/oc_problem/OcpSize.h>
4040

41-
#include "ocs2_pipg/PipgSettings.h"
42-
#include "ocs2_pipg/PipgSolverStatus.h"
41+
#include "ocs2_slp/pipg/PipgSettings.h"
42+
#include "ocs2_slp/pipg/PipgSolverStatus.h"
4343

4444
namespace ocs2 {
4545

ocs2_pipg/package.xml renamed to ocs2_slp/package.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0"?>
22
<package format="2">
3-
<name>ocs2_pipg</name>
3+
<name>ocs2_slp</name>
44
<version>0.0.0</version>
5-
<description>A numerical implementation of PIPG.</description>
5+
<description>A numerical implementation of a first order primal-dual MPC basee on PIPG.</description>
66

77
<maintainer email="[email protected]">Farbod Farshidian</maintainer>
88
<maintainer email="[email protected]">Zhengyu Fu</maintainer>

ocs2_pipg/src/Helpers.cpp renamed to ocs2_slp/src/Helpers.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2727
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828
******************************************************************************/
2929

30-
#include "ocs2_pipg/Helpers.h"
30+
#include "ocs2_slp/Helpers.h"
3131

3232
#include <atomic>
3333
#include <numeric>

ocs2_pipg/src/SlpSettings.cpp renamed to ocs2_slp/src/SlpSettings.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2727
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828
******************************************************************************/
2929

30-
#include "ocs2_pipg/SlpSettings.h"
30+
#include "ocs2_slp/SlpSettings.h"
3131

3232
#include <iostream>
3333

ocs2_pipg/src/mpc/PipgMpcSolver.cpp renamed to ocs2_slp/src/SlpSolver.cpp

+23-23
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2727
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828
******************************************************************************/
2929

30-
#include "ocs2_pipg/mpc/PipgMpcSolver.h"
30+
#include "ocs2_slp/SlpSolver.h"
3131

3232
#include <iostream>
3333
#include <numeric>
@@ -38,11 +38,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3838
#include <ocs2_oc/multiple_shooting/Transcription.h>
3939
#include <ocs2_oc/pre_condition/Scaling.h>
4040

41-
#include "ocs2_pipg/Helpers.h"
41+
#include "ocs2_slp/Helpers.h"
4242

4343
namespace ocs2 {
4444

45-
PipgMpcSolver::PipgMpcSolver(slp::Settings settings, const OptimalControlProblem& optimalControlProblem, const Initializer& initializer)
45+
SlpSolver::SlpSolver(slp::Settings settings, const OptimalControlProblem& optimalControlProblem, const Initializer& initializer)
4646
: settings_(std::move(settings)),
4747
pipgSolver_(settings_.pipgSettings),
4848
threadPool_(std::max(settings_.nThreads, size_t(1)) - 1, settings_.threadPriority) {
@@ -68,13 +68,13 @@ PipgMpcSolver::PipgMpcSolver(slp::Settings settings, const OptimalControlProblem
6868
filterLinesearch_.armijoFactor = settings_.armijoFactor;
6969
}
7070

71-
PipgMpcSolver::~PipgMpcSolver() {
71+
SlpSolver::~SlpSolver() {
7272
if (settings_.printSolverStatistics) {
7373
std::cerr << getBenchmarkingInformationPIPG() << "\n" << getBenchmarkingInformation() << std::endl;
7474
}
7575
}
7676

77-
void PipgMpcSolver::reset() {
77+
void SlpSolver::reset() {
7878
// Clear solution
7979
primalSolution_ = PrimalSolution();
8080
performanceIndeces_.clear();
@@ -88,7 +88,7 @@ void PipgMpcSolver::reset() {
8888
computeControllerTimer_.reset();
8989
}
9090

91-
std::string PipgMpcSolver::getBenchmarkingInformationPIPG() const {
91+
std::string SlpSolver::getBenchmarkingInformationPIPG() const {
9292
const auto GGTMultiplication = GGTMultiplication_.getTotalInMilliseconds();
9393
const auto preConditioning = preConditioning_.getTotalInMilliseconds();
9494
const auto lambdaEstimation = lambdaEstimation_.getTotalInMilliseconds();
@@ -117,7 +117,7 @@ std::string PipgMpcSolver::getBenchmarkingInformationPIPG() const {
117117
return infoStream.str();
118118
}
119119

120-
std::string PipgMpcSolver::getBenchmarkingInformation() const {
120+
std::string SlpSolver::getBenchmarkingInformation() const {
121121
const auto linearQuadraticApproximationTotal = linearQuadraticApproximationTimer_.getTotalInMilliseconds();
122122
const auto solveQpTotal = solveQpTimer_.getTotalInMilliseconds();
123123
const auto linesearchTotal = linesearchTimer_.getTotalInMilliseconds();
@@ -143,18 +143,18 @@ std::string PipgMpcSolver::getBenchmarkingInformation() const {
143143
return infoStream.str();
144144
}
145145

146-
const std::vector<PerformanceIndex>& PipgMpcSolver::getIterationsLog() const {
146+
const std::vector<PerformanceIndex>& SlpSolver::getIterationsLog() const {
147147
if (performanceIndeces_.empty()) {
148-
throw std::runtime_error("[PipgMpcSolver]: No performance log yet, no problem solved yet?");
148+
throw std::runtime_error("[SlpSolver]: No performance log yet, no problem solved yet?");
149149
} else {
150150
return performanceIndeces_;
151151
}
152152
}
153153

154-
void PipgMpcSolver::runImpl(scalar_t initTime, const vector_t& initState, scalar_t finalTime) {
154+
void SlpSolver::runImpl(scalar_t initTime, const vector_t& initState, scalar_t finalTime) {
155155
if (settings_.printSolverStatus || settings_.printLinesearch) {
156156
std::cerr << "\n++++++++++++++++++++++++++++++++++++++++++++++++++++++";
157-
std::cerr << "\n+++++++++++++ PIPG solver is initialized +++++++++++++";
157+
std::cerr << "\n+++++++++++++ SLP solver is initialized ++++++++++++++";
158158
std::cerr << "\n++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
159159
}
160160

@@ -215,16 +215,16 @@ void PipgMpcSolver::runImpl(scalar_t initTime, const vector_t& initState, scalar
215215
if (settings_.printSolverStatus || settings_.printLinesearch) {
216216
std::cerr << "\nConvergence : " << toString(convergence) << "\n";
217217
std::cerr << "\n++++++++++++++++++++++++++++++++++++++++++++++++++++++";
218-
std::cerr << "\n+++++++++++++ PIPG solver has terminated +++++++++++++";
218+
std::cerr << "\n+++++++++++++ SLP solver has terminated ++++++++++++++";
219219
std::cerr << "\n++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
220220
}
221221
}
222222

223-
void PipgMpcSolver::runParallel(std::function<void(int)> taskFunction) {
223+
void SlpSolver::runParallel(std::function<void(int)> taskFunction) {
224224
threadPool_.runParallel(std::move(taskFunction), settings_.nThreads);
225225
}
226226

227-
PipgMpcSolver::OcpSubproblemSolution PipgMpcSolver::getOCPSolution(const vector_t& delta_x0) {
227+
SlpSolver::OcpSubproblemSolution SlpSolver::getOCPSolution(const vector_t& delta_x0) {
228228
// Solve the QP
229229
OcpSubproblemSolution solution;
230230
auto& deltaXSol = solution.deltaXSol;
@@ -283,13 +283,13 @@ PipgMpcSolver::OcpSubproblemSolution PipgMpcSolver::getOCPSolution(const vector_
283283
return solution;
284284
}
285285

286-
PrimalSolution PipgMpcSolver::toPrimalSolution(const std::vector<AnnotatedTime>& time, vector_array_t&& x, vector_array_t&& u) {
286+
PrimalSolution SlpSolver::toPrimalSolution(const std::vector<AnnotatedTime>& time, vector_array_t&& x, vector_array_t&& u) {
287287
ModeSchedule modeSchedule = this->getReferenceManager().getModeSchedule();
288288
return multiple_shooting::toPrimalSolution(time, std::move(modeSchedule), std::move(x), std::move(u));
289289
}
290290

291-
PerformanceIndex PipgMpcSolver::setupQuadraticSubproblem(const std::vector<AnnotatedTime>& time, const vector_t& initState,
292-
const vector_array_t& x, const vector_array_t& u) {
291+
PerformanceIndex SlpSolver::setupQuadraticSubproblem(const std::vector<AnnotatedTime>& time, const vector_t& initState,
292+
const vector_array_t& x, const vector_array_t& u) {
293293
// Problem horizon
294294
const int N = static_cast<int>(time.size()) - 1;
295295

@@ -362,8 +362,8 @@ PerformanceIndex PipgMpcSolver::setupQuadraticSubproblem(const std::vector<Annot
362362
return totalPerformance;
363363
}
364364

365-
PerformanceIndex PipgMpcSolver::computePerformance(const std::vector<AnnotatedTime>& time, const vector_t& initState,
366-
const vector_array_t& x, const vector_array_t& u) {
365+
PerformanceIndex SlpSolver::computePerformance(const std::vector<AnnotatedTime>& time, const vector_t& initState, const vector_array_t& x,
366+
const vector_array_t& u) {
367367
// Problem horizon
368368
const int N = static_cast<int>(time.size()) - 1;
369369

@@ -408,9 +408,9 @@ PerformanceIndex PipgMpcSolver::computePerformance(const std::vector<AnnotatedTi
408408
return totalPerformance;
409409
}
410410

411-
slp::StepInfo PipgMpcSolver::takeStep(const PerformanceIndex& baseline, const std::vector<AnnotatedTime>& timeDiscretization,
412-
const vector_t& initState, const OcpSubproblemSolution& subproblemSolution, vector_array_t& x,
413-
vector_array_t& u) {
411+
slp::StepInfo SlpSolver::takeStep(const PerformanceIndex& baseline, const std::vector<AnnotatedTime>& timeDiscretization,
412+
const vector_t& initState, const OcpSubproblemSolution& subproblemSolution, vector_array_t& x,
413+
vector_array_t& u) {
414414
using StepType = FilterLinesearch::StepType;
415415

416416
/*
@@ -501,7 +501,7 @@ slp::StepInfo PipgMpcSolver::takeStep(const PerformanceIndex& baseline, const st
501501
return stepInfo;
502502
}
503503

504-
slp::Convergence PipgMpcSolver::checkConvergence(int iteration, const PerformanceIndex& baseline, const slp::StepInfo& stepInfo) const {
504+
slp::Convergence SlpSolver::checkConvergence(int iteration, const PerformanceIndex& baseline, const slp::StepInfo& stepInfo) const {
505505
using Convergence = slp::Convergence;
506506
if ((iteration + 1) >= settings_.slpIteration) {
507507
// Converged because the next iteration would exceed the specified number of iterations

0 commit comments

Comments
 (0)