diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..93b9383c7 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,23 @@ +{ + "name": "modulo", + "remoteUser": "ros2", + "build": { + "dockerfile": "../Dockerfile", + "context": "..", + "target": "development", + "args": { "CL_VERSION": "v7.2.0" } + }, + "workspaceMount": "source=${localWorkspaceFolder},target=/home/ros2/.devcontainer,type=bind,consistency=cached", + "workspaceFolder": "/home/ros2/.devcontainer", + "mounts": [ + "source=${localWorkspaceFolder}/source,target=/home/ros2/ws/src,type=bind,consistency=cached" + ], + "customizations": { + "vscode": { + "extensions": [ + "ms-vscode.cpptools-extension-pack", + "eamodio.gitlens" + ] + } + } +} \ No newline at end of file diff --git a/.github/actions/build-test-humble-devel/action.yml b/.github/actions/build-test-humble-devel/action.yml deleted file mode 100644 index 25181c7ef..000000000 --- a/.github/actions/build-test-humble-devel/action.yml +++ /dev/null @@ -1,6 +0,0 @@ -name: 'Build and Test (humble-devel)' -description: 'Build the source packages and run all unit tests' -runs: - using: 'docker' - image: 'ghcr.io/aica-technology/ros2-control-libraries:humble-devel' - entrypoint: '/github/workspace/.github/common/entrypoint.sh' diff --git a/.github/actions/build-test-humble/action.yml b/.github/actions/build-test-humble/action.yml deleted file mode 100644 index dd9a91914..000000000 --- a/.github/actions/build-test-humble/action.yml +++ /dev/null @@ -1,6 +0,0 @@ -name: 'Build and Test (humble)' -description: 'Build the source packages and run all unit tests' -runs: - using: 'docker' - image: 'ghcr.io/aica-technology/ros2-control-libraries:humble' - entrypoint: '/github/workspace/.github/common/entrypoint.sh' diff --git a/.github/common/build-test.sh b/.github/common/build-test.sh deleted file mode 100755 index 13d7d7863..000000000 --- a/.github/common/build-test.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -STEP=1 -build_and_test() { - PACKAGE=$1 - - echo ">>> ${STEP}: Building ${PACKAGE}..." - cp -r /github/workspace/source/"${PACKAGE}" ./src/"${PACKAGE}" - if ! colcon build --packages-select "${PACKAGE}"; then - echo ">>> [ERROR] Build stage ${STEP} failed!" - exit "${STEP}" - fi - echo ">>> Build stage ${STEP} completed successfully!" - STEP=$((STEP+1)) - - echo ">>> ${STEP}: Testing ${PACKAGE}..." - if ! colcon test --packages-select "${PACKAGE}" --return-code-on-test-failure; then - colcon test-result --verbose - echo ">>> [ERROR] Test stage ${STEP} failed!" - exit "${STEP}" - fi - echo ">>> Test stage ${STEP} completed successfully!" - STEP=$((STEP+1)) -} - -source /opt/ros/"${ROS_DISTRO}"/setup.bash -cd /home/ros2/ros2_ws - -build_and_test modulo_component_interfaces -build_and_test modulo_utils -build_and_test modulo_core -build_and_test modulo_components - -echo ">>> All build and test stages completed successfully!" -exit 0 diff --git a/.github/common/entrypoint.sh b/.github/common/entrypoint.sh deleted file mode 100755 index a2d20c182..000000000 --- a/.github/common/entrypoint.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -sudo su - ros2 -c /bin/bash -c /github/workspace/.github/common/build-test.sh diff --git a/.github/workflows/build-release.yaml b/.github/workflows/build-release.yaml index 96f792d7c..ad910835a 100644 --- a/.github/workflows/build-release.yaml +++ b/.github/workflows/build-release.yaml @@ -46,7 +46,6 @@ jobs: with: image_name: aica-technology/modulo image_tags: ${{ steps.merge-tags.outputs.list }} - dockerfile_path: Dockerfile.ci token: ${{ secrets.GITHUB_TOKEN }} multi-arch: diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index bf890ebb1..73953132f 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -1,40 +1,31 @@ name: Build and Test -# Run workflow on pushes to main and develop branches, on any pull request, or by manual dispatch on: - push: - branches: - - main - - develop pull_request: workflow_dispatch: -# Define the build test jobs jobs: - - check-contribution: + check: name: Check if changelog and version have been updated runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - - name: Check contributions - if: ${{ github.event.pull_request.base.sha }} + - name: Check changelog run: | git fetch origin main ${{ github.event.pull_request.base.sha }} VER_DIFF=$(git diff ${{ github.event.pull_request.base.sha }} ${{ github.sha }} -- ./VERSION) if ! [ "${VER_DIFF}" ]; then - echo "::warning title=Contribution check failed::VERSION must be updated!" + echo "::warning title=Version check failed::VERSION must be updated!" exit 1 fi CL_DIFF=$(git diff ${{ github.event.pull_request.base.sha }} ${{ github.sha }} -- ./CHANGELOG.md) if ! [ "${CL_DIFF}" ]; then - echo "::warning title=Contribution check failed::CHANGELOG.md must be updated!" + echo "::warning title=CHEANGELOG check failed::CHANGELOG.md must be updated!" exit 1 fi shell: bash - # check if jobs can be skipped check-skippable-changes: name: Check skippable changes runs-on: ubuntu-latest @@ -49,28 +40,17 @@ jobs: paths_ignore: '["**.md"]' skip_after_successful_duplicate: 'true' - build-test-humble: + test: needs: check-skippable-changes if: ${{ needs.check-skippable-changes.outputs.skip != 'true' }} runs-on: ubuntu-latest - name: Humble build and test + name: Run tests steps: - # First check out the repository - - name: Checkout + - name: Checkout repository uses: actions/checkout@v3 - # Load the repository build-test action - - name: Build and Test - uses: ./.github/actions/build-test-humble - build-test-humble-devel: - needs: check-skippable-changes - if: ${{ needs.check-skippable-changes.outputs.skip != 'true' }} - runs-on: ubuntu-latest - name: Humble development build and test - steps: - # First check out the repository - - name: Checkout - uses: actions/checkout@v2 - # Load the repository build-test action - - name: Build and Test - uses: ./.github/actions/build-test-humble-devel \ No newline at end of file + - name: Test + run: | + DOCKER_BUILDKIT=1 docker build --target test . + shell: bash + \ No newline at end of file diff --git a/.gitignore b/.gitignore index 603364d8b..0dbd1beda 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ .idea cmake-build-* ./fileList.txt +build doxygen/docs/html diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 000000000..d490efeac --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,20 @@ +{ + "configurations": [ + { + "name": "AMD", + "includePath": [ + "/opt/ros/humble/include/**", + "/home/ros2/ros2_ws/install/**", + "/home/ros2/ws/install/**", + "/home/ros2/ws/src/modulo_utils/include", + "/home/ros2/ws/src/modulo_core/include", + "/home/ros2/ws/src/modulo_components/include" + ], + "compilerPath": "/usr/bin/gcc", + "cStandard": "c17", + "cppStandard": "gnu++17", + "intelliSenseMode": "linux-gcc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..00a610035 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "C_Cpp.clang_format_style": "file:/home/ros2/.clang-format", + "cmake.sourceDirectory": "/home/ros2/ws/src/modulo_components", +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 85cb2b36a..97617e800 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,29 @@ Release Versions: +- [3.1.0](#300) - [3.0.0](#300) - [2.3.0](#230) - [2.2.0](#220) - [2.1.1](#211) - [2.1.0](#210) +## 3.1.0 + +### September 27, 2023 + +Version 3.1.0 is a minor update to modulo with a new feature in the components and it marks the first official version +that uses `iron` as its ROS2 distribution. + +### Features + +- Add the on_step_callback for components (#51) + +### Behind the scenes + +- Revise test stage to fail on test errors (#48) +- Unify dockerfiles and add vs code configuration (#50) +- Use iron as ros2 distro (#53) +- Change test workflow to docker build (#55) ## 3.0.0 diff --git a/source/modulo_components/CONTRIBUTING.md b/CONTRIBUTING.md similarity index 57% rename from source/modulo_components/CONTRIBUTING.md rename to CONTRIBUTING.md index 27f5cd4b5..53975c37f 100644 --- a/source/modulo_components/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,4 +26,23 @@ Similar to the exceptions, the logging of debug, info, and error messages should - Methods that catch an exception and are not allow to rethrow, log an error with the exception message - `add_xxx` methods use non-throttled logging - Setters and getters as well as all other methods that are expected to be called at a high frequency use throttled - logging \ No newline at end of file + logging + + +## Development Environment + +Our development and testing workflow uses a Docker container to host the project build dependencies. + +The following section describes the configuration steps to use this workflow. Of course, contributors may use whatever +development environment they prefer, as long as they adhere to the overall contribution guidelines. + +### Configuring the development environment + +Prerequisites: Install Docker and Visual Studio Code. + +Step 1: Open VS Code and install the [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension. + +Step 2: Use **Dev Containers: Open Folder in Container...** from the command palette and select this directory. + +Step 3: The CMake profile should be automatically selected, now you can run and debug library and test targets entirely +with the devcontainer toolchain. \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 012b0d11f..ead4f5a2e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,56 @@ -ARG BASE_TAG=humble -FROM ghcr.io/aica-technology/ros2-control-libraries:${BASE_TAG} as dependencies -WORKDIR ${HOME}/ros2_ws - - -FROM dependencies as modulo-component-interfaces - -COPY --chown=${USER} ./source/modulo_component_interfaces ./src/modulo_component_interfaces -COPY --chown=${USER} ./source/modulo_utils ./src/modulo_utils -RUN /bin/bash -c "source /opt/ros/$ROS_DISTRO/setup.bash; colcon build" - - -FROM modulo-component-interfaces as modulo-core - -COPY --chown=${USER} ./source/modulo_core ./src/modulo_core -RUN /bin/bash -c "source /opt/ros/$ROS_DISTRO/setup.bash; colcon build --packages-select modulo_core" - - -FROM modulo-core as modulo-components - -COPY --chown=${USER} ./source/modulo_components ./src/modulo_components -RUN /bin/bash -c "source /opt/ros/$ROS_DISTRO/setup.bash; colcon build --packages-select modulo_components" - -# clean image -RUN sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/* +#syntax=docker/dockerfile:1.4.0 +ARG CL_VERSION=v7.2.0 +ARG ROS2_VERSION=iron +FROM ghcr.io/aica-technology/control-libraries:${CL_VERSION} as cl +FROM ghcr.io/aica-technology/ros2-ws:${ROS2_VERSION} as base +# setup the environment +USER ${USER} +ENV WORKSPACE ${HOME}/ws +WORKDIR ${WORKSPACE} +SHELL ["/bin/bash", "-l", "-c"] + +# create a workspace +RUN source ${HOME}/ros2_ws/install/setup.bash && colcon build +# source the new workspace on login +RUN echo "source ${WORKSPACE}/install/setup.bash" | cat - ${HOME}/.bashrc > tmp && mv tmp ${HOME}/.bashrc +# install deps +COPY --from=cl / / +# install sources +COPY --chown=${USER}:${USER} ./source ${WORKSPACE}/src + +FROM base as utils-development +ARG TARGETPLATFORM +ARG CACHEID +RUN --mount=type=cache,target=./build,id=${TARGETPLATFORM}-${CACHEID},uid=1000 \ + colcon build --packages-select modulo_component_interfaces + +FROM utils-development as core-development +ARG TARGETPLATFORM +ARG CACHEID +RUN --mount=type=cache,target=./build,id=${TARGETPLATFORM}-${CACHEID},uid=1000 \ + colcon build --packages-select modulo_utils + +FROM core-development as development +ARG TARGETPLATFORM +ARG CACHEID +RUN --mount=type=cache,target=./build,id=${TARGETPLATFORM}-${CACHEID},uid=1000 \ + colcon build --packages-select modulo_core + +FROM base as build +ARG TARGETPLATFORM +ARG CACHEID +RUN --mount=type=cache,target=./build,id=${TARGETPLATFORM}-${CACHEID},uid=1000 \ + sudo apt-get update && rosdep update \ + && rosdep install --from-paths src --ignore-src -r -y \ + --skip-keys "ros2_control ros2_controllers controller_interface hardware_interface controller_manager" \ + && sudo rm -rf /var/lib/apt/lists/* \ + && colcon build + +FROM build as test +ARG TARGETPLATFORM +ARG CACHEID +RUN --mount=type=cache,target=./build,id=${TARGETPLATFORM}-${CACHEID},uid=1000 \ + colcon test && colcon test-result --verbose + +FROM scratch as production +COPY --from=build /home/ros2/ws/install /colcon diff --git a/Dockerfile.ci b/Dockerfile.ci deleted file mode 100644 index 2d5eaf8ce..000000000 --- a/Dockerfile.ci +++ /dev/null @@ -1,37 +0,0 @@ -#syntax=docker/dockerfile:1.4.0 -ARG CL_VERSION=v7.1.0 -ARG ROS2_VERSION=humble -FROM ghcr.io/aica-technology/control-libraries:${CL_VERSION} as cl -FROM ghcr.io/aica-technology/ros2-ws:${ROS2_VERSION} as base -# setup the environment -USER ${USER} -ENV WORKSPACE ${HOME}/ws -WORKDIR ${WORKSPACE} -SHELL ["/bin/bash", "-l", "-c"] - -# create a workspace -RUN source ${HOME}/ros2_ws/install/setup.bash && colcon build -# source the new workspace on login -RUN echo "source ${WORKSPACE}/install/setup.bash" | cat - ${HOME}/.bashrc > tmp && mv tmp ${HOME}/.bashrc -# install deps -COPY --from=cl / / -# install sources -COPY --chown=${USER}:${USER} ./source ${WORKSPACE}/src - -FROM base as development - -FROM base as build -ARG TARGETPLATFORM -RUN --mount=type=cache,target=./build,id=${TARGETPLATFORM},uid=1000 \ - sudo apt-get update && rosdep update \ - && rosdep install --from-paths src --ignore-src -r -y \ - --skip-keys "ros2_control ros2_controllers controller_interface hardware_interface controller_manager" \ - && sudo rm -rf /var/lib/apt/lists/* \ - && colcon build - -FROM build as test -ARG TARGETPLATFORM -RUN --mount=type=cache,target=./build,id=${TARGETPLATFORM},uid=1000 colcon test - -FROM scratch as production -COPY --from=build /home/ros2/ws/install /colcon diff --git a/VERSION b/VERSION index 4a36342fc..fd2a01863 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.0.0 +3.1.0 diff --git a/build-server.sh b/build-server.sh deleted file mode 100755 index 9290ad4a6..000000000 --- a/build-server.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -BASE_TAG=humble-devel - -IMAGE_NAME=aica-technology/modulo -IMAGE_TAG=latest - -REMOTE_SSH_PORT=4440 -SERVE_REMOTE=false - -HELP_MESSAGE="Usage: build.sh [-p] [-r] -Options: - -d, --development Only target the dependencies layer to prevent - sources from being built or tested - - -c, --core Only target the modulo core layer to prevent - modulo components from being built or tested - - -r, --rebuild Rebuild the image using the docker - --no-cache option - - -v, --verbose Use the verbose option during the building - process - - -s, --serve Start the remove development server -" - -BUILD_FLAGS=(--build-arg BASE_TAG="${BASE_TAG}") -while [[ $# -gt 0 ]]; do - opt="$1" - case $opt in - -d|--development) BUILD_FLAGS+=(--target dependencies) ; IMAGE_TAG=development ; shift ;; - -c|--core) BUILD_FLAGS+=(--target modulo-core) ; IMAGE_TAG=development ; shift ;; - -r|--rebuild) BUILD_FLAGS+=(--no-cache) ; shift ;; - -v|--verbose) BUILD_FLAGS+=(--progress=plain) ; shift ;; - -s|--serve) SERVE_REMOTE=true ; shift ;; - -h|--help) echo "${HELP_MESSAGE}" ; exit 0 ;; - *) echo 'Error in command line parsing' >&2 - echo -e "\n${HELP_MESSAGE}" - exit 1 - esac -done - -docker pull ghcr.io/aica-technology/ros2-control-libraries:"${BASE_TAG}" -DOCKER_BUILDKIT=1 docker build -t "${IMAGE_NAME}:${IMAGE_TAG}" "${BUILD_FLAGS[@]}" . || exit 1 - -if [[ "${SERVE_REMOTE}" == true ]]; then - aica-docker server "${IMAGE_NAME}:${IMAGE_TAG}" -u ros2 -p "${REMOTE_SSH_PORT}" -fi \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 000000000..dca14ae30 --- /dev/null +++ b/build.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +IMAGE_NAME=ghcr.io/aica-technology/modulo +IMAGE_TAG=latest + +ROS2_VERSION=iron +CL_VERSION=v7.2.0 + +SSH_PORT=4440 + +HELP_MESSAGE="Usage: build.sh [options] +Options: + --test Target the test layer to run the tests. + + -s|--serve Start the remote development server on port $SSH_PORT. + + --cl-version Specify the version of the control libraries image to use. + (default: $CL_VERSION) + + --ros2-version Specify the version of ROS 2 to use. + (default: $ROS2_VERSION) + + --tag Specify the tag of the generated image. + (default: $IMAGE_TAG) + + -v|--verbose Set the build output to verbose. + + --cache-id Invalidate the mount cache (e.g. CMake build folder) + by providing a new value. + + -r|--no-cache Invalidate all cache (layer + mount). + + -h|--help Show this help message. +" + +TEST=0 +SERVE_REMOTE=0 +BUILD_FLAGS=() +while [ "$#" -gt 0 ]; do + case "$1" in + --test) BUILD_FLAGS+=(--target=test); TEST=1; IMAGE_TAG=test; shift 1;; + -s|--serve) BUILD_FLAGS+=(--target build); SERVE_REMOTE=1; IMAGE_TAG=build; shift 1;; + --cl-version) CL_VERSION=$2; shift 2;; + --ros2-version) ROS2_VERSION=$2; shift 2;; + --tag) IMAGE_TAG=$2; shift 2;; + -v|--verbose) BUILD_FLAGS+=(--progress=plain); shift 1;; + --cache-id) BUILD_FLAGS+=(--build-arg CACHEID=$2); shift 2;; + -r|--no-cache) BUILD_FLAGS+=(--no-cache); BUILD_FLAGS+=(--build-arg CACHEID=$(date +%s)); shift 1;; + -h|--help) echo "$HELP_MESSAGE"; exit 0;; + -*) echo "Unknown option: $1" >&2; echo "$HELP_MESSAGE"; exit 1;; + esac +done + +if [ "$((TEST + SERVE_REMOTE))" -gt 1 ]; then + echo "Error in command line arguments:" >&2 + echo "--test and --serve options are mutually exclusive." >&2 + exit 1 +fi + +BUILD_FLAGS+=(--build-arg CL_VERSION="${CL_VERSION}") +BUILD_FLAGS+=(--build-arg ROS2_VERSION="${ROS2_VERSION}") +BUILD_FLAGS+=(-t "${IMAGE_NAME}:${IMAGE_TAG}") + +DOCKER_BUILDKIT=1 docker build "${BUILD_FLAGS[@]}" . || exit 1 + +if [ "${SERVE_REMOTE}" -eq 1 ]; then + aica-docker server "${IMAGE_NAME}:${IMAGE_TAG}" --user ros2 --port ${SSH_PORT} +fi diff --git a/doxygen/doxygen.conf b/doxygen/doxygen.conf index 46b2bb4e4..5585bb895 100644 --- a/doxygen/doxygen.conf +++ b/doxygen/doxygen.conf @@ -38,8 +38,7 @@ PROJECT_NAME = "Modulo" # could be handy for archiving the generated documentation or if some version # control system is used. - -PROJECT_NUMBER = 3.0.0 +PROJECT_NUMBER = 3.1.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/source/modulo_component_interfaces/README.md b/source/modulo_component_interfaces/README.md index 5388a79a0..fe5ed609f 100644 --- a/source/modulo_component_interfaces/README.md +++ b/source/modulo_component_interfaces/README.md @@ -2,6 +2,15 @@ This package defines custom standard interfaces for modulo components. +## Messages + +Modulo component classes broadcast predicates to a global channel in a predicate message. + +### Predicate + +The predicate message contains the component name, the predicate name, and the current value (true or false) of the +predicate. + ## Services Modulo component classes provide a simplified method to add services which trigger a pre-defined callback function. diff --git a/source/modulo_component_interfaces/package.xml b/source/modulo_component_interfaces/package.xml index e411084ce..7b9a231f1 100644 --- a/source/modulo_component_interfaces/package.xml +++ b/source/modulo_component_interfaces/package.xml @@ -2,7 +2,7 @@ modulo_component_interfaces - 3.0.0 + 3.1.0 Interface package for communicating with modulo components through the ROS framework Enrico Eberhard GPLv3 diff --git a/source/modulo_components/include/modulo_components/ComponentInterface.hpp b/source/modulo_components/include/modulo_components/ComponentInterface.hpp index 151aef7fd..b9d9eef2d 100644 --- a/source/modulo_components/include/modulo_components/ComponentInterface.hpp +++ b/source/modulo_components/include/modulo_components/ComponentInterface.hpp @@ -99,6 +99,11 @@ class ComponentInterface : public NodeT { */ virtual void step(); + /** + * @brief Steps to execute periodically. To be redefined by derived Component classes. + */ + virtual void on_step_callback(); + /** * @brief Add a parameter. * @details This method stores a pointer reference to an existing Parameter object in the local parameter map and @@ -609,6 +614,9 @@ ComponentInterface::ComponentInterface( template inline void ComponentInterface::step() {} +template +inline void ComponentInterface::on_step_callback() {} + template template inline void ComponentInterface::add_parameter( diff --git a/source/modulo_components/include/modulo_components/LifecycleComponent.hpp b/source/modulo_components/include/modulo_components/LifecycleComponent.hpp index 744e56808..3e8be7c72 100644 --- a/source/modulo_components/include/modulo_components/LifecycleComponent.hpp +++ b/source/modulo_components/include/modulo_components/LifecycleComponent.hpp @@ -94,11 +94,6 @@ class LifecycleComponent : public ComponentInterface::evaluate_periodic_callbacks; }; -inline void LifecycleComponent::on_step_callback() {} - template inline void LifecycleComponent::add_output( const std::string& signal_name, const std::shared_ptr& data, const std::string& default_topic, diff --git a/source/modulo_components/modulo_components/component.py b/source/modulo_components/modulo_components/component.py index d3279c7ed..f178eb90d 100644 --- a/source/modulo_components/modulo_components/component.py +++ b/source/modulo_components/modulo_components/component.py @@ -30,6 +30,7 @@ def _step(self): """ try: self._evaluate_periodic_callbacks() + self.on_step_callback() self._publish_outputs() self._publish_predicates() except Exception as e: diff --git a/source/modulo_components/modulo_components/component_interface.py b/source/modulo_components/modulo_components/component_interface.py index 02bc02538..b6c222e2c 100644 --- a/source/modulo_components/modulo_components/component_interface.py +++ b/source/modulo_components/modulo_components/component_interface.py @@ -72,6 +72,12 @@ def _step(self) -> None: Step function that is called periodically. """ pass + + def on_step_callback(self): + """ + Steps to execute periodically. To be redefined by derived classes. + """ + pass def add_parameter(self, parameter: Union[str, sr.Parameter], description: str, read_only=False) -> None: """ diff --git a/source/modulo_components/modulo_components/lifecycle_component.py b/source/modulo_components/modulo_components/lifecycle_component.py index 79c44faa4..41c4e9bc6 100644 --- a/source/modulo_components/modulo_components/lifecycle_component.py +++ b/source/modulo_components/modulo_components/lifecycle_component.py @@ -307,12 +307,6 @@ def _step(self): self.get_logger().error(f"Failed to execute step function: {e}", throttle_duration_sec=1.0) # TODO handle error in lifecycle component - def on_step_callback(self): - """ - Steps to execute periodically. To be redefined by derived classes. - """ - pass - def __configure_outputs(self) -> bool: """ Configure all outputs. diff --git a/source/modulo_components/package.xml b/source/modulo_components/package.xml index 247f6386c..fc43ca178 100644 --- a/source/modulo_components/package.xml +++ b/source/modulo_components/package.xml @@ -2,7 +2,7 @@ modulo_components - 3.0.0 + 3.1.0 Modulo base classes that wrap ROS2 Nodes as modular components for the AICA application framework Baptiste Busch Enrico Eberhard diff --git a/source/modulo_components/src/Component.cpp b/source/modulo_components/src/Component.cpp index 5106d9568..23ea7bea7 100644 --- a/source/modulo_components/src/Component.cpp +++ b/source/modulo_components/src/Component.cpp @@ -12,6 +12,7 @@ Component::Component(const rclcpp::NodeOptions& node_options, const std::string& void Component::step() { try { this->evaluate_periodic_callbacks(); + this->on_step_callback(); this->publish_outputs(); this->publish_predicates(); } catch (const std::exception& ex) { diff --git a/source/modulo_core/package.xml b/source/modulo_core/package.xml index 110b007b2..6ffba21eb 100644 --- a/source/modulo_core/package.xml +++ b/source/modulo_core/package.xml @@ -2,7 +2,7 @@ modulo_core - 3.0.0 + 3.1.0 Modulo Core communication and translation utilities for interoperability with AICA Control Libraries Baptiste Busch Enrico Eberhard diff --git a/source/modulo_utils/package.xml b/source/modulo_utils/package.xml index b758a1ec3..e449ae2e1 100644 --- a/source/modulo_utils/package.xml +++ b/source/modulo_utils/package.xml @@ -2,7 +2,7 @@ modulo_utils - 3.0.0 + 3.1.0 Modulo utils package for shared test fixtures Dominic Reber GPLv3