Skip to content

Commit 43c548d

Browse files
committed
Merge branch 'main' into feature/ocs2_anymal_perception
# Conflicts: # ocs2_sqp/ocs2_sqp/CMakeLists.txt # ocs2_sqp/ocs2_sqp/include/ocs2_sqp/SqpSolver.h # ocs2_sqp/ocs2_sqp/src/SqpSolver.cpp
2 parents cb368eb + 8b64496 commit 43c548d

File tree

386 files changed

+24680
-3039
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

386 files changed

+24680
-3039
lines changed

.github/workflows/ros-build-test.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: System deps
3131
run: |
3232
apt-get update
33-
apt-get install -y git ninja-build liburdfdom-dev liboctomap-dev libassimp-dev
33+
apt-get install -y git ninja-build liburdfdom-dev liboctomap-dev libassimp-dev checkinstall wget rsync
3434
3535
- uses: actions/checkout@v2
3636
with:
@@ -46,14 +46,33 @@ jobs:
4646
git clone --recurse-submodules https://github.com/leggedrobotics/pinocchio.git src/pinocchio
4747
git clone --recurse-submodules https://github.com/leggedrobotics/hpp-fcl.git src/hpp-fcl
4848
git clone https://github.com/leggedrobotics/ocs2_robotic_assets.git src/ocs2_robotic_assets
49+
50+
- name: Install RaiSim
51+
run: |
52+
git clone --depth 1 https://github.com/raisimTech/raisimLib.git -b v1.1.01 src/raisim_tech
53+
cd src/raisim_tech
54+
mkdir build
55+
cd build
56+
cmake .. -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")
57+
make -j4 && checkinstall
58+
59+
- name: Install ONNX Runtime
60+
run: |
61+
wget https://github.com/microsoft/onnxruntime/releases/download/v1.7.0/onnxruntime-linux-x64-1.7.0.tgz -P tmp/microsoft
62+
tar xf tmp/microsoft/onnxruntime-linux-x64-1.7.0.tgz -C tmp/microsoft
63+
rsync -a tmp/microsoft/onnxruntime-linux-x64-1.7.0/include/ /usr/local/include/onnxruntime
64+
rsync -a tmp/microsoft/onnxruntime-linux-x64-1.7.0/lib/ /usr/local/lib
65+
rsync -a src/ocs2/ocs2_mpcnet/ocs2_mpcnet_core/misc/onnxruntime/cmake/ /usr/local/share/onnxruntime
66+
4967
- name: Build (${{ matrix.build_type }})
5068
shell: bash
5169
run: |
5270
source /opt/ros/noetic/setup.bash
53-
catkin_make_isolated --use-ninja --merge --only-pkg-with-deps ocs2 --ignore-pkg ocs2_raisim --cmake-args -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
71+
catkin_make_isolated --use-ninja --merge --only-pkg-with-deps ocs2 --cmake-args -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
5472
5573
- name: Test
5674
shell: bash
5775
run: |
5876
source devel_isolated/setup.bash
5977
catkin_make_isolated --use-ninja --merge --only-pkg-with-deps ocs2 --catkin-make-args run_tests
78+
catkin_test_results

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ ocs2_ddp/test/ddp_test_generated/
2525
*.out
2626
*.synctex.gz
2727
.vscode/
28+
runs/

