Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CoM Trajectory Generation from HMC #140

Draft
wants to merge 43 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d573ecf
[HMC] Import LinearTimeInvariantInvertedPendulum
arntanguy Jun 10, 2020
496c915
[HMC/LTVS] Cleanup and start documenting
arntanguy Jun 10, 2020
612bcdb
LookupTable implementation (+test/benchmark)
arntanguy Jun 15, 2020
822c433
[hmc] Import code related to short-term com trajectory
arntanguy Jun 15, 2020
ec4fc55
[HMC] Minimal running example of CoM trajectory generation
arntanguy Jun 15, 2020
b843e14
[utils] Add utility to measure elapsed time of a function
arntanguy Jun 15, 2020
136e148
[HMC/test] Use mc_rtc logging
arntanguy Jun 15, 2020
7020de9
[LookupTable] Fix debug assert
arntanguy Jun 15, 2020
d69affc
[time_utils] Always pick a steady clock
arntanguy Jun 16, 2020
5d5163e
[HMC/LTVIP] Use LookupTable implementation
arntanguy Jun 16, 2020
ff9b4e0
[ci/tmp] Temporarely upload documentation of HMC branch
arntanguy Jun 16, 2020
5485b13
[CI/tmp] Disable slack notification for now
arntanguy Jun 19, 2020
813d8c7
[HMC/bench] Use same cosh argument as in LTVIP
arntanguy Jun 16, 2020
3b624ea
[io_utils] Specializations for Eigen types
arntanguy Jun 16, 2020
388e508
[HMC/test] Clean generator example (+bugfix)
arntanguy Jun 17, 2020
98e9e8f
[time_utils] Add stopwatch
arntanguy Jun 18, 2020
452f2ef
[HMC/samples] Sample controller generating and tracking CoM/ZMP Traje…
arntanguy Jun 17, 2020
a03ee7a
[StabilizerTask] Log reference and stabilized targets
arntanguy Jun 18, 2020
a2da964
[StabilizerTask] Fix custom plots
arntanguy Jun 18, 2020
b5d713c
[mc_log_ui] Display error when the log file is invalid
arntanguy Jun 19, 2020
0320d7f
[HMC/generator] Cleanup, use unsigned values
arntanguy Jun 19, 2020
878337e
[HMC/samples] WIP change footsteps online
arntanguy Jun 19, 2020
3255f5b
[tests] Use in-source mc_planning headers for tests
arntanguy Jun 22, 2020
811ed48
[HMC/generator] Discrete step logic implementation
arntanguy Jun 22, 2020
a8596e1
[HMC/generator] Add benchmarks
arntanguy Jun 24, 2020
eed398f
[HMC/clean] Move PreviewSteps to its own header
arntanguy Jun 25, 2020
aa221b6
[HMC/bugfix] Fix bug in PreviewSteps::next
arntanguy Jun 25, 2020
ca8aace
[HMC/convenience] Iterable preview windows
arntanguy Jun 25, 2020
7de1e89
[LookupTable] Human-readable function name
arntanguy Jun 25, 2020
6fe0ac1
[HMC/generator] Use Iterable PreviewWindow
arntanguy Jun 26, 2020
b9f95a1
[HMC/doc] Include CoM generation example and figure
arntanguy Jun 26, 2020
d1b46c8
[doc] Install documentation images
arntanguy Jun 26, 2020
578680e
[HMC/doc] Complete generator doc
arntanguy Jun 26, 2020
58e70d4
[doc] Include samples in doxygen, reorganize and install samples
arntanguy Jun 26, 2020
268cdc8
[WIP/PreviewWindow] Implement views, strong typing for Time/Index
arntanguy Jun 26, 2020
2b29fc9
[cmake] Option to force colored output for Clang/GCC
arntanguy Jul 1, 2020
0eb3b77
[WIP/PreviewWindow] Continue views implementation
arntanguy Jul 1, 2020
4c84a3d
[log/utils] Get compile-time type from enum value
arntanguy Jul 2, 2020
81f44d8
[utils] Add mc_bin_compare for comparison between logs
arntanguy Jul 1, 2020
9b1bd15
[tests] Add regression tests based on logs
arntanguy Jul 3, 2020
9ecadaa
[HMC/LTVIP] Use preview windows
arntanguy Jul 3, 2020
704ebd5
[samples/HMC] Adapt CoMTrajectoryGeneration to mc_rtc 1.5
arntanguy Sep 12, 2020
39396a4
[hmc] Fix rebase to mc_rtc 1.7
arntanguy Mar 30, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 33 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,30 @@ jobs:
cd build
cmake ../ && make -j2 && sudo make install || exit 1
popd
- name: Upload documentation (HMC fork)
# Only run on master branch and for one configuration
if: matrix.os == 'ubuntu-18.04' && matrix.build-type == 'RelWithDebInfo' && matrix.compiler == 'gcc' && github.ref == 'refs/heads/topic/hmc' && github.repository == 'arntanguy/mc_rtc'
run: |
set -x
pushd .
cd doc
cp -r /usr/local/share/doc/mc_rtc/doxygen-html .
find . -type f -print0 | xargs -0 sed -i -e's@/usr/local/share/doc/SpaceVecAlg/doxygen-html/@https://jrl-umi3218.github.io/SpaceVecAlg/doxygen/HEAD/@g'
find . -type f -print0 | xargs -0 sed -i -e's@/usr/local/share/doc/RBDyn/doxygen-html/@https://jrl-umi3218.github.io/RBDyn/doxygen/HEAD/@g'
find . -type f -print0 | xargs -0 sed -i -e's@/usr/local/share/doc/Tasks/doxygen-html/@https://jrl-umi3218.github.io/Tasks/doxygen/HEAD/@g'
find . -type f -print0 | xargs -0 sed -i -e's@/usr/local/share/doc/sch-core/doxygen-html/@https://jrl-umi3218.github.io/sch-core/doxygen/HEAD/@g'
find . -type f -print0 | xargs -0 sed -i -e's@/usr/local/share/doc/mc_rbdyn_urdf/doxygen-html/@https://jrl-umi3218.github.io/mc_rbdyn_urdf/doxygen/HEAD/@g'
sudo apt-get install -qq ruby-dev ruby-bundler libxml2-dev
bundle install --path vendor
git clone -b gh-pages https://arntanguy:${{ secrets.GH_PAGES_TOKEN }}@github.com/arntanguy/mc_rtc /tmp/website
bundle exec jekyll build --trace -b /mc_rtc -d /tmp/website
cd /tmp/website
git add .
git config --global user.email "[email protected]"
git config --global user.name "Arnaud TANGUY (Automated CI update)"
git commit -m "Website from commit ${GITHUB_SHA}"
git push origin gh-pages
popd
- name: Upload documentation
# Only run on master branch and for one configuration
if: matrix.os == 'ubuntu-18.04' && matrix.build-type == 'RelWithDebInfo' && matrix.compiler == 'gcc' && github.ref == 'refs/heads/master' && github.repository == 'jrl-umi3218/mc_rtc'
Expand All @@ -186,6 +210,7 @@ jobs:
cd doc
cp -r /usr/local/share/doc/mc_rtc/doxygen-html .
find . -type f -print0 | xargs -0 sed -i -e's@/usr/local/share/doc/SpaceVecAlg/doxygen-html/@https://jrl-umi3218.github.io/SpaceVecAlg/doxygen/HEAD/@g'
find . -type f -print0 | xargs -0 sed -i -e's@/usr/local/share/doc/SpaceVecAlg/doxygen-html/@https://jrl-umi3218.github.io/SpaceVecAlg/doxygen/HEAD/@g'
find . -type f -print0 | xargs -0 sed -i -e's@/usr/local/share/doc/RBDyn/doxygen-html/@https://jrl-umi3218.github.io/RBDyn/doxygen/HEAD/@g'
find . -type f -print0 | xargs -0 sed -i -e's@/usr/local/share/doc/Tasks/doxygen-html/@https://jrl-umi3218.github.io/Tasks/doxygen/HEAD/@g'
find . -type f -print0 | xargs -0 sed -i -e's@/usr/local/share/doc/sch-core/doxygen-html/@https://jrl-umi3218.github.io/sch-core/doxygen/HEAD/@g'
Expand All @@ -201,11 +226,11 @@ jobs:
git commit -m "Website from commit ${GITHUB_SHA}"
git push origin gh-pages
popd
- name: Slack Notification
if: failure()
uses: archive/github-actions-slack@master
with:
slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_TOKEN }}
slack-channel: '#ci'
slack-text: >
[mc_rtc] Build *${{ matrix.os }}/${{ matrix.build-type }} (${{ matrix.compiler }})* failed on ${{ github.ref }}
# - name: Slack Notification
# if: failure()
# uses: archive/github-actions-slack@master
# with:
# slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_TOKEN }}
# slack-channel: '#ci'
# slack-text: >
# [mc_rtc] Build *${{ matrix.os }}/${{ matrix.build-type }} (${{ matrix.compiler }})* failed on ${{ github.ref }}
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)

