diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ec50e74..c86f0bc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -100,6 +100,9 @@ jobs: github: - path: jrl-umi3218/mc_rtc_data github: | + - path: gabime/spdlog + ref: v1.6.1 + options: -DSPDLOG_BUILD_EXAMPLE:BOOL=OFF -DSPDLOG_BUILD_SHARED:BOOL=ON - path: humanoid-path-planner/hpp-spline ref: v4.7.0 options: -DBUILD_PYTHON_INTERFACE:BOOL=OFF diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 2203e42..54d7c38 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -1,38 +1,28 @@ +--- name: Package mc-rtc-ros - -# This workflow only runs when pushing to master or pushing a tag -# -# On master, it will: -# - Build packages for selected Debian/Ubuntu distro -# - Upload the packages to https://dl.bintray.com/gergondet/multi-contact-head -# -# On tagged versions it will: -# - Create a GitHub release draft -# - Attach the sources to the release -# - Build packages for selected Debian/Ubuntu distro -# - Upload the packages to https://dl.bintray.com/gergondet/multi-contact -# - Finalize the release - on: repository_dispatch: - types: [package-master, package-release] + types: + - package-master + - package-release + pull_request: + branches: + - "**" push: + paths-ignore: + - ".gitlab-ci.yml" + - ".jrl-ci" + - README.md + - ".github/workflows/build.yml" branches: - - master + - "**" tags: - - v* - + - v* jobs: - # For a given tag vX.Y.Z, this checks: - # - set(PROJECT_VERSION X.Y.Z) in CMakeLists.txt - # - version X.Y.Z in debian/changelog - # If these checks fail, the tag is automatically deleted - # - # This job does not run on the master branch check-tag: runs-on: ubuntu-18.04 steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 with: submodules: recursive if: startsWith(github.ref, 'refs/tags/') @@ -56,57 +46,81 @@ jobs: - name: Notify tag deletion uses: archive/github-actions-slack@master with: - slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_TOKEN }} - slack-channel: '#ci' - slack-text: > + slack-bot-user-oauth-access-token: "${{ secrets.SLACK_BOT_TOKEN }}" + slack-channel: "#ci" + slack-text: | Tag *${{ github.ref }}* in *${{ github.repository }}* was deleted: ${{ env.REJECTION}} if: failure() - name: Create release uses: jrl-umi3218/github-actions/create-release@master with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ env.RELEASE_TAG }} + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + tag: "${{ env.RELEASE_TAG }}" if: startsWith(github.ref, 'refs/tags/') - # This job build binary packages for Ubuntu build-packages: needs: check-tag strategy: fail-fast: false matrix: - dist: [xenial, bionic] - arch: [i386, amd64] + dist: + - xenial + - bionic + - focal + arch: + - i386 + - amd64 exclude: - - dist: bionic - arch: i386 + - dist: focal + arch: i386 runs-on: ubuntu-18.04 steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 with: submodules: recursive - - name: Setup environment + - name: Choose extra mirror run: | - set -e - set -x - if [ "${{ github.event.action }}" == "package-master" ] + # We upload in all conditions except when building on PR or branch other than master + export PACKAGE_UPLOAD=true + if ${{ startsWith(github.ref, 'refs/tags/') }} + then + export USE_HEAD=false + elif [ "${{ github.event.action }}" == "package-master" ] then - export REF=master + export USE_HEAD=true elif [ "${{ github.event.action }}" == "package-release" ] then + export USE_HEAD=false export REF=`git tag --sort=committerdate --list 'v[0-9]*'|tail -1` git checkout $REF git submodule sync && git submodule update else export REF=`echo ${{ github.ref }} | sed -e 's@refs/[a-z]*/@@'` + export USE_HEAD=true + if [ $REF != "master" ] + then + export PACKAGE_UPLOAD=false + fi fi - if [ $REF == "master" ] + if $USE_HEAD then + echo "::set-env name=BINTRAY_REPO::multi-contact-head" + echo "::set-env name=BINTRAY_VERSION::HEAD" echo "::set-env name=EXTRA_MIRROR::https://dl.bintray.com/gergondet/multi-contact-head" + echo "::set-env name=PACKAGE_JOB::package-master" else + echo "::set-env name=BINTRAY_REPO::multi-contact-release" + echo "::set-env name=BINTRAY_VERSION::${REF}" echo "::set-env name=EXTRA_MIRROR::https://dl.bintray.com/gergondet/multi-contact-release" + echo "::set-env name=PACKAGE_JOB::package-release" fi + echo "::set-env name=PACKAGE_UPLOAD::${PACKAGE_UPLOAD}" + - name: Setup ROS packages + run: | + set -x export PACKAGES_OUT=/tmp/packages-${{ matrix.dist }}-${{ matrix.arch }} export ROS_DISTRO="" + export PYTHON_EXECUTABLE=/usr/bin/python if [ "${{ matrix.dist }}" = "xenial" ] then export ROS_DISTRO="kinetic" @@ -117,6 +131,13 @@ jobs: export ROS_DISTRO="melodic" export PACKAGES_OUT=${PACKAGES_OUT}-${ROS_DISTRO} fi + if [ "${{ matrix.dist }}" = "focal" ] + then + export PYTHON_EXECUTABLE=/usr/bin/python3 + export ROS_DISTRO="noetic" + sed -i -e"s/python2.7/python3/" debian/rules.ros + export PACKAGES_OUT=${PACKAGES_OUT}-${ROS_DISTRO} + fi echo "::set-env name=ROS_DISTRO::${ROS_DISTRO}" echo "::set-env name=PACKAGES_OUT::${PACKAGES_OUT}" if [ "${ROS_DISTRO}" != "" ] @@ -127,6 +148,7 @@ jobs: cat debian/control mv debian/rules.ros debian/rules sed -i -e"s/@ROS_DISTRO@/${ROS_DISTRO}/" debian/rules + sed -i -e"s#@PYTHON_EXECUTABLE@#${PYTHON_EXECUTABLE}#" debian/rules cat debian/rules sed -e"s/@ROS_DISTRO@/${ROS_DISTRO}/" debian/ros-ROS_DISTRO-mc-convex-visualization.install | tee -a debian/ros-${ROS_DISTRO}-mc-convex-visualization.install sed -e"s/@ROS_DISTRO@/${ROS_DISTRO}/" debian/ros-ROS_DISTRO-mc-log-visualization.install | tee -a debian/ros-${ROS_DISTRO}-mc-log-visualization.install @@ -138,96 +160,142 @@ jobs: - name: Build package uses: jrl-umi3218/github-actions/build-package-native@master with: - dist: ${{ matrix.dist }} - arch: ${{ matrix.arch }} - ros-distro: ${{ env.ROS_DISTRO }} - other-mirrors: ${{ env.EXTRA_MIRROR }} - other-gpg-keys: "0x892EA6EE273707C6495A6FB6220D644C64666806" + dist: "${{ matrix.dist }}" + arch: "${{ matrix.arch }}" + ros-distro: "${{ env.ROS_DISTRO }}" + other-mirrors: "${{ env.EXTRA_MIRROR }}" + other-gpg-keys: '0x892EA6EE273707C6495A6FB6220D644C64666806' - uses: actions/upload-artifact@v1 with: name: packages-${{ matrix.dist }}-${{ matrix.arch }} - path: ${{ env.PACKAGES_OUT }} - # This job upload binary packages for Ubuntu + path: "${{ env.PACKAGES_OUT }}" + if: env.PACKAGE_UPLOAD == 'true' upload-packages: needs: build-packages strategy: max-parallel: 1 fail-fast: false matrix: - dist: [xenial, bionic] - arch: [i386, amd64] + dist: + - xenial + - bionic + - focal + arch: + - i386 + - amd64 exclude: - - dist: bionic - arch: i386 + - dist: focal + arch: i386 runs-on: ubuntu-18.04 steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 with: submodules: recursive - - name: Set upload parameters + - name: Choose extra mirror run: | - if [ "${{ github.event.action }}" == "package-master" ] + # We upload in all conditions except when building on PR or branch other than master + export PACKAGE_UPLOAD=true + if ${{ startsWith(github.ref, 'refs/tags/') }} then - export REF=master + export USE_HEAD=false + elif [ "${{ github.event.action }}" == "package-master" ] + then + export USE_HEAD=true elif [ "${{ github.event.action }}" == "package-release" ] then + export USE_HEAD=false export REF=`git tag --sort=committerdate --list 'v[0-9]*'|tail -1` + git checkout $REF + git submodule sync && git submodule update else export REF=`echo ${{ github.ref }} | sed -e 's@refs/[a-z]*/@@'` + export USE_HEAD=true + if [ $REF != "master" ] + then + export PACKAGE_UPLOAD=false + fi fi - if [ $REF == "master" ] + if $USE_HEAD then echo "::set-env name=BINTRAY_REPO::multi-contact-head" echo "::set-env name=BINTRAY_VERSION::HEAD" + echo "::set-env name=EXTRA_MIRROR::https://dl.bintray.com/gergondet/multi-contact-head" + echo "::set-env name=PACKAGE_JOB::package-master" else echo "::set-env name=BINTRAY_REPO::multi-contact-release" echo "::set-env name=BINTRAY_VERSION::${REF}" + echo "::set-env name=EXTRA_MIRROR::https://dl.bintray.com/gergondet/multi-contact-release" + echo "::set-env name=PACKAGE_JOB::package-release" fi + echo "::set-env name=PACKAGE_UPLOAD::${PACKAGE_UPLOAD}" - name: Download packages uses: actions/download-artifact@v1 with: name: packages-${{ matrix.dist }}-${{ matrix.arch }} + if: env.PACKAGE_UPLOAD == 'true' - name: Upload uses: jrl-umi3218/github-actions/upload-package@master with: - dist: ${{ matrix.dist }} - arch: ${{ matrix.arch }} + dist: "${{ matrix.dist }}" + arch: "${{ matrix.arch }}" subject: gergondet - repo: ${{ env.BINTRAY_REPO }} + repo: "${{ env.BINTRAY_REPO }}" package: | name: mc-rtc-ros desc: "mc_rtc tools based on the ROS framework" licenses: [BSD 2-Clause] vcs_url: https://github.com/jrl-umi3218/mc_rtc_ros - version: ${{ env.BINTRAY_VERSION }} + version: "${{ env.BINTRAY_VERSION }}" path: packages-${{ matrix.dist }}-${{ matrix.arch }} - BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }} - GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - # This job forces a mirror sync + BINTRAY_API_KEY: "${{ secrets.BINTRAY_API_KEY }}" + GPG_PASSPHRASE: "${{ secrets.GPG_PASSPHRASE }}" + if: env.PACKAGE_UPLOAD == 'true' mirror-sync: needs: upload-packages runs-on: ubuntu-18.04 steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 with: submodules: recursive - - name: Set repository parameters + - name: Choose extra mirror run: | - if [ "${{ github.event.action }}" == "package-master" ] + # We upload in all conditions except when building on PR or branch other than master + export PACKAGE_UPLOAD=true + if ${{ startsWith(github.ref, 'refs/tags/') }} + then + export USE_HEAD=false + elif [ "${{ github.event.action }}" == "package-master" ] then - export REF=master + export USE_HEAD=true elif [ "${{ github.event.action }}" == "package-release" ] then + export USE_HEAD=false export REF=`git tag --sort=committerdate --list 'v[0-9]*'|tail -1` + git checkout $REF + git submodule sync && git submodule update else export REF=`echo ${{ github.ref }} | sed -e 's@refs/[a-z]*/@@'` + export USE_HEAD=true + if [ $REF != "master" ] + then + export PACKAGE_UPLOAD=false + fi fi - if [ $REF == "master" ] + if $USE_HEAD then echo "::set-env name=BINTRAY_REPO::multi-contact-head" + echo "::set-env name=BINTRAY_VERSION::HEAD" + echo "::set-env name=EXTRA_MIRROR::https://dl.bintray.com/gergondet/multi-contact-head" + echo "::set-env name=PACKAGE_JOB::package-master" else echo "::set-env name=BINTRAY_REPO::multi-contact-release" + echo "::set-env name=BINTRAY_VERSION::${REF}" + echo "::set-env name=EXTRA_MIRROR::https://dl.bintray.com/gergondet/multi-contact-release" + echo "::set-env name=PACKAGE_JOB::package-release" fi + echo "::set-env name=PACKAGE_UPLOAD::${PACKAGE_UPLOAD}" - name: Request mirror sync - run: | - curl -ugergondet:${{ secrets.BINTRAY_API_KEY }} --header "X-GPG-PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}" -X POST https://api.bintray.com/calc_metadata/gergondet/${{ env.BINTRAY_REPO }} + run: 'curl -ugergondet:${{ secrets.BINTRAY_API_KEY }} --header "X-GPG-PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}" -X POST https://api.bintray.com/calc_metadata/gergondet/${{ env.BINTRAY_REPO }} + +' + if: env.PACKAGE_UPLOAD == 'true' diff --git a/.github/workflows/sources/package.yml b/.github/workflows/sources/package.yml new file mode 100644 index 0000000..6b34bb9 --- /dev/null +++ b/.github/workflows/sources/package.yml @@ -0,0 +1,242 @@ +name: Package mc-rtc-ros + +# On any branch/pull request it will: +# - Build packages for selected Debian/Ubuntu distros +# +# On master, it will additionally: +# - Build packages for selected Debian/Ubuntu distro +# - Upload the packages to https://dl.bintray.com/gergondet/multi-contact-head +# +# On tagged versions it will: +# - Create a GitHub release draft +# - Attach the sources to the release +# - Build packages for selected Debian/Ubuntu distro +# - Upload the packages to https://dl.bintray.com/gergondet/multi-contact +# +# On package-master trigger, it will rebuild and upload the latest master package +# +# On package-release trigger, it will rebuild and upload the latest release package + +on: + repository_dispatch: + types: [package-master, package-release] + pull_request: + branches: + - "**" + push: + paths-ignore: + # Changes to those files don't mandate rebuilding a package + - ".gitlab-ci.yml" + - ".jrl-ci" + - "README.md" + - ".github/workflows/build.yml" + branches: + - '**' + tags: + - v* + +jobs: + # For a given tag vX.Y.Z, this checks: + # - set(PROJECT_VERSION X.Y.Z) in CMakeLists.txt + # - version X.Y.Z in debian/changelog + # If these checks fail, the tag is automatically deleted + # + # This job does not run on the master branch + check-tag: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + if: startsWith(github.ref, 'refs/tags/') + - name: Check version coherency + run: | + set -x + export VERSION=`echo ${{ github.ref }} | sed -e 's@refs/tags/v@@'` + echo "::set-env name=REJECTION::PROJECT_VERSION in CMakeLists.txt does not match tag" + grep -q "project(mc_rtc_ros VERSION ${VERSION})" CMakeLists.txt + echo "::set-env name=REJECTION::Upstream version in debian/changelog does not match tag" + head -n 1 debian/changelog | grep -q "mc-rtc-ros (${VERSION}" + echo "::set-env name=REJECTION::" + export TAG=`echo ${{ github.ref }} | sed -e 's@refs/tags/@@'` + echo "::set-env name=RELEASE_TAG::${TAG}" + if: startsWith(github.ref, 'refs/tags/') + - name: Delete tag + run: | + set -x + curl --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -X DELETE https://api.github.com/repos/${{ github.repository }}/git/${{ github.ref }} + if: failure() + - name: Notify tag deletion + uses: archive/github-actions-slack@master + with: + slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_TOKEN }} + slack-channel: '#ci' + slack-text: > + Tag *${{ github.ref }}* in *${{ github.repository }}* was deleted: + ${{ env.REJECTION}} + if: failure() + - name: Create release + uses: jrl-umi3218/github-actions/create-release@master + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ env.RELEASE_TAG }} + if: startsWith(github.ref, 'refs/tags/') + # This job build binary packages for Ubuntu + build-packages: + needs: check-tag + strategy: + fail-fast: false + matrix: &package-matrix + dist: [xenial, bionic, focal] + arch: [i386, amd64] + exclude: + - dist: focal + arch: i386 + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - &choose-extra-mirror + name: Choose extra mirror + run: | + # We upload in all conditions except when building on PR or branch other than master + export PACKAGE_UPLOAD=true + if ${{ startsWith(github.ref, 'refs/tags/') }} + then + export USE_HEAD=false + elif [ "${{ github.event.action }}" == "package-master" ] + then + export USE_HEAD=true + elif [ "${{ github.event.action }}" == "package-release" ] + then + export USE_HEAD=false + export REF=`git tag --sort=committerdate --list 'v[0-9]*'|tail -1` + git checkout $REF + git submodule sync && git submodule update + else + export REF=`echo ${{ github.ref }} | sed -e 's@refs/[a-z]*/@@'` + export USE_HEAD=true + if [ $REF != "master" ] + then + export PACKAGE_UPLOAD=false + fi + fi + if $USE_HEAD + then + echo "::set-env name=BINTRAY_REPO::multi-contact-head" + echo "::set-env name=BINTRAY_VERSION::HEAD" + echo "::set-env name=EXTRA_MIRROR::https://dl.bintray.com/gergondet/multi-contact-head" + echo "::set-env name=PACKAGE_JOB::package-master" + else + echo "::set-env name=BINTRAY_REPO::multi-contact-release" + echo "::set-env name=BINTRAY_VERSION::${REF}" + echo "::set-env name=EXTRA_MIRROR::https://dl.bintray.com/gergondet/multi-contact-release" + echo "::set-env name=PACKAGE_JOB::package-release" + fi + echo "::set-env name=PACKAGE_UPLOAD::${PACKAGE_UPLOAD}" + - name: Setup ROS packages + run: | + set -x + export PACKAGES_OUT=/tmp/packages-${{ matrix.dist }}-${{ matrix.arch }} + export ROS_DISTRO="" + export PYTHON_EXECUTABLE=/usr/bin/python + if [ "${{ matrix.dist }}" = "xenial" ] + then + export ROS_DISTRO="kinetic" + export PACKAGES_OUT=${PACKAGES_OUT}-${ROS_DISTRO} + fi + if [ "${{ matrix.dist }}" = "bionic" -a "${{ matrix.arch }}" = "amd64" ] + then + export ROS_DISTRO="melodic" + export PACKAGES_OUT=${PACKAGES_OUT}-${ROS_DISTRO} + fi + if [ "${{ matrix.dist }}" = "focal" ] + then + export PYTHON_EXECUTABLE=/usr/bin/python3 + export ROS_DISTRO="noetic" + sed -i -e"s/python2.7/python3/" debian/rules.ros + export PACKAGES_OUT=${PACKAGES_OUT}-${ROS_DISTRO} + fi + echo "::set-env name=ROS_DISTRO::${ROS_DISTRO}" + echo "::set-env name=PACKAGES_OUT::${PACKAGES_OUT}" + if [ "${ROS_DISTRO}" != "" ] + then + sed -i -e"s/# ros-@ROS_DISTRO@/ ros-${ROS_DISTRO}/" debian/control + sed -i -e"s/@ROS_DISTRO@/${ROS_DISTRO}/" debian/control.ros + cat debian/control.ros >> debian/control + cat debian/control + mv debian/rules.ros debian/rules + sed -i -e"s/@ROS_DISTRO@/${ROS_DISTRO}/" debian/rules + sed -i -e"s#@PYTHON_EXECUTABLE@#${PYTHON_EXECUTABLE}#" debian/rules + cat debian/rules + sed -e"s/@ROS_DISTRO@/${ROS_DISTRO}/" debian/ros-ROS_DISTRO-mc-convex-visualization.install | tee -a debian/ros-${ROS_DISTRO}-mc-convex-visualization.install + sed -e"s/@ROS_DISTRO@/${ROS_DISTRO}/" debian/ros-ROS_DISTRO-mc-log-visualization.install | tee -a debian/ros-${ROS_DISTRO}-mc-log-visualization.install + sed -e"s/@ROS_DISTRO@/${ROS_DISTRO}/" debian/ros-ROS_DISTRO-mc-rtc-ticker.install | tee -a debian/ros-${ROS_DISTRO}-mc-rtc-ticker.install + sed -e"s/@ROS_DISTRO@/${ROS_DISTRO}/" debian/ros-ROS_DISTRO-mc-rtc-rviz-panel.install | tee -a debian/ros-${ROS_DISTRO}-mc-rtc-rviz-panel.install + sed -e"s/@ROS_DISTRO@/${ROS_DISTRO}/" debian/ros-ROS_DISTRO-mc-surfaces-visualization.install | tee -a debian/ros-${ROS_DISTRO}-mc-surfaces-visualization.install + ls debian + fi + - name: Build package + uses: jrl-umi3218/github-actions/build-package-native@master + with: + dist: ${{ matrix.dist }} + arch: ${{ matrix.arch }} + ros-distro: ${{ env.ROS_DISTRO }} + other-mirrors: ${{ env.EXTRA_MIRROR }} + other-gpg-keys: "0x892EA6EE273707C6495A6FB6220D644C64666806" + - uses: actions/upload-artifact@v1 + with: + name: packages-${{ matrix.dist }}-${{ matrix.arch }} + path: ${{ env.PACKAGES_OUT }} + if: env.PACKAGE_UPLOAD == 'true' + # This job upload binary packages for Ubuntu + upload-packages: + needs: build-packages + strategy: + max-parallel: 1 + fail-fast: false + matrix: *package-matrix + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Set upload parameters + <<: *choose-extra-mirror + - name: Download packages + uses: actions/download-artifact@v1 + with: + name: packages-${{ matrix.dist }}-${{ matrix.arch }} + if: env.PACKAGE_UPLOAD == 'true' + - name: Upload + uses: jrl-umi3218/github-actions/upload-package@master + with: + dist: ${{ matrix.dist }} + arch: ${{ matrix.arch }} + subject: gergondet + repo: ${{ env.BINTRAY_REPO }} + package: | + name: mc-rtc-ros + desc: "mc_rtc tools based on the ROS framework" + licenses: [BSD 2-Clause] + vcs_url: https://github.com/jrl-umi3218/mc_rtc_ros + version: ${{ env.BINTRAY_VERSION }} + path: packages-${{ matrix.dist }}-${{ matrix.arch }} + BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + if: env.PACKAGE_UPLOAD == 'true' + # This job triggers a mirror sync and dependent rebuilds + mirror-sync: + needs: upload-packages + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Set repository parameters + <<: *choose-extra-mirror + - name: Request mirror sync + run: | + curl -ugergondet:${{ secrets.BINTRAY_API_KEY }} --header "X-GPG-PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}" -X POST https://api.bintray.com/calc_metadata/gergondet/${{ env.BINTRAY_REPO }} + if: env.PACKAGE_UPLOAD == 'true' diff --git a/.github/workflows/sources/setup.rb b/.github/workflows/sources/setup.rb new file mode 100755 index 0000000..2113ae7 --- /dev/null +++ b/.github/workflows/sources/setup.rb @@ -0,0 +1,10 @@ +#!/usr/bin/env ruby + +require "yaml" +require "json" + +data = File.open(File.expand_path("package.yml", __dir__)).read().gsub(/^on:$/, "\"on\":"); +yaml = YAML.load(data) + +out = YAML.load(yaml.to_json).to_yaml(line_width: 1024).gsub(/^'on':$/, "on:"); +File.write(File.expand_path("../package.yml", __dir__), out) diff --git a/debian/rules.ros b/debian/rules.ros index 9a5397b..6666c2b 100644 --- a/debian/rules.ros +++ b/debian/rules.ros @@ -13,7 +13,7 @@ TMP = $(CURDIR)/debian/tmp dh $@ override_dh_auto_configure: - dh_auto_configure -- -DCMAKE_INSTALL_PREFIX=/opt/ros/@ROS_DISTRO@ -DBUILD_ROS_FREE_GUI:BOOL=ON + dh_auto_configure -- -DCMAKE_INSTALL_PREFIX=/opt/ros/@ROS_DISTRO@ -DBUILD_ROS_FREE_GUI:BOOL=ON -DPYTHON_EXECUTABLE=@PYTHON_EXECUTABLE@ override_dh_auto_install: dh_auto_install --destdir=$(TMP) diff --git a/mc_log_visualization/src/mc_log_visualization.cpp b/mc_log_visualization/src/mc_log_visualization.cpp index fe9635e..8453828 100644 --- a/mc_log_visualization/src/mc_log_visualization.cpp +++ b/mc_log_visualization/src/mc_log_visualization.cpp @@ -49,7 +49,7 @@ int main(int argc, char * argv[]) auto nh = mc_rtc::ROSBridge::get_node_handle(); if(!nh) { - LOG_ERROR_AND_THROW(std::runtime_error, "Failed to initialized node handle") + mc_rtc::log::error_and_throw("Failed to initialized node handle"); } ros::NodeHandle nh_private("~"); @@ -74,13 +74,13 @@ int main(int argc, char * argv[]) } else { - LOG_ERROR_AND_THROW(std::runtime_error, "log_visualization cannot handle the robot_params it was given") + mc_rtc::log::error_and_throw("log_visualization cannot handle the robot_params it was given"); } } double dt = 0.005; getParam(nh_private, "dt", dt); - LOG_INFO("Replaying log: " << log) + mc_rtc::log::info("Replaying log: {}", log); LogPublisher appli(*nh, log, mod, dt); appli.run(); diff --git a/mc_rtc_rviz_panel/src/ArrowInteractiveMarkerWidget.cpp b/mc_rtc_rviz_panel/src/ArrowInteractiveMarkerWidget.cpp index bad75c8..7fee902 100644 --- a/mc_rtc_rviz_panel/src/ArrowInteractiveMarkerWidget.cpp +++ b/mc_rtc_rviz_panel/src/ArrowInteractiveMarkerWidget.cpp @@ -71,14 +71,14 @@ void ArrowInteractiveMarkerWidget::update(const Eigen::Vector3d & start, { if(!is_in_range(start)) { - LOG_ERROR("Could not display arrow " << id2name(id()) << ": invalid value in start coordinates (" - << start.transpose() << ")"); + mc_rtc::log::error("Could not display arrow {}: invalid value in start coordinates ({})", id2name(id()), + start.transpose()); return; } if(!is_in_range(end)) { - LOG_ERROR("Could not display arrow " << id2name(id()) << ": invalid value in end coordinates (" << end.transpose() - << ")"); + mc_rtc::log::error("Could not display arrow {}: invalid value in end coordinates ({})", id2name(id()), + end.transpose()); return; } diff --git a/mc_rtc_rviz_panel/src/DisplayTrajectoryWidget.cpp b/mc_rtc_rviz_panel/src/DisplayTrajectoryWidget.cpp index 8050e67..a611e6d 100644 --- a/mc_rtc_rviz_panel/src/DisplayTrajectoryWidget.cpp +++ b/mc_rtc_rviz_panel/src/DisplayTrajectoryWidget.cpp @@ -41,8 +41,8 @@ void DisplayTrajectoryWidget::update(const std::vector & points { if(!is_in_range(p)) { - LOG_ERROR("Could not display trajectory " << id2name(id()) << ": invalid value in coordinates (" << p.transpose() - << ")"); + mc_rtc::log::error("Could not display trajectory {}: invalid value in coordinates ({})", id2name(id()), + p.transpose()); return; } geometry_msgs::Point pose; @@ -64,8 +64,8 @@ void DisplayTrajectoryWidget::update(const std::vector & point const auto & p = point.translation(); if(!is_in_range(p)) { - LOG_ERROR("Could not display trajectory " << id2name(id()) << ": invalid value in coordinates (" << p.transpose() - << ")"); + mc_rtc::log::error("Could not display trajectory {}: invalid value in coordinates ({})", id2name(id()), + p.transpose()); return; } geometry_msgs::Point pose; @@ -82,8 +82,8 @@ void DisplayTrajectoryWidget::update(const Eigen::Vector3d & point, const mc_rtc { if(!is_in_range(point)) { - LOG_ERROR("Could not display trajectory " << id2name(id()) << ": invalid value in coordinates (" - << point.transpose() << ")"); + mc_rtc::log::error("Could not display trajectory {}: invalid value in coordinates ({})", id2name(id()), + point.transpose()); return; } geometry_msgs::Point pose; @@ -100,8 +100,8 @@ void DisplayTrajectoryWidget::update(const sva::PTransformd & point, const mc_rt const auto & p = point.translation(); if(!is_in_range(p)) { - LOG_ERROR("Could not display trajectory " << id2name(id()) << ": invalid value in coordinates (" << p.transpose() - << ")"); + mc_rtc::log::error("Could not display trajectory {}: invalid value in coordinates ({})", id2name(id()), + p.transpose()); return; } configure(config); diff --git a/mc_rtc_rviz_panel/src/Panel.cpp b/mc_rtc_rviz_panel/src/Panel.cpp index 43362cd..2900930 100644 --- a/mc_rtc_rviz_panel/src/Panel.cpp +++ b/mc_rtc_rviz_panel/src/Panel.cpp @@ -85,13 +85,13 @@ void savePanelConfiguration(const mc_rtc::Configuration & config) } if(!bfs::is_directory(config_directory)) { - LOG_ERROR("Cannot save configuration to " << config_directory << ", " << config_directory << " is not a directory") + mc_rtc::log::error("Cannot save configuration to {}, {} is not a directory", config_directory, config_directory); return; } auto config_path = getConfigPath(); if(bfs::exists(config_path) && !bfs::is_regular(config_path)) { - LOG_ERROR("Cannot save configuration to " << config_path << ", " << config_path << " is not a regular file") + mc_rtc::log::error("Cannot save configuration to {}, {} is not a regular file", config_path, config_path); return; } config.save(config_path.string()); @@ -991,7 +991,7 @@ void Panel::contextMenu_editConnection() } catch(std::runtime_error & exc) { - LOG_ERROR("Reconnection failed with provided URIs") + mc_rtc::log::error("Reconnection failed with provided URIs"); exc.what(); return; } diff --git a/mc_rtc_rviz_panel/src/PolygonMarkerWidget.cpp b/mc_rtc_rviz_panel/src/PolygonMarkerWidget.cpp index df0c5ed..2ffdf7e 100644 --- a/mc_rtc_rviz_panel/src/PolygonMarkerWidget.cpp +++ b/mc_rtc_rviz_panel/src/PolygonMarkerWidget.cpp @@ -66,7 +66,7 @@ void PolygonMarkerWidget::update(const std::string & ns, { if(!is_in_range(point)) { - LOG_ERROR("Could not display polygon " << ns << ": invalid value in coordinates (" << point.transpose() << ")"); + mc_rtc::log::error("Could not display polygon {}: invalid value in coordinates ({})", ns, point.transpose()); return; } geometry_msgs::Point p; diff --git a/mc_rtc_rviz_panel/src/Schema.cpp b/mc_rtc_rviz_panel/src/Schema.cpp index 9992403..0b206ee 100644 --- a/mc_rtc_rviz_panel/src/Schema.cpp +++ b/mc_rtc_rviz_panel/src/Schema.cpp @@ -157,8 +157,8 @@ void Schema::init(const mc_rtc::Configuration & s, { if(type != "string") { - LOG_WARNING("Property " << k << " in " << source << " has unknown or missing type (value: " << type - << "), treating as string") + mc_rtc::log::warning("Property {} in {} has unknown or missing type (value: {}), treating as string", k, source, + type); } static const std::unordered_map surface_keys = { {"surface", "$robot"}, {"r1Surface", "$r1"}, {"r2Surface", "$r2"}}; @@ -225,8 +225,9 @@ void Schema::init(const mc_rtc::Configuration & s, { if(type != "string") { - LOG_WARNING("Property " << k << " in " << source << " has unknonw or missing array items' type (value: " << type - << "), treating as string") + mc_rtc::log::warning( + "Property {} in {} has unknown or missing array items' type (value: {}), treating as string", k, source, + type); } create_form = [cf, k, required, min, max](QWidget * parent, const mc_rtc::Configuration & data) { auto v = cf(parent, data); @@ -249,7 +250,7 @@ void Schema::init(const mc_rtc::Configuration & s, const char * desc, const std::string & k, bool required, const mc_rtc::Configuration & c) { if(!c.has("items")) { - LOG_WARNING(desc << k << " in " << source << " is an array but items are not specified") + mc_rtc::log::warning("{}{} in {} is an array but items are not specified", desc, k, source); } auto items = c("items"); int minItems = c("minItems", 0); @@ -281,13 +282,13 @@ void Schema::init(const mc_rtc::Configuration & s, } else { - LOG_WARNING(desc << k << " in " << source << " is an array but items' type is not specified") + mc_rtc::log::warning("{}{} in {} is an array but items' type is not specified", desc, k, source); } }; auto handle_object = [&](const std::string & title, const mc_rtc::Configuration & schema) { if(!schema.has("properties")) { - LOG_WARNING(title << " in " << source << " is an object without properties") + mc_rtc::log::warning("{} in {} is an object without properties", title, source); return; } auto properties = schema("properties"); @@ -332,7 +333,7 @@ void Schema::init(const mc_rtc::Configuration & s, } else { - LOG_ERROR("Cannot handle property " << k << " in " << source << ": " << prop.dump()) + mc_rtc::log::error("Cannot handle property {} in {}: {}", k, source, prop.dump()); } } }; @@ -343,7 +344,7 @@ void Schema::init(const mc_rtc::Configuration & s, } if(!s.has("type")) { - LOG_ERROR("No type entry for " << title_ << " in " << source) + mc_rtc::log::error("No type entry for {} in {}", title, source); } std::string type = s("type"); if(type == "object") diff --git a/mc_rtc_rviz_panel/src/SchemaWidget.cpp b/mc_rtc_rviz_panel/src/SchemaWidget.cpp index c078e9b..1900042 100644 --- a/mc_rtc_rviz_panel/src/SchemaWidget.cpp +++ b/mc_rtc_rviz_panel/src/SchemaWidget.cpp @@ -26,7 +26,7 @@ SchemaWidget::SchemaWidget(const ClientWidgetParam & params, schema_path /= schema; if(!bfs::exists(schema_path)) { - LOG_ERROR("Schema path: " << schema_path.string() << " does not exist in this machine") + mc_rtc::log::error("Schema path: {} does not exist in this machine", schema_path.string()); return; } bfs::directory_iterator dit(schema_path), endit; diff --git a/mc_rtc_ticker/src/mc_rtc_ticker.cpp b/mc_rtc_ticker/src/mc_rtc_ticker.cpp index 02673be..20a615a 100644 --- a/mc_rtc_ticker/src/mc_rtc_ticker.cpp +++ b/mc_rtc_ticker/src/mc_rtc_ticker.cpp @@ -51,14 +51,14 @@ int main() if(nh.hasParam("mc_rtc_ticker/conf")) { conf = getParam(nh, "mc_rtc_ticker/conf"); - LOG_INFO("Configuring mc_rtc with " << conf) + mc_rtc::log::info("Configuring mc_rtc with {}", conf); } if(mc_rtc::MC_RTC_VERSION != mc_rtc::version()) { - LOG_ERROR("mc_rtc_ticker was compiled with " - << mc_rtc::MC_RTC_VERSION << " but mc_rtc is at version " << mc_rtc::version() - << ", you might face subtle issues or unexpected crashes, please recompile mc_rtc_ticker") + mc_rtc::log::error("mc_rtc_ticker was compiled with {} but mc_rtc is at version {}, you might face subtle issues " + "or unexpected crashes, please recompile mc_rtc_ticker", + mc_rtc::MC_RTC_VERSION, mc_rtc::version()); } mc_control::MCGlobalController controller(conf); @@ -93,7 +93,7 @@ int main() controller.setEncoderValues(q); if(nh.hasParam("mc_rtc_ticker/init_pos")) { - LOG_INFO("Using initial pos from ROS param") + mc_rtc::log::info("Using initial pos from ROS param"); std::vector pos = getParam>(nh, "mc_rtc_ticker/init_pos"); for(const auto & pi : pos) { @@ -110,6 +110,37 @@ int main() } controller.running = true; + bool stepByStep = getParam(nh, "mc_rtc_ticker/stepByStep", false); + size_t nextStep = 0; + auto gui = controller.controller().gui(); + auto toogleStepByStep = [&]() { + if(stepByStep) + { + stepByStep = false; + } + else + { + nextStep = 0; + stepByStep = true; + } + }; + if(gui) + { + gui->addElement({"mc_rtc_ticker"}, + mc_rtc::gui::Checkbox("Step by step", [&]() { return stepByStep; }, [&]() { toogleStepByStep(); })); + auto dt = controller.timestep(); + auto buttonText = [&](size_t n) { + size_t n_ms = std::ceil(n * 1000 * dt); + return "+" + std::to_string(n_ms) + "ms"; + }; + gui->addElement({"mc_rtc_ticker"}, mc_rtc::gui::ElementsStacking::Horizontal, + mc_rtc::gui::Button(buttonText(1), [&]() { nextStep = 1; }), + mc_rtc::gui::Button(buttonText(5), [&]() { nextStep = 5; }), + mc_rtc::gui::Button(buttonText(10), [&]() { nextStep = 10; }), + mc_rtc::gui::Button(buttonText(50), [&]() { nextStep = 20; }), + mc_rtc::gui::Button(buttonText(100), [&]() { nextStep = 100; })); + } + const bool bench = getParam(nh, "mc_rtc_ticker/bench", false); std::chrono::time_point begin, end; std::vector> solve_dt(0); @@ -170,6 +201,21 @@ int main() } }); } + + auto runController = [&]() { + controller.setEncoderValues(q); + if(controller.run() && cfp_ptr) + { + cfp_ptr->update(); + } + }; + + auto updateGUI = [&]() { + controller.running = false; + controller.run(); + controller.running = true; + }; + while(ros::ok()) { if(bench) @@ -191,10 +237,21 @@ int main() } } } - controller.setEncoderValues(q); - if(controller.run() && cfp_ptr) + if(stepByStep) { - cfp_ptr->update(); + if(nextStep > 0) + { + nextStep--; + runController(); + } + else + { + updateGUI(); + } + } + else + { + runController(); } if(bench) {