jenkins-pipeline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
library 'continuous_integration_pipeline'
2-
ciPipeline("--ros-distro noetic --publish-doxygen --recipes raisimlib\
2+
ciPipeline("--ros-distro noetic --publish-doxygen --recipes onnxruntime raisimlib\
33
--dependencies '[email protected]:leggedrobotics/hpp-fcl.git;master;git'\
44
'[email protected]:leggedrobotics/pinocchio.git;master;git'\
55
'[email protected]:leggedrobotics/ocs2_robotic_assets.git;main;git'\

ocs2/package.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@
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>
2021
<exec_depend>ocs2_ros_interfaces</exec_depend>
2122
<exec_depend>ocs2_python_interface</exec_depend>
2223
<exec_depend>ocs2_pinocchio</exec_depend>
2324
<exec_depend>ocs2_robotic_tools</exec_depend>
25+
<exec_depend>ocs2_perceptive</exec_depend>
2426
<exec_depend>ocs2_robotic_examples</exec_depend>
2527
<exec_depend>ocs2_thirdparty</exec_depend>
2628
<exec_depend>ocs2_raisim</exec_depend>
29+
<exec_depend>ocs2_mpcnet</exec_depend>
2730

2831
<export>
2932
<metapackage />

ocs2_core/cmake/ocs2_cxx_flags.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ list(APPEND OCS2_CXX_FLAGS
2222
)
2323

2424
# Cpp standard version
25-
set(CMAKE_CXX_STANDARD 11)
25+
set(CMAKE_CXX_STANDARD 14)
2626
set(CMAKE_CXX_STANDARD_REQUIRED ON)

ocs2_core/include/ocs2_core/Types.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,8 @@ using matrix_array2_t = std::vector<matrix_array_t>;
7171
/** Array of arrays of dynamic matrix trajectory type. */
7272
using matrix_array3_t = std::vector<matrix_array2_t>;
7373

74-
/** Eigen scalar type. */
75-
using eigen_scalar_t = Eigen::Matrix<scalar_t, 1, 1>;
76-
/** Eigen scalar trajectory type. */
77-
using eigen_scalar_array_t = std::vector<eigen_scalar_t>;
78-
/** Array of eigen scalar trajectory type. */
79-
using eigen_scalar_array2_t = std::vector<eigen_scalar_array_t>;
80-
/** Array of arrays of eigen scalar trajectory type. */
81-
using eigen_scalar_array3_t = std::vector<eigen_scalar_array2_t>;
82-
8374
/**
84-
* Defines the linear approximation
75+
* Defines the linear approximation of a scalar function
8576
* f(x,u) = dfdx' dx + dfdu' du + f
8677
*/
8778
struct ScalarFunctionLinearApproximation {
@@ -134,7 +125,7 @@ std::ostream& operator<<(std::ostream& out, const ScalarFunctionLinearApproximat
134125
*
135126
* @param[in] stateDim: Number of states.
136127
* @param[in] inputDim: Number of inputs.
137-
* @param[in] data: Given quadratic approximation.
128+
* @param[in] data: Given linear approximation.
138129
* @param[in] dataName: The name of the data which appears in the output error message.
139130
* @return The description of the error. If there was no error it would be empty;
140131
*/
@@ -148,7 +139,7 @@ inline ScalarFunctionLinearApproximation operator*(scalar_t scalar, ScalarFuncti
148139
}
149140

150141
/**
151-
* Defines the quadratic approximation
142+
* Defines the quadratic approximation of a scalar function
152143
* f(x,u) = 1/2 dx' dfdxx dx + du' dfdux dx + 1/2 du' dfduu du + dfdx' dx + dfdu' du + f
153144
*/
154145
struct ScalarFunctionQuadraticApproximation {

ocs2_core/include/ocs2_core/constraint/StateConstraintCollection.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,14 @@ class StateConstraintCollection : public Collection<StateConstraint> {
4949
~StateConstraintCollection() override = default;
5050
StateConstraintCollection* clone() const override;
5151

52-
/** Returns the number of active constraints at given time. */
53-
virtual size_t getNumConstraints(scalar_t time) const;
52+
/** Returns the number of active constraints at a given time. */
53+
size_t getNumConstraints(scalar_t time) const;
5454

55-
/** Get the constraint vector value */
56-
virtual vector_t getValue(scalar_t time, const vector_t& state, const PreComputation& preComp) const;
55+
/** Returns the number of active constraints at a given time for each term. If a term is inactive, its size is zero. */
56+
size_array_t getTermsSize(scalar_t time) const;
57+
58+
/** Get an array of all constraints. If a term is inactive, the corresponding element is a vector of size zero. */
59+
virtual vector_array_t getValue(scalar_t time, const vector_t& state, const PreComputation& preComp) const;
5760

5861
/** Get the constraint linear approximation */
5962
virtual VectorFunctionLinearApproximation getLinearApproximation(scalar_t time, const vector_t& state,
@@ -68,4 +71,4 @@ class StateConstraintCollection : public Collection<StateConstraint> {
6871
StateConstraintCollection(const StateConstraintCollection& other);
6972
};
7073

71-
} // namespace ocs2
74+
} // namespace ocs2

ocs2_core/include/ocs2_core/constraint/StateInputConstraintCollection.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,14 @@ class StateInputConstraintCollection : public Collection<StateInputConstraint> {
4949
~StateInputConstraintCollection() override = default;
5050
StateInputConstraintCollection* clone() const override;
5151

52-
/** Returns the number of active constraints at given time. */
53-
virtual size_t getNumConstraints(scalar_t time) const;
52+
/** Returns the number of active constraints at a given time. */
53+
size_t getNumConstraints(scalar_t time) const;
5454

55-
/** Get the constraint vector value */
56-
virtual vector_t getValue(scalar_t time, const vector_t& state, const vector_t& input, const PreComputation& preComp) const;
55+
/** Returns the number of active constraints at a given time for each term. If a term is inactive, its size is zero. */
56+
size_array_t getTermsSize(scalar_t time) const;
57+
58+
/** Get an array of all constraints. If a term is inactive, the corresponding element is a vector of size zero. */
59+
virtual vector_array_t getValue(scalar_t time, const vector_t& state, const vector_t& input, const PreComputation& preComp) const;
5760

5861
/** Get the constraint linear approximation */
5962
virtual VectorFunctionLinearApproximation getLinearApproximation(scalar_t time, const vector_t& state, const vector_t& input,
@@ -68,4 +71,4 @@ class StateInputConstraintCollection : public Collection<StateInputConstraint> {
6871
StateInputConstraintCollection(const StateInputConstraintCollection& other);
6972
};
7073

71-
} // namespace ocs2
74+
} // namespace ocs2

ocs2_core/include/ocs2_core/control/ControllerType.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ namespace ocs2 {
3434
/**
3535
* Enum class for specifying controller type
3636
*/
37-
enum class ControllerType { UNKNOWN, FEEDFORWARD, LINEAR, NEURAL_NETWORK };
37+
enum class ControllerType { UNKNOWN, FEEDFORWARD, LINEAR, ONNX, BEHAVIORAL };
3838

3939
} // namespace ocs2

ocs2_core/include/ocs2_core/integration/TrapezoidalIntegration.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,32 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929

3030
#pragma once
3131

32+
#include <cassert>
3233
#include <vector>
3334

3435
namespace ocs2 {
3536

36-
template <typename SCALAR_T>
37-
SCALAR_T trapezoidalIntegration(const std::vector<SCALAR_T>& timeTrajectory, const std::vector<SCALAR_T>& valueTrajectory) {
37+
/**
38+
* Compute the trapezoidal integration of a trajectory of VALUE_T given the time stamp timeTrajectory and initial value initialValue.
39+
*
40+
* @note It requires that the VALUE_T has overwrite operator+(VALUE_T, VALUE_T) and define VALUE_T::operator*(SCALAR_T)
41+
*/
42+
template <typename SCALAR_T, typename VALUE_T>
43+
VALUE_T trapezoidalIntegration(const std::vector<SCALAR_T>& timeTrajectory, const std::vector<VALUE_T>& valueTrajectory,
44+
VALUE_T initialValue) {
45+
assert(timeTrajectory.size() == valueTrajectory.size());
46+
3847
if (timeTrajectory.size() < 2) {
39-
return 0.0;
48+
return initialValue;
4049
}
4150

42-
SCALAR_T areaUnderCurve = 0.0;
4351
for (size_t k = 1; k < timeTrajectory.size(); k++) {
44-
areaUnderCurve += 0.5 * (valueTrajectory[k] + valueTrajectory[k - 1]) * (timeTrajectory[k] - timeTrajectory[k - 1]);
52+
auto temp = valueTrajectory[k - 1] + valueTrajectory[k];
53+
temp *= (0.5 * (timeTrajectory[k] - timeTrajectory[k - 1]));
54+
initialValue += temp;
4555
} // end of k loop
4656

47-
return areaUnderCurve;
57+
return initialValue;
4858
}
4959

5060
} // namespace ocs2

0 commit comments

Comments
 (0)