project(${PROJECT_NAME} C CXX)
set(MC_RTC_SOURCE_DIR "${PROJECT_SOURCE_DIR}")
set(DOXYGEN_EXAMPLE_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DOCDIR}/doxygen-html/examples")

option(GENERATE_COVERAGE "Generate coverage data" FALSE)
if("${CMAKE_CXX_FLAGS}" MATCHES "--coverage")
Expand All @@ -46,6 +47,7 @@ option(TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" OFF)

option(BUILD_CONTROLLER_SAMPLES "Build sample controllers in the project" ON)
option(DISABLE_CONTROLLER_TESTS "Disable controller unit tests" OFF)
option(DISABLE_LOG_REGRESSION_TESTS "Disable tests checking regressions against downloaded logs" ON)
option(DISABLE_ROBOT_TESTS "Disable RobotModule unit tests" OFF)
option(ENABLE_FAST_TESTS "Run controllers tests for a few iterations" OFF)

Expand All @@ -56,6 +58,17 @@ option(MC_RTC_DISABLE_NETWORK "Build without network support" OFF)

option(DISABLE_ROS "Build without ROS support (even if ROS was found)" OFF)

# By default, neither clang nor gcc produce color output if they detect the output medium
# is not a terminal (e.g Ninja).
option (FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." OFF)
if (${FORCE_COLORED_OUTPUT})
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options (-fdiagnostics-color=always)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options (-fcolor-diagnostics)
endif()
endif()

add_project_dependency(Boost REQUIRED COMPONENTS filesystem timer)
add_project_dependency(Tasks REQUIRED)
add_project_dependency(mc_rbdyn_urdf REQUIRED)
Expand Down Expand Up @@ -156,6 +169,7 @@ include(CMakeModules/ListAllFiles.cmake)
add_subdirectory(CMakeModules)
add_subdirectory(doc)
add_subdirectory(src)
add_subdirectory(samples)
add_subdirectory(plugins)
if(${BUILD_TESTING})
add_subdirectory(tests)
Expand Down
1 change: 1 addition & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ mc_rtc_benchmark(benchCompletionCriteria mc_control)
mc_rtc_benchmark(benchSimulationContactSensor mc_control)
mc_rtc_benchmark(benchRobotLoading mc_rbdyn)
mc_rtc_benchmark(benchAllocTasks mc_tasks)
mc_rtc_benchmark(benchHMC mc_planning)
170 changes: 170 additions & 0 deletions benchmarks/benchHMC.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/*
* Copyright 2015-2020 CNRS-UM LIRMM, CNRS-AIST JRL
*/

#include <mc_planning/LookupTable.h>
#include <mc_planning/generator.h>
#include <mc_rtc/constants.h>
#include "benchmark/benchmark.h"
#include <random>

static void BM_cosh_lookuptable(benchmark::State & state)
{
// Perform setup here
auto omega = [](double h) { return std::sqrt(mc_rtc::constants::GRAVITY / h); };
double dt = 0.005;
auto table =
mc_planning::LookupTable<double>(20000, omega(2.5), omega(0.01), [dt](double x) { return cosh(x * dt); });

static std::random_device rd;
static std::mt19937_64 gen(rd());
static std::uniform_real_distribution<double> dis(omega(2.5), omega(0.01));

double res = 0;
double val = 0;
for(auto _ : state)
{
val = dis(gen);
for(int i = 0; i < 10000; ++i)
{
// Prevent compiler from optimizing away the result
benchmark::DoNotOptimize(res = table(val));
}
}
state.SetItemsProcessed(10000 * state.iterations());
}
BENCHMARK(BM_cosh_lookuptable);

static void BM_cosh(benchmark::State & state)
{
// Perform setup here
auto omega = [](double h) { return std::sqrt(mc_rtc::constants::GRAVITY / h); };
double dt = 0.005;
static std::random_device rd;
static std::mt19937_64 gen(rd());
static std::uniform_real_distribution<double> dis(omega(2.5), omega(0.01));

double res = 0;
double val = 0;
for(auto _ : state)
{
val = dis(gen);
for(int i = 0; i < 10000; ++i)
{
benchmark::DoNotOptimize(res = cosh(val * dt));
}
}
state.SetItemsProcessed(10000 * state.iterations());
}
BENCHMARK(BM_cosh);

class PreviewStepsFixture : public benchmark::Fixture
{
using PreviewSteps = mc_planning::PreviewSteps<Eigen::Vector2d>;

public:
void SetUp(const ::benchmark::State &)
{
steps = std::make_shared<PreviewSteps>();
steps->add({0, {0.0, 0.0}});
steps->add({1.5, {0.0, 1.5}});
steps->add({1.6, {0.0, 1.6}});
steps->add({2.9, {0.0, 2.9}});
steps->add({3.0, {0.0, 3.0}});
steps->add({5.0, {0.0, 3.0}});
steps->add({10.0, {0.0, 3.0}});
steps->initialize();
}

void TearDown(const ::benchmark::State &) {}

static constexpr unsigned nIter()
{
return n_loop * (2 * n_preview + 1);
}

std::shared_ptr<PreviewSteps> steps;
static constexpr double dt = 0.005;
static constexpr unsigned n_loop = 15. / dt;
static constexpr unsigned n_preview = 1.6 / dt;
};

BENCHMARK_DEFINE_F(PreviewStepsFixture, BM_PreviewSteps)(benchmark::State & state)
{
while(state.KeepRunning())
{
for(unsigned loop = 0; loop <= n_loop; loop++)
{
auto previewStart = loop * dt;
steps->nextWindow(previewStart);

for(unsigned previewWindow = loop; previewWindow < loop + 2 * n_preview + 1; ++previewWindow)
{
double t = previewWindow * dt;
steps->update(t);

if(!steps->isLastStep())
{
mc_planning::TimedStep<Eigen::Vector2d> prev, next;
benchmark::DoNotOptimize(prev = steps->previous());
benchmark::DoNotOptimize(next = steps->next());
}
}
}
}
state.SetItemsProcessed(PreviewStepsFixture::nIter() * state.iterations());
}
BENCHMARK_REGISTER_F(PreviewStepsFixture, BM_PreviewSteps)->Unit(benchmark::kMicrosecond);

class GeneratorFixture : public benchmark::Fixture
{
public:
using Generator = mc_planning::generator;
using PreviewSteps = mc_planning::PreviewSteps<Eigen::Vector2d>;
using CenteredPreviewWindow = mc_planning::CenteredPreviewWindow;
GeneratorFixture() : preview(1.6, dt) {}

void SetUp(const ::benchmark::State &)
{
steps.add({preview.halfDuration(), {-0.2, 0.0}});
steps.addRelative({preview.halfDuration(), {0.0, 0.0}});
steps.addRelative({0.1, {0.0, 0.0}});
steps.addRelative({1.6, {0.0, 0.0}});
steps.addRelative({0.1, {0.2, 0.095}});
steps.addRelative({1.6, {0.0, 0.0}});
steps.addRelative({0.1, {0.0, -0.19}});
steps.addRelative({1.6, {0.0, 0.0}});
steps.addRelative({0.1, {-0.2, 0.095}});
steps.addRelative({preview.halfDuration(), {0.0, 0.0}});
steps.initialize();
generator = std::make_shared<Generator>(preview);
generator->steps(steps);

n_loop = preview.index(mc_planning::Time(steps.back().t()));
}

void TearDown(const ::benchmark::State &) {}

std::shared_ptr<Generator> generator;
CenteredPreviewWindow preview;
PreviewSteps steps;
static constexpr double dt = 0.005;
unsigned n_loop = 0.;
static constexpr unsigned n_preview = 1.6 / dt;
};

BENCHMARK_DEFINE_F(GeneratorFixture, BM_Generator)(benchmark::State & state)
{
for(auto _ : state)
{
for(unsigned loop = 0; loop <= n_loop; loop++)
{
generator->generate(loop);
}
}
state.SetItemsProcessed(n_loop * state.iterations());
}
BENCHMARK_REGISTER_F(GeneratorFixture, BM_Generator)->Unit(benchmark::kMicrosecond);

// Run the benchmark
BENCHMARK_MAIN();
4 changes: 4 additions & 0 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ configure_file(_plugins/doxygen.rb.in "${CMAKE_CURRENT_SOURCE_DIR}/_plugins/doxy
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/_data/schemas
DESTINATION ${JSON_DOC_INSTALL}
FILES_MATCHING PATTERN "*.json")

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/images
DESTINATION ${CMAKE_INSTALL_DOCDIR}/doxygen-html
)
Loading