├── .clang-format ├── .clangformatignore ├── .github ├── CODEOWNERS └── workflows │ ├── build_humble.yaml │ ├── build_jazzy.yaml │ ├── build_rolling.yaml │ └── generate_doc.yaml ├── .gitignore ├── CMakeLists.txt ├── COMMUNICATION.md ├── CONTRIBUTING.md ├── Doxyfile ├── LICENSE ├── README.rst ├── ci ├── apt-packages.sh ├── build_doc.sh └── install_dependencies.sh ├── config ├── adis1646x │ └── imu_config.yaml ├── adis1647x │ └── imu_config.yaml ├── adis1650x │ └── imu_config.yaml ├── adis1654x │ └── imu_config.yaml ├── adis1655x │ └── imu_config.yaml └── adis1657x │ └── imu_config.yaml ├── doc ├── Makefile ├── conf.py ├── images │ ├── adis16467_1_rpi.jpg │ ├── adis16505_2_rpi.jpg │ ├── architecture_local_client.png │ └── architecture_remote_client.png ├── make.bat └── requirements.txt ├── include └── adi_imu │ ├── accelgyrotemp_data_provider.h │ ├── accelgyrotemp_data_provider_interface.h │ ├── accelgyrotemp_ros_publisher.h │ ├── accelgyrotemp_ros_publisher_interface.h │ ├── adis1646x │ └── adis1646x_data_access.h │ ├── adis1647x │ └── adis1647x_data_access.h │ ├── adis1650x │ └── adis1650x_data_access.h │ ├── adis1654x │ └── adis1654x_data_access.h │ ├── adis1655x │ └── adis1655x_data_access.h │ ├── adis1657x │ └── adis1657x_data_access.h │ ├── adis_data_access.h │ ├── iio_wrapper.h │ ├── imu_control_parameters.h │ ├── imu_data_provider.h │ ├── imu_data_provider_interface.h │ ├── imu_diag_data_provider.h │ ├── imu_diag_data_provider_interface.h │ ├── imu_diag_ros_publisher.h │ ├── imu_diag_ros_publisher_interface.h │ ├── imu_full_measured_data_provider.h │ ├── imu_full_measured_data_provider_interface.h │ ├── imu_full_measured_data_ros_publisher.h │ ├── imu_full_measured_data_ros_publisher_interface.h │ ├── imu_identification_data_provider.h │ ├── imu_identification_data_provider_interface.h │ ├── imu_identification_ros_publisher.h │ ├── imu_identification_ros_publisher_interface.h │ ├── imu_ros_publisher.h │ ├── imu_ros_publisher_interface.h │ ├── ros_publisher_group.h │ ├── ros_publisher_group_interface.h │ ├── ros_task.h │ ├── velangtemp_data_provider.h │ ├── velangtemp_data_provider_interface.h │ ├── velangtemp_ros_publisher.h │ ├── velangtemp_ros_publisher_interface.h │ └── worker_thread.h ├── launch ├── imu_tof_fusion.launch.py └── imu_with_madgwick_filter_rviz.launch.py ├── msg ├── AccelGyroTempData.msg ├── ImuFullMeasuredData.msg ├── ImuIdentificationData.msg ├── VelAngTempData.msg ├── adis1646x │ └── ImuDiagData.msg ├── adis1647x │ └── ImuDiagData.msg ├── adis1650x │ └── ImuDiagData.msg ├── adis1654x │ └── ImuDiagData.msg ├── adis1655x │ └── ImuDiagData.msg └── adis1657x │ └── ImuDiagData.msg ├── package.xml ├── rviz ├── imu_tof_fusion.rviz └── imu_with_madgwick_filter_rviz.rviz ├── scripts └── format.sh ├── src ├── accelgyrotemp_data_provider.cpp ├── accelgyrotemp_ros_publisher.cpp ├── iio_wrapper.cpp ├── imu_control_parameters.cpp ├── imu_data_provider.cpp ├── imu_diag_data_provider.cpp ├── imu_diag_ros_publisher.cpp ├── imu_full_measured_data_provider.cpp ├── imu_full_measured_data_ros_publisher.cpp ├── imu_identification_data_provider.cpp ├── imu_identification_ros_publisher.cpp ├── imu_ros2_node.cpp ├── imu_ros_publisher.cpp ├── ros_publisher_group.cpp ├── velangtemp_data_provider.cpp ├── velangtemp_ros_publisher.cpp └── worker_thread.cpp └── test ├── CMakeLists.txt ├── package.xml ├── src ├── accelgyrotemp_subscriber_test.cpp ├── imu_diag_subscriber_test.cpp ├── imu_full_measured_data_subscriber_test.cpp ├── imu_identification_subscriber_test.cpp ├── imu_subscriber_test.cpp ├── utest.cpp └── velangtemp_subscriber_test.cpp └── utest_launch.test /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: Google 4 | 5 | AccessModifierOffset: -2 6 | AlignAfterOpenBracket: AlwaysBreak 7 | BraceWrapping: 8 | AfterClass: true 9 | AfterFunction: true 10 | AfterNamespace: true 11 | AfterStruct: true 12 | AfterEnum: true 13 | BreakBeforeBraces: Custom 14 | ColumnLimit: 100 15 | ConstructorInitializerIndentWidth: 0 16 | ContinuationIndentWidth: 2 17 | DerivePointerAlignment: false 18 | PointerAlignment: Middle 19 | ReflowComments: false 20 | ... 21 | -------------------------------------------------------------------------------- /.clangformatignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/analogdevicesinc/imu_ros2/637372fc00b2962330fe3a8ca44ccd8d3e1de8d7/.clangformatignore -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # This file contains code owners for the imu-ros2 project 2 | 3 | # The following are the global code owners which will be responsible for all 4 | # files in the repository. 5 | 6 | * @adisuciu @Adrian-Stanea @rbolboac @rbudai98 @SeptimiuVana -------------------------------------------------------------------------------- /.github/workflows/build_humble.yaml: -------------------------------------------------------------------------------- 1 | name: Build ROS2 package 2 | 3 | env: 4 | DEVICE_ID: adis16505-2 5 | PACKAGE_NAME: "adi_imu" 6 | 7 | on: 8 | workflow_dispatch: 9 | pull_request: 10 | merge_group: 11 | push: 12 | branches: 13 | - humble* 14 | - main 15 | 16 | jobs: 17 | build-package: 18 | name: ROS ${{ matrix.ros_distribution }} 19 | runs-on: ubuntu-latest 20 | strategy: 21 | fail-fast: false 22 | matrix: 23 | ros_distribution: 24 | - humble 25 | include: 26 | # Humble Hawksbill (May 2022 - May 2027) - Ubuntu 22.04 (Jammy) 27 | - docker_image: ubuntu:jammy 28 | ros_distribution: humble 29 | ros_version: 2 30 | 31 | container: 32 | image: ${{ matrix.docker_image }} 33 | 34 | steps: 35 | - name: Setup workspace 36 | run: mkdir -p ros_ws/src 37 | 38 | - name: Checkout code 39 | uses: actions/checkout@v4 40 | with: 41 | path: ros2_ws/src 42 | 43 | - name: Setup ROS environment 44 | uses: ros-tooling/setup-ros@v0.7 45 | with: 46 | required-ros-distributions: ${{ matrix.ros_distribution }} 47 | use-ros2-testing: false 48 | 49 | - name: Build the package 50 | id: action_ros_ci_step 51 | uses: ros-tooling/action-ros-ci@v0.4 52 | with: 53 | package-name: ${{ env.PACKAGE_NAME }} 54 | target-ros2-distro: ${{ matrix.ros_distribution }} 55 | skip-tests: true # TODO: Enable tests if any (TBD) 56 | import-token: ${{ secrets.GITHUB_TOKEN }} 57 | 58 | - name: Store the build logs 59 | uses: actions/upload-artifact@v4 60 | with: 61 | name: colcon-logs 62 | path: ${{ steps.action_ros_ci_step.outputs.ros-workspace-directory-name }}/log 63 | if: always() # upload the logs even when the build fails 64 | -------------------------------------------------------------------------------- /.github/workflows/build_jazzy.yaml: -------------------------------------------------------------------------------- 1 | name: Build ROS2 package 2 | 3 | env: 4 | DEVICE_ID: adis16505-2 5 | PACKAGE_NAME: "adi_imu" 6 | # Builds the package for the Jazzy distribution using the source code from the humble branch. 7 | DEV_BRANCH: "humble" 8 | 9 | on: 10 | push: 11 | branches: 12 | - jazzy* 13 | schedule: 14 | - cron: '0 0 * * 0' 15 | 16 | jobs: 17 | build-package: 18 | name: ROS ${{ matrix.ros_distribution }} 19 | runs-on: ubuntu-latest 20 | strategy: 21 | fail-fast: false 22 | matrix: 23 | ros_distribution: 24 | - jazzy 25 | include: 26 | # Jazzy Jalisco (May 2024 - May 2029) 27 | - docker_image: ubuntu:noble 28 | ros_distribution: jazzy 29 | ros_version: 2 30 | 31 | container: 32 | image: ${{ matrix.docker_image }} 33 | 34 | steps: 35 | - name: Setup workspace 36 | run: mkdir -p ros_ws/src 37 | 38 | - name: Checkout code 39 | uses: actions/checkout@v4 40 | with: 41 | path: ros2_ws/src 42 | 43 | - name: Setup ROS environment 44 | uses: ros-tooling/setup-ros@v0.7 45 | with: 46 | required-ros-distributions: ${{ matrix.ros_distribution }} 47 | use-ros2-testing: false 48 | 49 | - name: Build the package 50 | id: action_ros_ci_step 51 | uses: ros-tooling/action-ros-ci@v0.4 52 | with: 53 | package-name: ${{ env.PACKAGE_NAME }} 54 | target-ros2-distro: ${{ matrix.ros_distribution }} 55 | skip-tests: true # TODO: Enable tests if any (TBD) 56 | import-token: ${{ secrets.GITHUB_TOKEN }} 57 | ref: ${{ env.DEV_BRANCH }} 58 | 59 | - name: Store the build logs 60 | uses: actions/upload-artifact@v4 61 | with: 62 | name: colcon-logs 63 | path: ${{ steps.action_ros_ci_step.outputs.ros-workspace-directory-name }}/log 64 | if: always() # upload the logs even when the build fails 65 | -------------------------------------------------------------------------------- /.github/workflows/build_rolling.yaml: -------------------------------------------------------------------------------- 1 | name: Build ROS2 package 2 | 3 | env: 4 | DEVICE_ID: adis16505-2 5 | PACKAGE_NAME: "adi_imu" 6 | # Builds the package for the Rolling distribution using the source code from the humble branch. 7 | DEV_BRANCH: "humble" 8 | 9 | on: 10 | push: 11 | branches: 12 | - rolling* 13 | schedule: 14 | - cron: '0 0 * * 0' 15 | 16 | jobs: 17 | build-package: 18 | name: ROS ${{ matrix.ros_distribution }} 19 | runs-on: ubuntu-latest 20 | strategy: 21 | fail-fast: false 22 | matrix: 23 | ros_distribution: 24 | - rolling 25 | include: 26 | # Rolling Ridley (No End-Of-Life) 27 | - docker_image: ubuntu:noble 28 | ros_distribution: rolling 29 | ros_version: 2 30 | 31 | container: 32 | image: ${{ matrix.docker_image }} 33 | 34 | steps: 35 | - name: Setup workspace 36 | run: mkdir -p ros_ws/src 37 | 38 | - name: Checkout code 39 | uses: actions/checkout@v4 40 | with: 41 | path: ros2_ws/src 42 | 43 | - name: Setup ROS environment 44 | uses: ros-tooling/setup-ros@v0.7 45 | with: 46 | required-ros-distributions: ${{ matrix.ros_distribution }} 47 | use-ros2-testing: false 48 | 49 | - name: Build the package 50 | id: action_ros_ci_step 51 | uses: ros-tooling/action-ros-ci@v0.4 52 | with: 53 | package-name: ${{ env.PACKAGE_NAME }} 54 | target-ros2-distro: ${{ matrix.ros_distribution }} 55 | skip-tests: true # TODO: Enable tests if any (TBD) 56 | import-token: ${{ secrets.GITHUB_TOKEN }} 57 | ref: ${{ env.DEV_BRANCH }} 58 | 59 | - name: Store the build logs 60 | uses: actions/upload-artifact@v4 61 | with: 62 | name: colcon-logs 63 | path: ${{ steps.action_ros_ci_step.outputs.ros-workspace-directory-name }}/log 64 | if: always() # upload the logs even when the build fails 65 | -------------------------------------------------------------------------------- /.github/workflows/generate_doc.yaml: -------------------------------------------------------------------------------- 1 | name: Generate documentation 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: 7 | - humble 8 | - jazzy 9 | - rolling 10 | 11 | jobs: 12 | build-doc: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v4 17 | 18 | - uses: actions/setup-python@v5 19 | with: 20 | python-version: "3.x" 21 | 22 | - name: Install pip packages 23 | working-directory: doc 24 | run: | 25 | pip install pip --upgrade 26 | pip install -r requirements.txt 27 | 28 | - name: Build doc 29 | working-directory: ci 30 | run: | 31 | ./build_doc.sh 32 | 33 | - name: Store the generated doc 34 | uses: actions/upload-artifact@v4 35 | with: 36 | name: html 37 | path: _build/docs_output/adi_imu 38 | 39 | deploy-doc: 40 | runs-on: ubuntu-latest 41 | needs: build-doc 42 | if: github.ref == 'refs/heads/humble' 43 | 44 | steps: 45 | - run: | 46 | git config --global user.name "${{ github.event.head_commit.committer.name }}" 47 | git config --global user.email "${{ github.event.head_commit.committer.email }}" 48 | 49 | - uses: actions/checkout@v4 50 | - name: Create gh-pages branch 51 | run: > 52 | git ls-remote --exit-code --heads origin refs/heads/gh-pages || 53 | ( 54 | git reset --hard ; 55 | git clean -fdx ; 56 | git checkout --orphan gh-pages ; 57 | git reset --hard; 58 | git commit -m "empty" --allow-empty ; 59 | git push origin gh-pages:gh-pages 60 | ) 61 | 62 | - uses: actions/checkout@v4 63 | with: 64 | ref: 'gh-pages' 65 | 66 | - name: Empty gh-pages 67 | run: | 68 | git rm -r . --quiet || true 69 | 70 | - uses: actions/download-artifact@v4 71 | with: 72 | name: html 73 | 74 | - name: Patch doc build 75 | run: | 76 | rm -r _sources 77 | touch .nojekyll 78 | 79 | - name: Commit gh-pages 80 | run: | 81 | git add . >> /dev/null 82 | git commit -m "deploy: ${GITHUB_SHA}" --allow-empty 83 | 84 | - name: Push to gh-pages 85 | run: | 86 | git push origin gh-pages:gh-pages -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore all txtuser files 2 | *.txt.user 3 | *.cpp.orig 4 | .vscode 5 | .venv 6 | venv 7 | doc/_build 8 | _build 9 | -------------------------------------------------------------------------------- /COMMUNICATION.md: -------------------------------------------------------------------------------- 1 | # Communication 2 | 3 | ## How to Contact Us 4 | 5 | | Action | (General team contact) | 6 | | --------------- | ------------------------------ | 7 | | Bug report | GitHub Issue | 8 | | Feature request | GitHub Issue | 9 | 10 | 11 | ## Roles and Responsibilities 12 | 13 | Managers or roles and specific situations they should be contacted for outside the team channel. 14 | 15 | 16 | | Role | Name | Preferred contact method | 17 | | ----- | ------------- | ---------------------------------------- | 18 | | Owner | Adrian Suciu | [Email](mailto:Adrian.Suciu@analog.com) | 19 | | Owner | Adrian Stanea | [Email](mailto:Adrian.Stanea@analog.com) | 20 | 21 | 22 | ## Documentation Contacts 23 | 24 | If you have questions on a specific piece of documentation, you can find the team 25 | member responsible for the information by connecting with email or Teams. -------------------------------------------------------------------------------- /ci/apt-packages.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | apt_packages=( 4 | # libiio 5 | ## Basic system setup 6 | build-essential 7 | libxml2-dev 8 | libzstd-dev 9 | bison 10 | flex 11 | libcdk5-dev 12 | cmake 13 | ## Backend deps 14 | libaio-dev 15 | libusb-1.0-0-dev 16 | libserialport-dev 17 | libavahi-client-dev 18 | ) 19 | -------------------------------------------------------------------------------- /ci/build_doc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eou pipefail 4 | 5 | BASE_PATH=$(git rev-parse --show-toplevel) 6 | ROS_PKG_NAME="adi_imu" 7 | 8 | echo "Installing dependencies" 9 | sudo apt-get update 10 | sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \ 11 | graphviz \ 12 | doxygen 13 | 14 | echo "Generating the build directory" 15 | pushd "$BASE_PATH" >/dev/null || exit 16 | mkdir -p _build 17 | 18 | echo "Building the docs using rosdoc2" 19 | cd "$BASE_PATH/_build" || exit 20 | rosdoc2 build --package-path "$BASE_PATH" --debug 21 | 22 | popd >/dev/null 23 | 24 | if [ $? -eq 0 ]; then 25 | echo "rosdoc2 build command executed successfully." 26 | else 27 | echo "rosdoc2 build command failed." 28 | exit 1 29 | fi 30 | 31 | if [ ! -d "$BASE_PATH/_build/docs_output/$ROS_PKG_NAME" ]; then 32 | echo "Error: The docs_output/$ROS_PKG_NAME directory does not exist." 33 | exit 1 34 | fi 35 | -------------------------------------------------------------------------------- /ci/install_dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | LIBIIO_VERSION=${LIBIIO_VERSION:-libiio-v0} 4 | STAGING_DIR=${STAGING_DIR:-$HOME/src} 5 | 6 | BASE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) 7 | 8 | # Ensure that the STAING_DIR exists 9 | if [ ! -d "$STAGING_DIR" ]; then 10 | echo "Creating staging directory at: $STAGING_DIR" 11 | mkdir -p "$STAGING_DIR" 12 | fi 13 | 14 | install_packages() { 15 | echo "Installing packages" 16 | sudo apt-get update -y 17 | source "${BASE_DIR}"/apt-packages.sh 18 | sudo apt-get install --no-install-recommends -y "${apt_packages[@]}" 19 | } 20 | 21 | install_libiio() { 22 | echo "Building libiio ${LIBIIO_VERSION}" 23 | pushd "${STAGING_DIR}" 24 | git clone \ 25 | --depth 1 \ 26 | --branch "${LIBIIO_VERSION}" \ 27 | https://github.com/analogdevicesinc/libiio.git \ 28 | libiio_"${LIBIIO_VERSION}" 29 | cd libiio_"${LIBIIO_VERSION}" 30 | mkdir build_"${LIBIIO_VERSION}" && cd build_"${LIBIIO_VERSION}" 31 | cmake .. \ 32 | -Werror=dev \ 33 | -DCOMPILE_WARNING_AS_ERROR=ON 34 | sudo cmake --build . --target install 35 | popd 36 | } 37 | 38 | install_all() { 39 | install_packages 40 | install_libiio 41 | } 42 | 43 | install_all -------------------------------------------------------------------------------- /config/adis1646x/imu_config.yaml: -------------------------------------------------------------------------------- 1 | /adi_imu_node: 2 | ros__parameters: 3 | accel_calibbias_x: 0 4 | accel_calibbias_y: 0 5 | accel_calibbias_z: 0 6 | anglvel_calibbias_x: 0 7 | anglvel_calibbias_y: 0 8 | anglvel_calibbias_z: 0 9 | filter_low_pass_3db_frequency: 720 10 | point_of_percussion_alignment: 1 11 | linear_acceleration_compensation: 1 12 | bias_correction_time_base_control: 10 13 | x_axis_gyroscope_bias_correction_enable: 0 14 | y_axis_gyroscope_bias_correction_enable: 0 15 | z_axis_gyroscope_bias_correction_enable: 0 16 | x_axis_accelerometer_bias_correction_enable: 1 17 | y_axis_accelerometer_bias_correction_enable: 1 18 | z_axis_accelerometer_bias_correction_enable: 1 19 | sampling_frequency: 2000.0 20 | command_to_execute: no_command 21 | measured_data_topic_selection: 3 22 | iio_context_string: ip:192.168.0.1 23 | -------------------------------------------------------------------------------- /config/adis1647x/imu_config.yaml: -------------------------------------------------------------------------------- 1 | /adi_imu_node: 2 | ros__parameters: 3 | accel_calibbias_x: 0 4 | accel_calibbias_y: 0 5 | accel_calibbias_z: 0 6 | anglvel_calibbias_x: 0 7 | anglvel_calibbias_y: 0 8 | anglvel_calibbias_z: 0 9 | filter_low_pass_3db_frequency: 720 10 | point_of_percussion_alignment: 1 11 | linear_acceleration_compensation: 1 12 | bias_correction_time_base_control: 10 13 | x_axis_gyroscope_bias_correction_enable: 0 14 | y_axis_gyroscope_bias_correction_enable: 0 15 | z_axis_gyroscope_bias_correction_enable: 0 16 | x_axis_accelerometer_bias_correction_enable: 1 17 | y_axis_accelerometer_bias_correction_enable: 1 18 | z_axis_accelerometer_bias_correction_enable: 1 19 | sampling_frequency: 2000.0 20 | command_to_execute: no_command 21 | measured_data_topic_selection: 3 22 | iio_context_string: ip:192.168.0.1 23 | -------------------------------------------------------------------------------- /config/adis1650x/imu_config.yaml: -------------------------------------------------------------------------------- 1 | /adi_imu_node: 2 | ros__parameters: 3 | accel_calibbias_x: 0 4 | accel_calibbias_y: 0 5 | accel_calibbias_z: 0 6 | anglvel_calibbias_x: 0 7 | anglvel_calibbias_y: 0 8 | anglvel_calibbias_z: 0 9 | filter_low_pass_3db_frequency: 720 10 | internal_sensor_bandwidth: 0 11 | point_of_percussion_alignment: 1 12 | linear_acceleration_compensation: 1 13 | sampling_frequency: 2000.0 14 | command_to_execute: no_command 15 | measured_data_topic_selection: 3 16 | iio_context_string: ip:192.168.0.1 17 | -------------------------------------------------------------------------------- /config/adis1654x/imu_config.yaml: -------------------------------------------------------------------------------- 1 | /adi_imu_node: 2 | ros__parameters: 3 | accel_calibbias_x: 0 4 | accel_calibscale_x: 0 5 | accel_calibbias_y: 0 6 | accel_calibscale_y: 0 7 | accel_calibbias_z: 0 8 | accel_calibscale_z: 0 9 | anglvel_calibbias_x: 0 10 | anglvel_calibscale_x: 0 11 | anglvel_calibbias_y: 0 12 | anglvel_calibscale_y: 0 13 | anglvel_calibbias_z: 0 14 | anglvel_calibscale_z: 0 15 | filter_low_pass_3db_frequency: 100 16 | point_of_percussion_alignment: 1 17 | bias_correction_time_base_control: 10 18 | x_axis_gyroscope_bias_correction_enable: 0 19 | y_axis_gyroscope_bias_correction_enable: 0 20 | z_axis_gyroscope_bias_correction_enable: 0 21 | x_axis_accelerometer_bias_correction_enable: 1 22 | y_axis_accelerometer_bias_correction_enable: 1 23 | z_axis_accelerometer_bias_correction_enable: 1 24 | sampling_frequency: 4250.0 25 | command_to_execute: no_command 26 | measured_data_topic_selection: 3 27 | iio_context_string: ip:192.168.0.1 28 | -------------------------------------------------------------------------------- /config/adis1655x/imu_config.yaml: -------------------------------------------------------------------------------- 1 | /adi_imu_node: 2 | ros__parameters: 3 | accel_calibbias_x: 0 4 | accel_calibscale_x: 0 5 | accel_calibbias_y: 0 6 | accel_calibscale_y: 0 7 | accel_calibbias_z: 0 8 | accel_calibscale_z: 0 9 | anglvel_calibbias_x: 0 10 | anglvel_calibscale_x: 0 11 | anglvel_calibbias_y: 0 12 | anglvel_calibscale_y: 0 13 | anglvel_calibbias_z: 0 14 | anglvel_calibscale_z: 0 15 | filter_low_pass_3db_frequency: 100 16 | point_of_percussion_alignment: 1 17 | bias_correction_time_base_control: 10 18 | x_axis_gyroscope_bias_correction_enable: 0 19 | y_axis_gyroscope_bias_correction_enable: 0 20 | z_axis_gyroscope_bias_correction_enable: 0 21 | x_axis_accelerometer_bias_correction_enable: 1 22 | y_axis_accelerometer_bias_correction_enable: 1 23 | z_axis_accelerometer_bias_correction_enable: 1 24 | sampling_frequency: 4000.0 25 | command_to_execute: no_command 26 | measured_data_topic_selection: 3 27 | iio_context_string: ip:192.168.0.1 28 | -------------------------------------------------------------------------------- /config/adis1657x/imu_config.yaml: -------------------------------------------------------------------------------- 1 | /adi_imu_node: 2 | ros__parameters: 3 | accel_calibbias_x: 0 4 | accel_calibbias_y: 0 5 | accel_calibbias_z: 0 6 | anglvel_calibbias_x: 0 7 | anglvel_calibbias_y: 0 8 | anglvel_calibbias_z: 0 9 | filter_low_pass_3db_frequency: 720 10 | internal_sensor_bandwidth: 0 11 | point_of_percussion_alignment: 1 12 | linear_acceleration_compensation: 1 13 | bias_correction_time_base_control: 10 14 | x_axis_gyroscope_bias_correction_enable: 0 15 | y_axis_gyroscope_bias_correction_enable: 0 16 | z_axis_gyroscope_bias_correction_enable: 0 17 | x_axis_accelerometer_bias_correction_enable: 1 18 | y_axis_accelerometer_bias_correction_enable: 1 19 | z_axis_accelerometer_bias_correction_enable: 1 20 | sampling_frequency: 2000.0 21 | command_to_execute: no_command 22 | measured_data_topic_selection: 3 23 | iio_context_string: ip:192.168.0.1 24 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /doc/images/adis16467_1_rpi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/analogdevicesinc/imu_ros2/637372fc00b2962330fe3a8ca44ccd8d3e1de8d7/doc/images/adis16467_1_rpi.jpg -------------------------------------------------------------------------------- /doc/images/adis16505_2_rpi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/analogdevicesinc/imu_ros2/637372fc00b2962330fe3a8ca44ccd8d3e1de8d7/doc/images/adis16505_2_rpi.jpg -------------------------------------------------------------------------------- /doc/images/architecture_local_client.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/analogdevicesinc/imu_ros2/637372fc00b2962330fe3a8ca44ccd8d3e1de8d7/doc/images/architecture_local_client.png -------------------------------------------------------------------------------- /doc/images/architecture_remote_client.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/analogdevicesinc/imu_ros2/637372fc00b2962330fe3a8ca44ccd8d3e1de8d7/doc/images/architecture_remote_client.png -------------------------------------------------------------------------------- /doc/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | %SPHINXBUILD% >NUL 2>NUL 14 | if errorlevel 9009 ( 15 | echo. 16 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 17 | echo.installed, then set the SPHINXBUILD environment variable to point 18 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 19 | echo.may add the Sphinx directory to PATH. 20 | echo. 21 | echo.If you don't have Sphinx installed, grab it from 22 | echo.https://www.sphinx-doc.org/ 23 | exit /b 1 24 | ) 25 | 26 | if "%1" == "" goto help 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /doc/requirements.txt: -------------------------------------------------------------------------------- 1 | https://github.com/analogdevicesinc/doctools/releases/download/latest/adi-doctools.tar.gz 2 | git+https://github.com/ros-infrastructure/rosdoc2.git@main 3 | sphinx 4 | sphinxcontrib.wavedrom 5 | -------------------------------------------------------------------------------- /include/adi_imu/accelgyrotemp_data_provider.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file accelgyrotemp_data_provider.h 3 | * @brief Header for providing acceleration, gyroscope and 4 | * temperature data provider. 5 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 6 | ******************************************************************************* 7 | * Copyright 2023(c) Analog Devices, Inc. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | ******************************************************************************/ 21 | 22 | #ifndef ACCELGYROTEMP_DATA_PROVIDER_H 23 | #define ACCELGYROTEMP_DATA_PROVIDER_H 24 | 25 | #include "adi_imu/accelgyrotemp_data_provider_interface.h" 26 | #include "adi_imu/iio_wrapper.h" 27 | 28 | /** 29 | * @brief Class for acceleration, angular velocity and temperature 30 | * buffered data provider. 31 | */ 32 | class AccelGyroTempDataProvider : public AccelGyroTempDataProviderInterface 33 | { 34 | public: 35 | /** 36 | * @brief Constructor for AccelGyroTempDataProvider. 37 | */ 38 | AccelGyroTempDataProvider(); 39 | 40 | /** 41 | * @brief Destructor for AccelGyroTempDataProvider. 42 | */ 43 | ~AccelGyroTempDataProvider(); 44 | 45 | /** 46 | * @brief Populate AccelGyroTempData message with measured data. 47 | * @param message Message containing the measured data. 48 | * @return Return true if the message parameter is successfully populated with 49 | * measured data and false otherwise. 50 | */ 51 | bool getData(adi_imu::msg::AccelGyroTempData & message) override; 52 | 53 | private: 54 | /*! This data member is used to access sensor information via libiio. */ 55 | IIOWrapper m_iio_wrapper; 56 | }; 57 | 58 | #endif // ACCELGYROTEMP_DATA_PROVIDER_H 59 | -------------------------------------------------------------------------------- /include/adi_imu/accelgyrotemp_data_provider_interface.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file accelgyrotemp_data_provider_interface.h 3 | * @brief Interface for providing acceleration, gyroscope and 4 | * temperature data provider. 5 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 6 | ******************************************************************************* 7 | * Copyright 2023(c) Analog Devices, Inc. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | ******************************************************************************/ 21 | 22 | #ifndef ACCELGYROTEMP_DATA_PROVIDER_INTERFACE_H 23 | #define ACCELGYROTEMP_DATA_PROVIDER_INTERFACE_H 24 | 25 | #include "adi_imu/msg/accel_gyro_temp_data.hpp" 26 | 27 | /** 28 | * @brief Interface for acceleration, angular velocity and temperature 29 | * buffered data provider. 30 | */ 31 | class AccelGyroTempDataProviderInterface 32 | { 33 | public: 34 | /** 35 | * @brief Constructor for AccelGyroTempDataProviderInterface. 36 | */ 37 | AccelGyroTempDataProviderInterface() {} 38 | 39 | /** 40 | * @brief Destructor for AccelGyroTempDataProviderInterface. 41 | */ 42 | virtual ~AccelGyroTempDataProviderInterface() {} 43 | 44 | /** 45 | * @brief Populate AccelGyroTempData message with measured data. 46 | * @param message Message containing the measured data. 47 | * @return Return true if the message parameter is successfully populated with 48 | * measured data and false otherwise. 49 | */ 50 | virtual bool getData(adi_imu::msg::AccelGyroTempData & message) = 0; 51 | }; 52 | 53 | #endif // ACCELGYROTEMP_DATA_PROVIDER_INTERFACE_H 54 | -------------------------------------------------------------------------------- /include/adi_imu/accelgyrotemp_ros_publisher.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file accelgyrotemp_ros_publisher.h 3 | * @brief Header for acceleration, gyroscope and temperature publisher. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #ifndef ACCELGYROTEMP_ROS_SUBSCRIBER_H 22 | #define ACCELGYROTEMP_ROS_SUBSCRIBER_H 23 | 24 | #include 25 | 26 | #include "adi_imu/accelgyrotemp_data_provider_interface.h" 27 | #include "adi_imu/accelgyrotemp_ros_publisher_interface.h" 28 | 29 | /** 30 | * @brief Class for acceleration, angular velocity and temperature publisher. 31 | */ 32 | class AccelGyroTempRosPublisher : public AccelGyroTempRosPublisherInterface 33 | { 34 | public: 35 | /** 36 | * @brief Constructor for AccelGyroTempRosPublisher. 37 | * @param node The ros2 Node instance. 38 | */ 39 | AccelGyroTempRosPublisher(std::shared_ptr & node); 40 | 41 | /** 42 | * @brief Destructor for AccelGyroTempRosPublisher. 43 | */ 44 | ~AccelGyroTempRosPublisher(); 45 | 46 | /** 47 | * @brief Set the message data provider. 48 | * @param dataProvider Data provider. 49 | */ 50 | void setMessageProvider(AccelGyroTempDataProviderInterface * dataProvider) override; 51 | 52 | /** 53 | * @brief Publish the AccelGyroTempData message. 54 | */ 55 | void publish() override; 56 | 57 | private: 58 | /*! This variable retains the data provider instance. */ 59 | AccelGyroTempDataProviderInterface * m_data_provider; 60 | 61 | /*! This variable retains the publisher instance. */ 62 | rclcpp::Publisher::SharedPtr m_publisher; 63 | 64 | /*! This variable retains the message that is published. */ 65 | adi_imu::msg::AccelGyroTempData m_message; 66 | }; 67 | 68 | #endif // ACCELGYROTEMP_ROS_SUBSCRIBER_H 69 | -------------------------------------------------------------------------------- /include/adi_imu/accelgyrotemp_ros_publisher_interface.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file accelgyrotemp_ros_publisher_interface.h 3 | * @brief Interface for acceleration, gyroscope and temperature publisher. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #ifndef ACCELGYROTEMP_ROS_PUBLISHER_INTERFACE_H 22 | #define ACCELGYROTEMP_ROS_PUBLISHER_INTERFACE_H 23 | 24 | #include 25 | #include 26 | 27 | class AccelGyroTempDataProviderInterface; 28 | 29 | /** 30 | * @brief Interface for acceleration, angular velocity and temperature 31 | * publisher. 32 | */ 33 | class AccelGyroTempRosPublisherInterface 34 | { 35 | public: 36 | /** 37 | * @brief Constructor for AccelGyroTempRosPublisherInterface. 38 | */ 39 | AccelGyroTempRosPublisherInterface() {} 40 | 41 | /** 42 | * @brief Destructor for AccelGyroTempRosPublisherInterface. 43 | */ 44 | virtual ~AccelGyroTempRosPublisherInterface() {} 45 | 46 | /** 47 | * @brief Set the message data provider. 48 | * @param dataProvider Data provider. 49 | */ 50 | virtual void setMessageProvider(AccelGyroTempDataProviderInterface * dataProvider) = 0; 51 | 52 | /** 53 | * @brief Publish the AccelGyroTempData message. 54 | */ 55 | virtual void publish() = 0; 56 | 57 | protected: 58 | /*! The ros2 Node data member. */ 59 | std::shared_ptr m_node; 60 | }; 61 | 62 | #endif // ACCELGYROTEMP_ROS_PUBLISHER_INTERFACE_H 63 | -------------------------------------------------------------------------------- /include/adi_imu/adis1646x/adis1646x_data_access.h: -------------------------------------------------------------------------------- 1 | #ifndef ADIS1646X_DATA_ACCESS_H 2 | #define ADIS1646X_DATA_ACCESS_H 3 | 4 | #define ADIS_FLS_MEM_ENDURANCE 10000 5 | #define ADIS_MAX_SAMP_FREQ 2100.0 6 | 7 | #define ADIS_DIAG_STAT_ADDR 0x02 8 | #define ADIS_DATA_PATH_OVERRUN_POS 1 9 | #define ADIS_FLS_MEM_UPDATE_FAIL_POS 2 10 | #define ADIS_SPI_COMM_ERR_POS 3 11 | #define ADIS_STDBY_MODE_POS 4 12 | #define ADIS_SNSR_FAIL_POS 5 13 | #define ADIS_MEM_FAIL_POS 6 14 | #define ADIS_CLK_ERR_POS 7 15 | 16 | #define ADIS_DATA_PATH_OVERRUN (1 << ADIS_DATA_PATH_OVERRUN_POS) 17 | #define ADIS_FLS_MEM_UPDATE_FAIL (1 << ADIS_FLS_MEM_UPDATE_FAIL_POS) 18 | #define ADIS_SPI_COMM_ERR (1 << ADIS_SPI_COMM_ERR_POS) 19 | #define ADIS_STDBY_MODE (1 << ADIS_STDBY_MODE_POS) 20 | #define ADIS_SNSR_FAIL (1 << ADIS_SNSR_FAIL_POS) 21 | #define ADIS_MEM_FAIL (1 << ADIS_MEM_FAIL_POS) 22 | #define ADIS_CLK_ERR (1 << ADIS_CLK_ERR_POS) 23 | 24 | #define ADIS_RANG_MDL_ADDR 0x5E 25 | #define ADIS_GYRO_MEAS_RANG_POS 2 26 | 27 | #define ADIS_GYRO_MEAS_RANG (3 << ADIS_GYRO_MEAS_RANG_POS) 28 | 29 | #define ADIS_MSC_CTRL_ADDR 0x60 30 | #define ADIS_DR_POL_POS 0 31 | #define ADIS_SYNC_POL_POS 1 32 | #define ADIS_LN_ACCL_COMP_POS 7 33 | 34 | #define ADIS_DR_POL (1 << ADIS_DR_POL_POS) 35 | #define ADIS_SYNC_POL (1 << ADIS_SYNC_POL_POS) 36 | 37 | #define ADIS_LN_ACCL_COMP (1 << ADIS_LN_ACCL_COMP_POS) 38 | 39 | #define ADIS_NULL_CNFG_ADDR 0x66 40 | #define ADIS_TIME_BASE_CONTROL_POS 0 41 | #define ADIS_X_AXIS_GYRO_BIAS_CORR_EN_POS 8 42 | #define ADIS_Y_AXIS_GYRO_BIAS_CORR_EN_POS 9 43 | #define ADIS_Z_AXIS_GYRO_BIAS_CORR_EN_POS 10 44 | #define ADIS_X_AXIS_ACCEL_BIAS_CORR_EN_POS 11 45 | #define ADIS_Y_AXIS_ACCEL_BIAS_CORR_EN_POS 12 46 | #define ADIS_Z_AXIS_ACCEL_BIAS_CORR_EN_POS 13 47 | 48 | #define ADIS_TIME_BASE_CONTROL 0xF 49 | #define ADIS_X_AXIS_GYRO_BIAS_CORR_EN (1 << ADIS_X_AXIS_GYRO_BIAS_CORR_EN_POS) 50 | #define ADIS_Y_AXIS_GYRO_BIAS_CORR_EN (1 << ADIS_Y_AXIS_GYRO_BIAS_CORR_EN_POS) 51 | #define ADIS_Z_AXIS_GYRO_BIAS_CORR_EN (1 << ADIS_Z_AXIS_GYRO_BIAS_CORR_EN_POS) 52 | #define ADIS_X_AXIS_ACCEL_BIAS_CORR_EN (1 << ADIS_X_AXIS_ACCEL_BIAS_CORR_EN_POS) 53 | #define ADIS_Y_AXIS_ACCEL_BIAS_CORR_EN (1 << ADIS_Y_AXIS_ACCEL_BIAS_CORR_EN_POS) 54 | #define ADIS_Z_AXIS_ACCEL_BIAS_CORR_EN (1 << ADIS_Z_AXIS_ACCEL_BIAS_CORR_EN_POS) 55 | 56 | #define ADIS_GLOB_CMD_ADDR 0x68 57 | #define ADIS_BIAS_CORRECTION_UPDATE (1 << 0) 58 | #define ADIS_FACTORY_CALIBRATION_RESTORE (1 << 1) 59 | #define ADIS_SENSOR_SELF_TEST (1 << 2) 60 | #define ADIS_FLASH_MEMORY_UPDATE (1 << 3) 61 | #define ADIS_FLASH_MEMORY_TEST (1 << 4) 62 | #define ADIS_SOFTWARE_RESET_CMD (1 << 7) 63 | 64 | #define ADIS_PT_OF_PERC_REG_ADDR ADIS_MSC_CTRL_ADDR 65 | #define ADIS_PT_OF_PERC_ALGNMNT_POS 6 66 | #define ADIS_PT_OF_PERC_ALGNMNT (1 << ADIS_PT_OF_PERC_ALGNMNT_POS) 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /include/adi_imu/adis1647x/adis1647x_data_access.h: -------------------------------------------------------------------------------- 1 | #ifndef ADIS1647X_DATA_ACCESS_H 2 | #define ADIS1647X_DATA_ACCESS_H 3 | 4 | #define ADIS_HAS_DELTA_BURST 5 | 6 | #define ADIS_FLS_MEM_ENDURANCE 10000 7 | #define ADIS_MAX_SAMP_FREQ 2100.0 8 | 9 | #define ADIS_DIAG_STAT_ADDR 0x02 10 | #define ADIS_DATA_PATH_OVERRUN_POS 1 11 | #define ADIS_FLS_MEM_UPDATE_FAIL_POS 2 12 | #define ADIS_SPI_COMM_ERR_POS 3 13 | #define ADIS_STDBY_MODE_POS 4 14 | #define ADIS_SNSR_FAIL_POS 5 15 | #define ADIS_MEM_FAIL_POS 6 16 | #define ADIS_CLK_ERR_POS 7 17 | 18 | #define ADIS_DATA_PATH_OVERRUN (1 << ADIS_DATA_PATH_OVERRUN_POS) 19 | #define ADIS_FLS_MEM_UPDATE_FAIL (1 << ADIS_FLS_MEM_UPDATE_FAIL_POS) 20 | #define ADIS_SPI_COMM_ERR (1 << ADIS_SPI_COMM_ERR_POS) 21 | #define ADIS_STDBY_MODE (1 << ADIS_STDBY_MODE_POS) 22 | #define ADIS_SNSR_FAIL (1 << ADIS_SNSR_FAIL_POS) 23 | #define ADIS_MEM_FAIL (1 << ADIS_MEM_FAIL_POS) 24 | #define ADIS_CLK_ERR (1 << ADIS_CLK_ERR_POS) 25 | 26 | #define ADIS_RANG_MDL_ADDR 0x5E 27 | #define ADIS_GYRO_MEAS_RANG_POS 2 28 | 29 | #define ADIS_GYRO_MEAS_RANG (3 << ADIS_GYRO_MEAS_RANG_POS) 30 | 31 | #define ADIS_MSC_CTRL_ADDR 0x60 32 | #define ADIS_DR_POL_POS 0 33 | #define ADIS_SYNC_POL_POS 1 34 | #define ADIS_LN_ACCL_COMP_POS 7 35 | 36 | #define ADIS_DR_POL (1 << ADIS_DR_POL_POS) 37 | #define ADIS_SYNC_POL (1 << ADIS_SYNC_POL_POS) 38 | #define ADIS_LN_ACCL_COMP (1 << ADIS_LN_ACCL_COMP_POS) 39 | 40 | #define ADIS_NULL_CNFG_ADDR 0x66 41 | #define ADIS_TIME_BASE_CONTROL_POS 0 42 | #define ADIS_X_AXIS_GYRO_BIAS_CORR_EN_POS 8 43 | #define ADIS_Y_AXIS_GYRO_BIAS_CORR_EN_POS 9 44 | #define ADIS_Z_AXIS_GYRO_BIAS_CORR_EN_POS 10 45 | #define ADIS_X_AXIS_ACCEL_BIAS_CORR_EN_POS 11 46 | #define ADIS_Y_AXIS_ACCEL_BIAS_CORR_EN_POS 12 47 | #define ADIS_Z_AXIS_ACCEL_BIAS_CORR_EN_POS 13 48 | 49 | #define ADIS_TIME_BASE_CONTROL 0xF 50 | #define ADIS_X_AXIS_GYRO_BIAS_CORR_EN (1 << ADIS_X_AXIS_GYRO_BIAS_CORR_EN_POS) 51 | #define ADIS_Y_AXIS_GYRO_BIAS_CORR_EN (1 << ADIS_Y_AXIS_GYRO_BIAS_CORR_EN_POS) 52 | #define ADIS_Z_AXIS_GYRO_BIAS_CORR_EN (1 << ADIS_Z_AXIS_GYRO_BIAS_CORR_EN_POS) 53 | #define ADIS_X_AXIS_ACCEL_BIAS_CORR_EN (1 << ADIS_X_AXIS_ACCEL_BIAS_CORR_EN_POS) 54 | #define ADIS_Y_AXIS_ACCEL_BIAS_CORR_EN (1 << ADIS_Y_AXIS_ACCEL_BIAS_CORR_EN_POS) 55 | #define ADIS_Z_AXIS_ACCEL_BIAS_CORR_EN (1 << ADIS_Z_AXIS_ACCEL_BIAS_CORR_EN_POS) 56 | 57 | #define ADIS_GLOB_CMD_ADDR 0x68 58 | #define ADIS_BIAS_CORRECTION_UPDATE (1 << 0) 59 | #define ADIS_FACTORY_CALIBRATION_RESTORE (1 << 1) 60 | #define ADIS_SENSOR_SELF_TEST (1 << 2) 61 | #define ADIS_FLASH_MEMORY_UPDATE (1 << 3) 62 | #define ADIS_FLASH_MEMORY_TEST (1 << 4) 63 | #define ADIS_SOFTWARE_RESET_CMD (1 << 7) 64 | 65 | #define ADIS_PT_OF_PERC_REG_ADDR ADIS_MSC_CTRL_ADDR 66 | #define ADIS_PT_OF_PERC_ALGNMNT_POS 6 67 | #define ADIS_PT_OF_PERC_ALGNMNT (1 << ADIS_PT_OF_PERC_ALGNMNT_POS) 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /include/adi_imu/adis1650x/adis1650x_data_access.h: -------------------------------------------------------------------------------- 1 | #ifndef ADIS1650X_DATA_ACCESS_H 2 | #define ADIS1650X_DATA_ACCESS_H 3 | 4 | #define ADIS_HAS_DELTA_BURST 5 | 6 | #define ADIS_FLS_MEM_ENDURANCE 10000 7 | #define ADIS_MAX_SAMP_FREQ 2100.0 8 | 9 | #define ADIS_DIAG_STAT_ADDR 0x02 10 | #define ADIS_DATA_PATH_OVERRUN_POS 1 11 | #define ADIS_FLS_MEM_UPDATE_FAIL_POS 2 12 | #define ADIS_SPI_COMM_ERR_POS 3 13 | #define ADIS_STDBY_MODE_POS 4 14 | #define ADIS_SNSR_FAIL_POS 5 15 | #define ADIS_MEM_FAIL_POS 6 16 | #define ADIS_CLK_ERR_POS 7 17 | #define ADIS_GYRO1_FAIL_POS 8 18 | #define ADIS_GYRO2_FAIL_POS 9 19 | #define ADIS_ACCEL_FAIL_POS 10 20 | 21 | #define ADIS_DATA_PATH_OVERRUN (1 << ADIS_DATA_PATH_OVERRUN_POS) 22 | #define ADIS_FLS_MEM_UPDATE_FAIL (1 << ADIS_FLS_MEM_UPDATE_FAIL_POS) 23 | #define ADIS_SPI_COMM_ERR (1 << ADIS_SPI_COMM_ERR_POS) 24 | #define ADIS_STDBY_MODE (1 << ADIS_STDBY_MODE_POS) 25 | #define ADIS_SNSR_FAIL (1 << ADIS_SNSR_FAIL_POS) 26 | #define ADIS_MEM_FAIL (1 << ADIS_MEM_FAIL_POS) 27 | #define ADIS_CLK_ERR (1 << ADIS_CLK_ERR_POS) 28 | #define ADIS_GYRO1_FAIL (1 << ADIS_GYRO1_FAIL_POS) 29 | #define ADIS_GYRO2_FAIL (1 << ADIS_GYRO2_FAIL_POS) 30 | #define ADIS_ACCEL_FAIL (1 << ADIS_ACCEL_FAIL_POS) 31 | 32 | #define ADIS_RANG_MDL_ADDR 0x5E 33 | #define ADIS_GYRO_MEAS_RANG_POS 2 34 | 35 | #define ADIS_GYRO_MEAS_RANG (3 << ADIS_GYRO_MEAS_RANG_POS) 36 | 37 | #define ADIS_MSC_CTRL_ADDR 0x60 38 | #define ADIS_DR_POL_POS 0 39 | #define ADIS_SYNC_POL_POS 1 40 | #define ADIS_SENS_BW_POS 4 41 | #define ADIS_LN_ACCL_COMP_POS 7 42 | 43 | #define ADIS_DR_POL (1 << ADIS_DR_POL_POS) 44 | #define ADIS_SYNC_POL (1 << ADIS_SYNC_POL_POS) 45 | #define ADIS_SENS_BW (1 << ADIS_SENS_BW_POS) 46 | #define ADIS_LN_ACCL_COMP (1 << ADIS_LN_ACCL_COMP_POS) 47 | 48 | #define ADIS_GLOB_CMD_ADDR 0x68 49 | #define ADIS_FACTORY_CALIBRATION_RESTORE (1 << 1) 50 | #define ADIS_SENSOR_SELF_TEST (1 << 2) 51 | #define ADIS_FLASH_MEMORY_UPDATE (1 << 3) 52 | #define ADIS_FLASH_MEMORY_TEST (1 << 4) 53 | #define ADIS_SOFTWARE_RESET_CMD (1 << 7) 54 | 55 | #define ADIS_PT_OF_PERC_REG_ADDR ADIS_MSC_CTRL_ADDR 56 | #define ADIS_PT_OF_PERC_ALGNMNT_POS 6 57 | #define ADIS_PT_OF_PERC_ALGNMNT (1 << ADIS_PT_OF_PERC_ALGNMNT_POS) 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /include/adi_imu/adis1654x/adis1654x_data_access.h: -------------------------------------------------------------------------------- 1 | #ifndef ADIS1654X_DATA_ACCESS_H 2 | #define ADIS1654X_DATA_ACCESS_H 3 | 4 | // has delta channels 5 | #define ADIS_HAS_DELTA_BURST 6 | 7 | // has calibration scale channel 8 | #define ADIS_HAS_CALIB_SCALE 9 | 10 | #define ADIS_FLS_MEM_ENDURANCE 100000 11 | #define ADIS_MAX_SAMP_FREQ 4250.0 12 | 13 | // value to add to reg addr per page 14 | #define ADIS_PAGE_ID_VAL 0x80 15 | 16 | // global commands 17 | #define ADIS_GLOB_CMD_PAGE_ID 0x03 18 | #define ADIS_GLOB_CMD_ADDR_WITHOUT_PAGE 0x02 19 | #define ADIS_GLOB_CMD_ADDR \ 20 | (ADIS_PAGE_ID_VAL * ADIS_PT_OF_PERC_PAGE_ID + ADIS_GLOB_CMD_ADDR_WITHOUT_PAGE) 21 | 22 | #define ADIS_BIAS_CORRECTION_UPDATE_POS 0 23 | #define ADIS_SENSOR_SELF_TEST_POS 1 24 | #define ADIS_FLASH_MEMORY_UPDATE_POS 3 25 | #define ADIS_FACTORY_CALIBRATION_RESTORE_POS 6 26 | #define ADIS_SOFTWARE_RESET_CMD_POS 7 27 | 28 | #define ADIS_BIAS_CORRECTION_UPDATE (1 << ADIS_BIAS_CORRECTION_UPDATE_POS) 29 | #define ADIS_SENSOR_SELF_TEST (1 << ADIS_SENSOR_SELF_TEST_POS) 30 | #define ADIS_FLASH_MEMORY_UPDATE (1 << ADIS_FLASH_MEMORY_UPDATE_POS) 31 | #define ADIS_FACTORY_CALIBRATION_RESTORE (1 << ADIS_FACTORY_CALIBRATION_RESTORE_POS) 32 | #define ADIS_SOFTWARE_RESET_CMD (1 << ADIS_SOFTWARE_RESET_CMD_POS) 33 | 34 | // status and error flag indication 35 | #define ADIS_DIAG_STAT_PAGE_ID 0x00 36 | #define ADIS_DIAG_STAT_ADDR_WITHOUT_PAGE 0x08 37 | #define ADIS_DIAG_STAT_ADDR \ 38 | (ADIS_PAGE_ID_VAL * ADIS_DIAG_STAT_PAGE_ID + ADIS_DIAG_STAT_ADDR_WITHOUT_PAGE) 39 | #define ADIS_MEM_FAIL_POS 1 40 | #define ADIS_CRC_ERROR_POS 2 41 | #define ADIS_SPI_COMM_ERR_POS 3 42 | #define ADIS_SNSR_FAIL_POS 5 43 | #define ADIS_FLS_MEM_UPDATE_FAIL_POS 6 44 | #define ADIS_DATA_PATH_OVERRUN_POS 7 45 | #define ADIS_CLK_ERR_POS 8 46 | #define ADIS_WDG_TIMER_FLAG_POS 15 47 | 48 | #define ADIS_MEM_FAIL (1 << ADIS_MEM_FAIL_POS) 49 | #define ADIS_CRC_ERROR (1 << ADIS_CRC_ERROR_POS) 50 | #define ADIS_SPI_COMM_ERR (1 << ADIS_SPI_COMM_ERR_POS) 51 | #define ADIS_SNSR_FAIL (1 << ADIS_SNSR_FAIL_POS) 52 | #define ADIS_FLS_MEM_UPDATE_FAIL (1 << ADIS_FLS_MEM_UPDATE_FAIL_POS) 53 | #define ADIS_DATA_PATH_OVERRUN (1 << ADIS_DATA_PATH_OVERRUN_POS) 54 | #define ADIS_CLK_ERR (1 << ADIS_CLK_ERR_POS) 55 | #define ADIS_WDG_TIMER_FLAG (1 << ADIS_WDG_TIMER_FLAG_POS) 56 | 57 | // self test error flags 58 | #define ADIS_DIAG_STS_PAGE_ID 0x00 59 | #define ADIS_DIAG_STS_REG_WITHOUT_PAGE 0x0A 60 | #define ADIS_DIAG_STS_REG \ 61 | (ADIS_PAGE_ID_VAL * ADIS_DIAG_STS_PAGE_ID + ADIS_DIAG_STS_REG_WITHOUT_PAGE) 62 | 63 | #define ADIS_GYRO_ACCEL_FAIL_REG ADIS_DIAG_STS_REG 64 | #define ADIS_GYRO_X_FAIL_POS 0 65 | #define ADIS_GYRO_Y_FAIL_POS 1 66 | #define ADIS_GYRO_Z_FAIL_POS 2 67 | #define ADIS_ACCEL_X_FAIL_POS 3 68 | #define ADIS_ACCEL_Y_FAIL_POS 4 69 | #define ADIS_ACCEL_Z_FAIL_POS 5 70 | 71 | #define ADIS_GYRO_X_FAIL (1 << ADIS_GYRO_X_FAIL_POS) 72 | #define ADIS_GYRO_Y_FAIL (1 << ADIS_GYRO_Y_FAIL_POS) 73 | #define ADIS_GYRO_Z_FAIL (1 << ADIS_GYRO_Z_FAIL_POS) 74 | #define ADIS_ACCEL_X_FAIL (1 << ADIS_ACCEL_X_FAIL_POS) 75 | #define ADIS_ACCEL_Y_FAIL (1 << ADIS_ACCEL_Y_FAIL_POS) 76 | #define ADIS_ACCEL_Z_FAIL (1 << ADIS_ACCEL_Z_FAIL_POS) 77 | 78 | // measurement range identifier 79 | #define ADIS_RANG_MDL_PAGE_ID 0x03 80 | #define ADIS_RANG_MDL_ADDR_WITHOUT_PAGE 0x12 81 | #define ADIS_RANG_MDL_ADDR \ 82 | (ADIS_PAGE_ID_VAL * ADIS_RANG_MDL_PAGE_ID + ADIS_RANG_MDL_ADDR_WITHOUT_PAGE) 83 | #define ADIS_GYRO_MEAS_RANG_POS 2 84 | #define ADIS_GYRO_MEAS_RANG (3 << ADIS_GYRO_MEAS_RANG_POS) 85 | 86 | // point of percussion 87 | #define ADIS_PT_OF_PERC_PAGE_ID 0x03 88 | #define ADIS_PT_OF_PERC_REG_ADDR_WITHOUT_PAGE 0x0A 89 | #define ADIS_PT_OF_PERC_REG_ADDR \ 90 | (ADIS_PAGE_ID_VAL * ADIS_PT_OF_PERC_PAGE_ID + ADIS_PT_OF_PERC_REG_ADDR_WITHOUT_PAGE) 91 | #define ADIS_PT_OF_PERC_ALGNMNT_POS 6 92 | #define ADIS_PT_OF_PERC_ALGNMNT (1 << ADIS_PT_OF_PERC_ALGNMNT_POS) 93 | 94 | // continuous bias estimation 95 | #define ADIS_NULL_CNFG_PAGE_ID 0x03 96 | #define ADIS_NULL_CNFG_ADDR_WITHOUT_PAGE 0x0E 97 | #define ADIS_NULL_CNFG_ADDR \ 98 | (ADIS_PAGE_ID_VAL * ADIS_NULL_CNFG_PAGE_ID + ADIS_NULL_CNFG_ADDR_WITHOUT_PAGE) 99 | 100 | #define ADIS_TIME_BASE_CONTROL_POS 0 101 | #define ADIS_X_AXIS_GYRO_BIAS_CORR_EN_POS 8 102 | #define ADIS_Y_AXIS_GYRO_BIAS_CORR_EN_POS 9 103 | #define ADIS_Z_AXIS_GYRO_BIAS_CORR_EN_POS 10 104 | #define ADIS_X_AXIS_ACCEL_BIAS_CORR_EN_POS 11 105 | #define ADIS_Y_AXIS_ACCEL_BIAS_CORR_EN_POS 12 106 | #define ADIS_Z_AXIS_ACCEL_BIAS_CORR_EN_POS 13 107 | 108 | #define ADIS_TIME_BASE_CONTROL 0xF 109 | #define ADIS_X_AXIS_GYRO_BIAS_CORR_EN (1 << ADIS_X_AXIS_GYRO_BIAS_CORR_EN_POS) 110 | #define ADIS_Y_AXIS_GYRO_BIAS_CORR_EN (1 << ADIS_Y_AXIS_GYRO_BIAS_CORR_EN_POS) 111 | #define ADIS_Z_AXIS_GYRO_BIAS_CORR_EN (1 << ADIS_Z_AXIS_GYRO_BIAS_CORR_EN_POS) 112 | #define ADIS_X_AXIS_ACCEL_BIAS_CORR_EN (1 << ADIS_X_AXIS_ACCEL_BIAS_CORR_EN_POS) 113 | #define ADIS_Y_AXIS_ACCEL_BIAS_CORR_EN (1 << ADIS_Y_AXIS_ACCEL_BIAS_CORR_EN_POS) 114 | #define ADIS_Z_AXIS_ACCEL_BIAS_CORR_EN (1 << ADIS_Z_AXIS_ACCEL_BIAS_CORR_EN_POS) 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /include/adi_imu/adis1655x/adis1655x_data_access.h: -------------------------------------------------------------------------------- 1 | #ifndef ADIS1655X_DATA_ACCESS_H 2 | #define ADIS1655X_DATA_ACCESS_H 3 | 4 | // has delta channels 5 | #define ADIS_HAS_DELTA_BURST 6 | 7 | // has calibration scale channel 8 | #define ADIS_HAS_CALIB_SCALE 9 | 10 | #define ADIS_FLS_MEM_ENDURANCE 100000 11 | #define ADIS_MAX_SAMP_FREQ 4250.0 12 | 13 | // value to add to reg addr per page 14 | #define ADIS_PAGE_ID_VAL 0x80 15 | 16 | // global commands 17 | #define ADIS_GLOB_CMD_PAGE_ID 0x00 18 | #define ADIS_GLOB_CMD_ADDR_WITHOUT_PAGE 0x50 19 | #define ADIS_GLOB_CMD_ADDR \ 20 | (ADIS_PAGE_ID_VAL * ADIS_PT_OF_PERC_PAGE_ID + ADIS_GLOB_CMD_ADDR_WITHOUT_PAGE) 21 | 22 | #define ADIS_SENSOR_SELF_TEST_POS 1 23 | #define ADIS_FLASH_MEMORY_UPDATE_POS 3 24 | #define ADIS_FACTORY_CALIBRATION_RESTORE_POS 2 25 | #define ADIS_SOFTWARE_RESET_CMD_POS 5 26 | 27 | #define ADIS_SENSOR_SELF_TEST (1 << ADIS_SENSOR_SELF_TEST_POS) 28 | #define ADIS_FLASH_MEMORY_UPDATE (1 << ADIS_FLASH_MEMORY_UPDATE_POS) 29 | #define ADIS_FACTORY_CALIBRATION_RESTORE (1 << ADIS_FACTORY_CALIBRATION_RESTORE_POS) 30 | #define ADIS_SOFTWARE_RESET_CMD (1 << ADIS_SOFTWARE_RESET_CMD_POS) 31 | 32 | // status and error flag indication 33 | #define ADIS_DIAG_STAT_PAGE_ID 0x00 34 | #define ADIS_DIAG_STAT_ADDR_WITHOUT_PAGE 0x0E 35 | #define ADIS_DIAG_STAT_ADDR \ 36 | (ADIS_PAGE_ID_VAL * ADIS_DIAG_STAT_PAGE_ID + ADIS_DIAG_STAT_ADDR_WITHOUT_PAGE) 37 | 38 | #define ADIS_MEM_FAIL_POS 0 39 | #define ADIS_CRC_ERROR_POS 1 40 | #define ADIS_FLS_MEM_UPDATE_FAIL_POS 2 41 | #define ADIS_SNSR_FAIL_POS 4 42 | #define ADIS_SPI_COMM_ERR_POS 6 43 | #define ADIS_DATA_PATH_OVERRUN_POS 7 44 | #define ADIS_CLK_ERR_POS 10 45 | #define ADIS_WDG_TIMER_FLAG_POS 15 46 | 47 | #define ADIS_MEM_FAIL (1 << ADIS_MEM_FAIL_POS) 48 | #define ADIS_CRC_ERROR (1 << ADIS_CRC_ERROR_POS) 49 | #define ADIS_FLS_MEM_UPDATE_FAIL (1 << ADIS_FLS_MEM_UPDATE_FAIL_POS) 50 | #define ADIS_SNSR_FAIL (1 << ADIS_SNSR_FAIL_POS) 51 | #define ADIS_SPI_COMM_ERR (1 << ADIS_SPI_COMM_ERR_POS) 52 | #define ADIS_DATA_PATH_OVERRUN (1 << ADIS_DATA_PATH_OVERRUN_POS) 53 | #define ADIS_CLK_ERR (1 << ADIS_CLK_ERR_POS) 54 | #define ADIS_WDG_TIMER_FLAG (1 << ADIS_WDG_TIMER_FLAG_POS) 55 | 56 | // self test error flags 57 | #define ADIS_DIAG_STS_PAGE_ID 0x00 58 | #define ADIS_DIAG_STS_REG_WITHOUT_PAGE 0x0F 59 | #define ADIS_DIAG_STS_REG \ 60 | (ADIS_PAGE_ID_VAL * ADIS_DIAG_STS_PAGE_ID + ADIS_DIAG_STS_REG_WITHOUT_PAGE) 61 | 62 | #define ADIS_GYRO_ACCEL_FAIL_REG ADIS_DIAG_STS_REG 63 | #define ADIS_GYRO_X_FAIL_POS 0 64 | #define ADIS_GYRO_Y_FAIL_POS 2 65 | #define ADIS_GYRO_Z_FAIL_POS 4 66 | #define ADIS_ACCEL_X_FAIL_POS 6 67 | #define ADIS_ACCEL_Y_FAIL_POS 8 68 | #define ADIS_ACCEL_Z_FAIL_POS 10 69 | 70 | #define ADIS_GYRO_X_FAIL (3 << ADIS_GYRO_X_FAIL_POS) 71 | #define ADIS_GYRO_Y_FAIL (3 << ADIS_GYRO_Y_FAIL_POS) 72 | #define ADIS_GYRO_Z_FAIL (3 << ADIS_GYRO_Z_FAIL_POS) 73 | #define ADIS_ACCEL_X_FAIL (3 << ADIS_ACCEL_X_FAIL_POS) 74 | #define ADIS_ACCEL_Y_FAIL (3 << ADIS_ACCEL_Y_FAIL_POS) 75 | #define ADIS_ACCEL_Z_FAIL (3 << ADIS_ACCEL_Z_FAIL_POS) 76 | 77 | // measurement range identifier 78 | #define ADIS_RANG_MDL_PAGE_ID 0x00 79 | #define ADIS_RANG_MDL_ADDR_WITHOUT_PAGE 0x10 80 | #define ADIS_RANG_MDL_ADDR \ 81 | (ADIS_PAGE_ID_VAL * ADIS_RANG_MDL_PAGE_ID + ADIS_RANG_MDL_ADDR_WITHOUT_PAGE) 82 | 83 | // point of percussion 84 | #define ADIS_PT_OF_PERC_PAGE_ID 0x00 85 | #define ADIS_PT_OF_PERC_REG_ADDR_WITHOUT_PAGE 0x52 86 | #define ADIS_PT_OF_PERC_REG_ADDR \ 87 | (ADIS_PAGE_ID_VAL * ADIS_PT_OF_PERC_PAGE_ID + ADIS_PT_OF_PERC_REG_ADDR_WITHOUT_PAGE) 88 | #define ADIS_PT_OF_PERC_ALGNMNT_POS 4 89 | #define ADIS_PT_OF_PERC_ALGNMNT (1 << ADIS_PT_OF_PERC_ALGNMNT_POS) 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /include/adi_imu/adis1657x/adis1657x_data_access.h: -------------------------------------------------------------------------------- 1 | #ifndef ADIS1657X_DATA_ACCESS_H 2 | #define ADIS1657X_DATA_ACCESS_H 3 | 4 | #define ADIS_HAS_DELTA_BURST 5 | 6 | #define ADIS_FLS_MEM_ENDURANCE 100000 7 | #define ADIS_MAX_SAMP_FREQ 4100.0 8 | 9 | #define ADIS_DIAG_STAT_ADDR 0x02 10 | #define ADIS_SNSR_INIT_FAIL_POS 0 11 | #define ADIS_DATA_PATH_OVERRUN_POS 1 12 | #define ADIS_FLS_MEM_UPDATE_FAIL_POS 2 13 | #define ADIS_SPI_COMM_ERR_POS 3 14 | #define ADIS_STDBY_MODE_POS 4 15 | #define ADIS_SNSR_FAIL_POS 5 16 | #define ADIS_MEM_FAIL_POS 6 17 | #define ADIS_CLK_ERR_POS 7 18 | #define ADIS_DATA_PATH_OVERRUN (1 << ADIS_DATA_PATH_OVERRUN_POS) 19 | #define ADIS_FLS_MEM_UPDATE_FAIL (1 << ADIS_FLS_MEM_UPDATE_FAIL_POS) 20 | #define ADIS_SPI_COMM_ERR (1 << ADIS_SPI_COMM_ERR_POS) 21 | #define ADIS_STDBY_MODE (1 << ADIS_STDBY_MODE_POS) 22 | #define ADIS_SNSR_FAIL (1 << ADIS_SNSR_FAIL_POS) 23 | #define ADIS_MEM_FAIL (1 << ADIS_MEM_FAIL_POS) 24 | #define ADIS_ADUC_MCU_FAULT (1 << ADIS_ADUC_MCU_FAULT_POS) 25 | 26 | #define ADIS_GYRO_ACCEL_FAIL_REG ADIS_DIAG_STAT_ADDR 27 | #define ADIS_GYRO_X_FAIL_POS 8 28 | #define ADIS_GYRO_Y_FAIL_POS 9 29 | #define ADIS_GYRO_Z_FAIL_POS 10 30 | #define ADIS_ACCEL_X_FAIL_POS 11 31 | #define ADIS_ACCEL_Y_FAIL_POS 12 32 | #define ADIS_ACCEL_Z_FAIL_POS 13 33 | #define ADIS_ADUC_MCU_FAULT_POS 15 34 | #define ADIS_CLK_ERR (1 << ADIS_CLK_ERR_POS) 35 | #define ADIS_GYRO_X_FAIL (1 << ADIS_GYRO_X_FAIL_POS) 36 | #define ADIS_GYRO_Y_FAIL (1 << ADIS_GYRO_Y_FAIL_POS) 37 | #define ADIS_GYRO_Z_FAIL (1 << ADIS_GYRO_Z_FAIL_POS) 38 | #define ADIS_ACCEL_X_FAIL (1 << ADIS_ACCEL_X_FAIL_POS) 39 | #define ADIS_ACCEL_Y_FAIL (1 << ADIS_ACCEL_Y_FAIL_POS) 40 | #define ADIS_ACCEL_Z_FAIL (1 << ADIS_ACCEL_Z_FAIL_POS) 41 | 42 | #define ADIS_RANG_MDL_ADDR 0x5E 43 | #define ADIS_GYRO_MEAS_RANG_POS 2 44 | #define ADIS_GYRO_MEAS_RANG (3 << ADIS_GYRO_MEAS_RANG_POS) 45 | 46 | #define ADIS_MSC_CTRL_ADDR 0x60 47 | #define ADIS_DR_POL_POS 0 48 | #define ADIS_SYNC_POL_POS 1 49 | #define ADIS_LN_ACCL_COMP_POS 7 50 | #define ADIS_SENS_BW_POS 12 51 | 52 | #define ADIS_DR_POL (1 << ADIS_DR_POL_POS) 53 | #define ADIS_SYNC_POL (1 << ADIS_SYNC_POL_POS) 54 | #define ADIS_LN_ACCL_COMP (1 << ADIS_LN_ACCL_COMP_POS) 55 | #define ADIS_SENS_BW (1 << ADIS_SENS_BW_POS) 56 | 57 | #define ADIS_NULL_CNFG_ADDR 0x66 58 | #define ADIS_TIME_BASE_CONTROL_POS 0 59 | #define ADIS_X_AXIS_GYRO_BIAS_CORR_EN_POS 8 60 | #define ADIS_Y_AXIS_GYRO_BIAS_CORR_EN_POS 9 61 | #define ADIS_Z_AXIS_GYRO_BIAS_CORR_EN_POS 10 62 | #define ADIS_X_AXIS_ACCEL_BIAS_CORR_EN_POS 11 63 | #define ADIS_Y_AXIS_ACCEL_BIAS_CORR_EN_POS 12 64 | #define ADIS_Z_AXIS_ACCEL_BIAS_CORR_EN_POS 13 65 | 66 | #define ADIS_TIME_BASE_CONTROL 0xF 67 | #define ADIS_X_AXIS_GYRO_BIAS_CORR_EN (1 << ADIS_X_AXIS_GYRO_BIAS_CORR_EN_POS) 68 | #define ADIS_Y_AXIS_GYRO_BIAS_CORR_EN (1 << ADIS_Y_AXIS_GYRO_BIAS_CORR_EN_POS) 69 | #define ADIS_Z_AXIS_GYRO_BIAS_CORR_EN (1 << ADIS_Z_AXIS_GYRO_BIAS_CORR_EN_POS) 70 | #define ADIS_X_AXIS_ACCEL_BIAS_CORR_EN (1 << ADIS_X_AXIS_ACCEL_BIAS_CORR_EN_POS) 71 | #define ADIS_Y_AXIS_ACCEL_BIAS_CORR_EN (1 << ADIS_Y_AXIS_ACCEL_BIAS_CORR_EN_POS) 72 | #define ADIS_Z_AXIS_ACCEL_BIAS_CORR_EN (1 << ADIS_Z_AXIS_ACCEL_BIAS_CORR_EN_POS) 73 | 74 | #define ADIS_GLOB_CMD_ADDR 0x68 75 | #define ADIS_BIAS_CORRECTION_UPDATE (1 << 0) 76 | #define ADIS_FACTORY_CALIBRATION_RESTORE (1 << 1) 77 | #define ADIS_SENSOR_SELF_TEST (1 << 2) 78 | #define ADIS_FLASH_MEMORY_UPDATE (1 << 3) 79 | #define ADIS_FLASH_MEMORY_TEST (1 << 4) 80 | #define ADIS_SOFTWARE_RESET_CMD (1 << 7) 81 | 82 | // Point of percussion 83 | #define ADIS_PT_OF_PERC_REG_ADDR ADIS_MSC_CTRL_ADDR 84 | #define ADIS_PT_OF_PERC_ALGNMNT_POS 6 85 | #define ADIS_PT_OF_PERC_ALGNMNT (1 << ADIS_PT_OF_PERC_ALGNMNT_POS) 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /include/adi_imu/adis_data_access.h: -------------------------------------------------------------------------------- 1 | #ifndef ADIS_DATA_ACCESS_H 2 | #define ADIS_DATA_ACCESS_H 3 | 4 | #define DELTAVEL_DELTAANG_BUFFERED_DATA 0 5 | #define ACCEL_GYRO_BUFFERED_DATA 1 6 | #define IMU_STD_MSG_DATA 2 7 | #define FULL_MEASURED_DATA 3 8 | 9 | #define ADIS_DELTANG_X_LOW_REG 0x24 10 | #define ADIS_DELTANG_X_OUT_REG 0x26 11 | #define ADIS_DELTANG_Y_LOW_REG 0x28 12 | #define ADIS_DELTANG_Y_OUT_REG 0x2A 13 | #define ADIS_DELTANG_Z_LOW_REG 0x2C 14 | #define ADIS_DELTANG_Z_OUT_REG 0x2E 15 | #define ADIS_DELTVEL_X_LOW_REG 0x30 16 | #define ADIS_DELTVEL_X_OUT_REG 0x32 17 | #define ADIS_DELTVEL_Y_LOW_REG 0x34 18 | #define ADIS_DELTVEL_Y_OUT_REG 0x36 19 | #define ADIS_DELTVEL_Z_LOW_REG 0x38 20 | #define ADIS_DELTVEL_Z_OUT_REG 0x3A 21 | 22 | enum adis_device_id 23 | { 24 | ADIS16465_1, 25 | ADIS16465_2, 26 | ADIS16465_3, 27 | ADIS16467_1, 28 | ADIS16467_2, 29 | ADIS16467_3, 30 | ADIS16470, 31 | ADIS16475_1, 32 | ADIS16475_2, 33 | ADIS16475_3, 34 | ADIS16477_1, 35 | ADIS16477_2, 36 | ADIS16477_3, 37 | ADIS16500, 38 | ADIS16501, 39 | ADIS16505_1, 40 | ADIS16505_2, 41 | ADIS16505_3, 42 | ADIS16507_1, 43 | ADIS16507_2, 44 | ADIS16507_3, 45 | ADIS16545_1, 46 | ADIS16545_2, 47 | ADIS16545_3, 48 | ADIS16547_1, 49 | ADIS16547_2, 50 | ADIS16547_3, 51 | ADIS16550, 52 | ADIS16575_2, 53 | ADIS16575_3, 54 | ADIS16576_2, 55 | ADIS16576_3, 56 | ADIS16577_2, 57 | ADIS16577_3, 58 | }; 59 | 60 | #if defined(ADIS1646X) 61 | #include "adis1646x/adis1646x_data_access.h" 62 | #elif defined(ADIS1647X) 63 | #include "adis1647x/adis1647x_data_access.h" 64 | #elif defined(ADIS1650X) 65 | #include "adis1650x/adis1650x_data_access.h" 66 | #elif defined(ADIS1654X) 67 | #include "adis1654x/adis1654x_data_access.h" 68 | #elif defined(ADIS1655X) 69 | #include "adis1655x/adis1655x_data_access.h" 70 | #elif defined(ADIS1657X) 71 | #include "adis1657x/adis1657x_data_access.h" 72 | #else 73 | #error "No device defined." 74 | #endif 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /include/adi_imu/imu_data_provider.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_ros_publisher.h 3 | * @brief Header for providing IMU ros standard data. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #ifndef IMU_DATA_PROVIDER_H 22 | #define IMU_DATA_PROVIDER_H 23 | 24 | #include "adi_imu/iio_wrapper.h" 25 | #include "adi_imu/imu_data_provider_interface.h" 26 | 27 | /** 28 | * @brief Class for standard message sensor_msgs::msg::Imu data provider. 29 | */ 30 | class ImuDataProvider : public ImuDataProviderInterface 31 | { 32 | public: 33 | /** 34 | * @brief Constructor for ImuDataProvider. 35 | */ 36 | ImuDataProvider(); 37 | 38 | /** 39 | * @brief Destructor for ImuDataProvider. 40 | */ 41 | ~ImuDataProvider(); 42 | 43 | /** 44 | * @brief Populate Imu message with measured data. 45 | * @param message Message containing the measured data. 46 | * @return Return true if the message parameter is successfully populated with 47 | * measured data and false otherwise. 48 | */ 49 | bool getData(sensor_msgs::msg::Imu & message) override; 50 | 51 | private: 52 | /*! This data member is used to access sensor information via libiio. */ 53 | IIOWrapper m_iio_wrapper; 54 | }; 55 | 56 | #endif // IMU_DATA_PROVIDER_H 57 | -------------------------------------------------------------------------------- /include/adi_imu/imu_data_provider_interface.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_ros_publisher_interface.h 3 | * @brief Interface for providing IMU ros standard data. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #ifndef IMU_DATA_PROVIDER_INTERFACE_H 22 | #define IMU_DATA_PROVIDER_INTERFACE_H 23 | 24 | #include 25 | 26 | /** 27 | * @brief Interface for standard message sensor_msgs::msg::Imu data provider. 28 | */ 29 | class ImuDataProviderInterface 30 | { 31 | public: 32 | /** 33 | * @brief Constructor for ImuDataProviderInterface. 34 | */ 35 | ImuDataProviderInterface() {} 36 | 37 | /** 38 | * @brief Destructor for ImuDataProviderInterface. 39 | */ 40 | virtual ~ImuDataProviderInterface() {} 41 | 42 | /** 43 | * @brief Populate Imu message with measured data. 44 | * @param message Message containing the measured data. 45 | * @return Return true if the message parameter is successfully populated with 46 | * measured data and false otherwise. 47 | */ 48 | virtual bool getData(sensor_msgs::msg::Imu & message) = 0; 49 | }; 50 | 51 | #endif // IMU_DATA_PROVIDER_INTERFACE_H 52 | -------------------------------------------------------------------------------- /include/adi_imu/imu_diag_data_provider.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_diag_data_provider.h 3 | * @brief Header for providing diagnosis data for adis. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #ifndef IMU_DIAG_DATA_PROVIDER_H 22 | #define IMU_DIAG_DATA_PROVIDER_H 23 | 24 | #include "adi_imu/iio_wrapper.h" 25 | #include "imu_diag_data_provider_interface.h" 26 | 27 | /** 28 | * @brief Class for diagnosis data provider for adis chips. 29 | */ 30 | class ImuDiagDataProvider : public ImuDiagDataProviderInterface 31 | { 32 | public: 33 | /** 34 | * @brief Constructor for ImuDiagDataProvider. 35 | */ 36 | ImuDiagDataProvider(); 37 | 38 | /** 39 | * @brief Destructor for ImuDiagDataProvider. 40 | */ 41 | ~ImuDiagDataProvider(); 42 | 43 | /** 44 | * @brief Populate ImuDiagData message with diagnosis data. 45 | * @param message Message containing the diagnosis data. 46 | * @return Return true if the message parameter is successfully populated with 47 | * diagnosis data and false otherwise. 48 | */ 49 | bool getData(adi_imu::msg::ImuDiagData & message) override; 50 | 51 | private: 52 | /*! This data member is used to access sensor information via libiio. */ 53 | IIOWrapper m_iio_wrapper; 54 | }; 55 | 56 | #endif // IMU_DIAG_DATA_PROVIDER_H 57 | -------------------------------------------------------------------------------- /include/adi_imu/imu_diag_data_provider_interface.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_diag_data_provider_interface.h 3 | * @brief Interface for providing diagnosis data for adis. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #ifndef IMU_DIAG_DATA_PROVIDER_INTERFACE_H 22 | #define IMU_DIAG_DATA_PROVIDER_INTERFACE_H 23 | 24 | #include "adi_imu/msg/imu_diag_data.hpp" 25 | 26 | /** 27 | * @brief Interface for diagnosis data provider for adis chips. 28 | */ 29 | class ImuDiagDataProviderInterface 30 | { 31 | public: 32 | /** 33 | * @brief Constructor for ImuDiagDataProviderInterface. 34 | */ 35 | ImuDiagDataProviderInterface() {} 36 | 37 | /** 38 | * @brief Destructor for ImuDiagDataProviderInterface. 39 | */ 40 | virtual ~ImuDiagDataProviderInterface() {} 41 | 42 | /** 43 | * @brief Populate ImuDiagData message with diagnosis data. 44 | * @param message Message containing the diagnosis data. 45 | * @return Return true if the message parameter is successfully populated with 46 | * diagnosis data and false otherwise. 47 | */ 48 | virtual bool getData(adi_imu::msg::ImuDiagData & message) = 0; 49 | }; 50 | 51 | #endif // IMU_DIAG_DATA_PROVIDER_INTERFACE_H 52 | -------------------------------------------------------------------------------- /include/adi_imu/imu_diag_ros_publisher.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_diag_ros_publisher.h 3 | * @brief Header for adis1657x diagnosis publisher. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #ifndef IMU_DIAG_ROS_PUBLISHER_H 22 | #define IMU_DIAG_ROS_PUBLISHER_H 23 | 24 | #include 25 | 26 | #include "imu_diag_data_provider_interface.h" 27 | #include "imu_diag_ros_publisher_interface.h" 28 | 29 | /** 30 | * @brief Class for diagnosis publisher for adis1657x chips. 31 | */ 32 | class ImuDiagRosPublisher : public ImuDiagRosPublisherInterface 33 | { 34 | public: 35 | /** 36 | * @brief Constructor for ImuDiagRosPublisher. 37 | * @param node The ros2 Node instance. 38 | */ 39 | ImuDiagRosPublisher(std::shared_ptr & node); 40 | 41 | /** 42 | * @brief Destructor for ImuDiagRosPublisher. 43 | */ 44 | ~ImuDiagRosPublisher(); 45 | 46 | /** 47 | * @brief Set the message data provider. 48 | * @param dataProvider Data provider. 49 | */ 50 | void setMessageProvider(ImuDiagDataProviderInterface * dataProvider) override; 51 | 52 | /** 53 | * @brief Run the thread responsible for publishing ImuDiagData message. 54 | */ 55 | void run() override; 56 | 57 | private: 58 | /*! This variable retains the data provider instance. */ 59 | ImuDiagDataProviderInterface * m_data_provider; 60 | 61 | /*! This variable retains the publisher instance. */ 62 | rclcpp::Publisher::SharedPtr m_publisher; 63 | 64 | /*! This variable retains the message that is published. */ 65 | adi_imu::msg::ImuDiagData m_message; 66 | }; 67 | 68 | #endif // IMU_DIAG_ROS_PUBLISHER_H 69 | -------------------------------------------------------------------------------- /include/adi_imu/imu_diag_ros_publisher_interface.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_diag_ros_publisher_interface.h 3 | * @brief Interface for adis diagnosis publisher. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #ifndef IMU_DIAG_ROS_PUBLISHER_INTERFACE_H 22 | #define IMU_DIAG_ROS_PUBLISHER_INTERFACE_H 23 | 24 | #include 25 | #include 26 | 27 | #include "adi_imu/ros_task.h" 28 | 29 | class ImuDiagDataProviderInterface; 30 | 31 | /** 32 | * @brief Interface for diagnosis publisher for adis chips. 33 | */ 34 | class ImuDiagRosPublisherInterface : public RosTask 35 | { 36 | public: 37 | /** 38 | * @brief Constructor for ImuDiagRosPublisherInterface. 39 | */ 40 | ImuDiagRosPublisherInterface() {} 41 | 42 | /** 43 | * @brief Destructor for ImuDiagRosPublisherInterface. 44 | */ 45 | virtual ~ImuDiagRosPublisherInterface() {} 46 | 47 | /** 48 | * @brief Set the message data provider. 49 | * @param dataProvider Data provider. 50 | */ 51 | virtual void setMessageProvider(ImuDiagDataProviderInterface * dataProvider) = 0; 52 | 53 | protected: 54 | /*! The ros2 Node data member. */ 55 | std::shared_ptr m_node; 56 | }; 57 | 58 | #endif // IMU_DIAG_ROS_PUBLISHER_INTERFACE_H 59 | -------------------------------------------------------------------------------- /include/adi_imu/imu_full_measured_data_provider.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_full_measured_data_provider.h 3 | * @brief Header for providing acceleration, gyroscope, temperature, 4 | * delta velocity, delta angle and temperature data. 5 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 6 | ******************************************************************************* 7 | * Copyright 2023(c) Analog Devices, Inc. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | ******************************************************************************/ 21 | 22 | #ifndef IMU_FULL_MEASURED_DATA_PROVIDER_H 23 | #define IMU_FULL_MEASURED_DATA_PROVIDER_H 24 | 25 | #include "adi_imu/iio_wrapper.h" 26 | #include "adi_imu/imu_full_measured_data_provider_interface.h" 27 | 28 | /** 29 | * @brief Class for acceleration, angular velocity, delta angle, delta velocity 30 | * and temperature data provider. 31 | */ 32 | class ImuFullMeasuredDataProvider : public ImuFullMeasuredDataProviderInterface 33 | { 34 | public: 35 | /** 36 | * @brief Constructor for ImuFullMeasuredDataProvider. 37 | */ 38 | ImuFullMeasuredDataProvider(); 39 | 40 | /** 41 | * @brief Destructor for ImuFullMeasuredDataProvider. 42 | */ 43 | ~ImuFullMeasuredDataProvider(); 44 | 45 | /** 46 | * @brief Populate ImuFullMeasuredData message with measured data. 47 | * @param message Message containing the measured data. 48 | * @return Return true if the message parameter is successfully populated with 49 | * measured data and false otherwise. 50 | */ 51 | bool getData(adi_imu::msg::ImuFullMeasuredData & message) override; 52 | 53 | private: 54 | /*! This data member is used to access sensor information via libiio. */ 55 | IIOWrapper m_iio_wrapper; 56 | }; 57 | 58 | #endif // IMU_FULL_MEASURED_DATA_PROVIDER_H 59 | -------------------------------------------------------------------------------- /include/adi_imu/imu_full_measured_data_provider_interface.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_full_measured_data_provider_interface.h 3 | * @brief Interface for providing acceleration, gyroscope, temperature, 4 | * delta velocity, delta angle and temperature data. 5 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 6 | ******************************************************************************* 7 | * Copyright 2023(c) Analog Devices, Inc. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | ******************************************************************************/ 21 | 22 | #ifndef IMU_FULL_MEASURED_DATA_PROVIDER_INTERFACE_H 23 | #define IMU_FULL_MEASURED_DATA_PROVIDER_INTERFACE_H 24 | 25 | #include "adi_imu/msg/imu_full_measured_data.hpp" 26 | 27 | /** 28 | * @brief Interface for acceleration, angular velocity, delta angle, delta 29 | * velocity and temperature data provider. 30 | */ 31 | class ImuFullMeasuredDataProviderInterface 32 | { 33 | public: 34 | /** 35 | * @brief Constructor for ImuFullMeasuredDataProviderInterface. 36 | */ 37 | ImuFullMeasuredDataProviderInterface() {} 38 | 39 | /** 40 | * @brief Destructor for ImuFullMeasuredDataProviderInterface. 41 | */ 42 | virtual ~ImuFullMeasuredDataProviderInterface() {} 43 | 44 | /** 45 | * @brief Populate ImuFullMeasuredData message with measured data. 46 | * @param message Message containing the measured data. 47 | * @return Return true if the message parameter is successfully populated with 48 | * measured data and false otherwise. 49 | */ 50 | virtual bool getData(adi_imu::msg::ImuFullMeasuredData & message) = 0; 51 | }; 52 | 53 | #endif // IMU_FULL_MEASURED_DATA_PROVIDER_INTERFACE_H 54 | -------------------------------------------------------------------------------- /include/adi_imu/imu_full_measured_data_ros_publisher.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_full_measured_data_ros_publisher.h 3 | * @brief Header for acceleration, gyroscope, temperature, delta velocity, 4 | * delta angle and temperature publisher. 5 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 6 | ******************************************************************************* 7 | * Copyright 2023(c) Analog Devices, Inc. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | ******************************************************************************/ 21 | 22 | #ifndef IMU_FULL_MEASURED_DATA_ROS_PUBLISHER_H 23 | #define IMU_FULL_MEASURED_DATA_ROS_PUBLISHER_H 24 | 25 | #include 26 | 27 | #include "adi_imu/imu_full_measured_data_provider_interface.h" 28 | #include "adi_imu/imu_full_measured_data_ros_publisher_interface.h" 29 | 30 | /** 31 | * @brief Class for acceleration, angular velocity, delta angle, delta velocity 32 | * and temperature publisher. 33 | */ 34 | class ImuFullMeasuredDataRosPublisher : public ImuFullMeasuredDataRosPublisherInterface 35 | { 36 | public: 37 | /** 38 | * @brief Constructor for ImuFullMeasuredDataRosPublisher. 39 | * @param node The ros2 Node instance. 40 | */ 41 | ImuFullMeasuredDataRosPublisher(std::shared_ptr & node); 42 | 43 | /** 44 | * @brief Destructor for AccelGyroTempRosPublisher. 45 | */ 46 | ~ImuFullMeasuredDataRosPublisher(); 47 | 48 | /** 49 | * @brief Set the message data provider. 50 | * @param dataProvider Data provider. 51 | */ 52 | void setMessageProvider(ImuFullMeasuredDataProviderInterface * dataProvider) override; 53 | 54 | /** 55 | * @brief Publish the ImuFullMeasuredData message. 56 | */ 57 | void publish() override; 58 | 59 | private: 60 | /*! This variable retains the data provider instance. */ 61 | ImuFullMeasuredDataProviderInterface * m_data_provider; 62 | 63 | /*! This variable retains the publisher instance. */ 64 | rclcpp::Publisher::SharedPtr m_publisher; 65 | 66 | /*! This variable retains the message that is published. */ 67 | adi_imu::msg::ImuFullMeasuredData m_message; 68 | }; 69 | 70 | #endif // IMU_FULL_MEASURED_DATA_ROS_PUBLISHER_H 71 | -------------------------------------------------------------------------------- /include/adi_imu/imu_full_measured_data_ros_publisher_interface.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_full_measured_data_ros_publisher_interface.h 3 | * @brief Interface for acceleration, gyroscope, temperature, delta velocity, 4 | * delta angle and temperature publisher. 5 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 6 | ******************************************************************************* 7 | * Copyright 2023(c) Analog Devices, Inc. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | ******************************************************************************/ 21 | 22 | #ifndef IMU_FULL_MEASURED_DATA_ROS_PUBLISHER_INTERFACE_H 23 | #define IMU_FULL_MEASURED_DATA_ROS_PUBLISHER_INTERFACE_H 24 | 25 | #include 26 | #include 27 | 28 | class ImuFullMeasuredDataProviderInterface; 29 | 30 | /** 31 | * @brief Interface for acceleration, angular velocity, delta angle, delta 32 | * velocity and temperature publisher. 33 | */ 34 | class ImuFullMeasuredDataRosPublisherInterface 35 | { 36 | public: 37 | /** 38 | * @brief Constructor for ImuFullMeasuredDataRosPublisherInterface. 39 | */ 40 | ImuFullMeasuredDataRosPublisherInterface() {} 41 | 42 | /** 43 | * @brief Destructor for ImuFullMeasuredDataRosPublisherInterface. 44 | */ 45 | virtual ~ImuFullMeasuredDataRosPublisherInterface() {} 46 | 47 | /** 48 | * @brief Set the message data provider. 49 | * @param dataProvider Data provider. 50 | */ 51 | virtual void setMessageProvider(ImuFullMeasuredDataProviderInterface * dataProvider) = 0; 52 | 53 | /** 54 | * @brief Publish the ImuFullMeasuredData message. 55 | */ 56 | virtual void publish() = 0; 57 | 58 | protected: 59 | /*! The ros2 Node data member. */ 60 | std::shared_ptr m_node; 61 | }; 62 | 63 | #endif // IMU_FULL_MEASURED_DATA_ROS_PUBLISHER_INTERFACE_H 64 | -------------------------------------------------------------------------------- /include/adi_imu/imu_identification_data_provider.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ /** 2 | * @file imu_identification_data_provider.h 3 | * @brief Header for providing imu identification data. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | *******************************************************************************/ 20 | 21 | #ifndef IMU_IDENTIFICATION_DATA_PROVIDER_H 22 | #define IMU_IDENTIFICATION_DATA_PROVIDER_H 23 | 24 | #include "adi_imu/iio_wrapper.h" 25 | #include "adi_imu/imu_identification_data_provider_interface.h" 26 | 27 | /** 28 | * @brief Class for identification data provider. 29 | */ 30 | class ImuIdentificationDataProvider : public ImuIdentificationDataProviderInterface 31 | { 32 | public: 33 | /** 34 | * @brief Constructor for ImuIdentificationDataProvider. 35 | */ 36 | ImuIdentificationDataProvider(); 37 | 38 | /** 39 | * @brief Destructor for ImuIdentificationDataProvider. 40 | */ 41 | ~ImuIdentificationDataProvider(); 42 | 43 | /** 44 | * @brief Populate ImuIdentificationData message with identification data. 45 | * @param message Message containing the identification data. 46 | * @return Return true if the message parameter is successfully populated with 47 | * identification data and false otherwise. 48 | */ 49 | bool getData(adi_imu::msg::ImuIdentificationData & message) override; 50 | 51 | private: 52 | /*! This data member is used to access sensor information via libiio. */ 53 | IIOWrapper m_iio_wrapper; 54 | }; 55 | 56 | #endif // IMU_IDENTIFICATION_DATA_PROVIDER_STRING_H 57 | -------------------------------------------------------------------------------- /include/adi_imu/imu_identification_data_provider_interface.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_identification_data_provider_interface.h 3 | * @brief Interface for providing imu identification data. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #ifndef IMU_IDENTIFICATION_DATA_PROVIDER_INTERFACE_H 22 | #define IMU_IDENTIFICATION_DATA_PROVIDER_INTERFACE_H 23 | 24 | #include "adi_imu/msg/imu_identification_data.hpp" 25 | 26 | /** 27 | * @brief Interface for identification data provider. 28 | */ 29 | class ImuIdentificationDataProviderInterface 30 | { 31 | public: 32 | /** 33 | * @brief Constructor for ImuIdentificationDataProviderInterface. 34 | */ 35 | ImuIdentificationDataProviderInterface() {} 36 | 37 | /** 38 | * @brief Destructor for ImuIdentificationDataProviderInterface. 39 | */ 40 | virtual ~ImuIdentificationDataProviderInterface() {} 41 | 42 | /** 43 | * @brief Populate ImuIdentificationData message with identification data. 44 | * @param message Message containing the identification data. 45 | * @return Return true if the message parameter is successfully populated with 46 | * identification data and false otherwise. 47 | */ 48 | virtual bool getData(adi_imu::msg::ImuIdentificationData & message) = 0; 49 | }; 50 | 51 | #endif // IMU_IDENTIFICATION_DATA_PROVIDER_INTERFACE_H 52 | -------------------------------------------------------------------------------- /include/adi_imu/imu_identification_ros_publisher.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_identification_ros_publisher.h 3 | * @brief Header for imu identification publisher. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #ifndef IMU_IDENTIFICATION_ROS_PUBLISHER_H 22 | #define IMU_IDENTIFICATION_ROS_PUBLISHER_H 23 | 24 | #include 25 | 26 | #include "adi_imu/imu_identification_data_provider_interface.h" 27 | #include "adi_imu/imu_identification_ros_publisher_interface.h" 28 | 29 | /** 30 | * @brief Class for identification publisher. 31 | */ 32 | class ImuIdentificationRosPublisher : public ImuIdentificationRosPublisherInterface 33 | { 34 | public: 35 | /** 36 | * @brief Constructor for ImuIdentificationRosPublisher. 37 | * @param node The ros2 Node instance. 38 | */ 39 | ImuIdentificationRosPublisher(std::shared_ptr & node); 40 | 41 | /** 42 | * @brief Destructor for ImuIdentificationRosPublisher. 43 | */ 44 | ~ImuIdentificationRosPublisher(); 45 | 46 | /** 47 | * @brief Set the message data provider. 48 | * @param dataProvider Data provider. 49 | */ 50 | void setMessageProvider(ImuIdentificationDataProviderInterface * dataProvider) override; 51 | 52 | /** 53 | * @brief Run the thread responsible for publishing ImuIdentificationData 54 | * message. 55 | */ 56 | void run() override; 57 | 58 | private: 59 | /*! This variable retains the data provider instance. */ 60 | ImuIdentificationDataProviderInterface * m_data_provider; 61 | 62 | /*! This variable retains the publisher instance. */ 63 | rclcpp::Publisher::SharedPtr m_publisher; 64 | 65 | /*! This variable retains the message that is published. */ 66 | adi_imu::msg::ImuIdentificationData m_message; 67 | }; 68 | 69 | #endif // IMU_IDENTIFICATION_ROS_PUBLISHER_H 70 | -------------------------------------------------------------------------------- /include/adi_imu/imu_identification_ros_publisher_interface.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_identification_ros_publisher_interface.h 3 | * @brief Interface for imu identification publisher. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #ifndef IMU_IDENTIFICATION_ROS_PUBLISHER_INTERFACE_H 22 | #define IMU_IDENTIFICATION_ROS_PUBLISHER_INTERFACE_H 23 | 24 | #include 25 | #include 26 | 27 | #include "adi_imu/ros_task.h" 28 | 29 | class ImuIdentificationDataProviderInterface; 30 | 31 | /** 32 | * @brief Interface for identification publisher. 33 | */ 34 | class ImuIdentificationRosPublisherInterface : public RosTask 35 | { 36 | public: 37 | /** 38 | * @brief Constructor for ImuIdentificationRosPublisherInterface. 39 | */ 40 | ImuIdentificationRosPublisherInterface() {} 41 | 42 | /** 43 | * @brief Destructor for ImuIdentificationRosPublisherInterface. 44 | */ 45 | virtual ~ImuIdentificationRosPublisherInterface() {} 46 | 47 | /** 48 | * @brief Set the message data provider. 49 | * @param dataProvider Data provider. 50 | */ 51 | virtual void setMessageProvider(ImuIdentificationDataProviderInterface * dataProvider) = 0; 52 | 53 | protected: 54 | /*! The ros2 Node data member. */ 55 | std::shared_ptr m_node; 56 | }; 57 | 58 | #endif // IMU_IDENTIFICATION_ROS_PUBLISHER_INTERFACE_H 59 | -------------------------------------------------------------------------------- /include/adi_imu/imu_ros_publisher.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_ros_publisher.h 3 | * @brief Header for IMU ros standard message publisher. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #ifndef IMU_ROS_PUBLISHER_H 22 | #define IMU_ROS_PUBLISHER_H 23 | 24 | #include 25 | 26 | #include "adi_imu/imu_data_provider_interface.h" 27 | #include "adi_imu/imu_ros_publisher_interface.h" 28 | 29 | /** 30 | * @brief Class for standard message sensor_msgs::msg::Imu publisher. 31 | */ 32 | class ImuRosPublisher : public ImuRosPublisherInterface 33 | { 34 | public: 35 | /** 36 | * @brief Constructor for ImuRosPublisher. 37 | * @param node The ros2 Node instance. 38 | */ 39 | ImuRosPublisher(std::shared_ptr & node); 40 | 41 | /** 42 | * @brief Destructor for ImuRosPublisher. 43 | */ 44 | ~ImuRosPublisher(); 45 | 46 | /** 47 | * @brief Set the message data provider. 48 | * @param dataProvider Data provider. 49 | */ 50 | void setMessageProvider(ImuDataProviderInterface * dataProvider) override; 51 | 52 | /** 53 | * @brief Publish the sensor_msgs::msg::Imu message. 54 | */ 55 | void publish() override; 56 | 57 | private: 58 | /*! This variable retains the data provider instance. */ 59 | ImuDataProviderInterface * m_data_provider; 60 | 61 | /*! This variable retains the publisher instance. */ 62 | rclcpp::Publisher::SharedPtr m_publisher; 63 | 64 | /*! This variable retains the message that is published. */ 65 | sensor_msgs::msg::Imu m_message; 66 | }; 67 | 68 | #endif // IMU_ROS_PUBLISHER_H 69 | -------------------------------------------------------------------------------- /include/adi_imu/imu_ros_publisher_interface.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_ros_publisher_interface.h 3 | * @brief Interface for IMU ros standard message publisher. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #ifndef ACCELERATION_ROS_PUBLISHER_INTERFACE_H 22 | #define ACCELERATION_ROS_PUBLISHER_INTERFACE_H 23 | 24 | #include 25 | #include 26 | 27 | class ImuDataProviderInterface; 28 | 29 | /** 30 | * @brief Interface for standard message sensor_msgs::msg::Imu publisher. 31 | */ 32 | class ImuRosPublisherInterface 33 | { 34 | public: 35 | /** 36 | * @brief Constructor for ImuRosPublisherInterface. 37 | */ 38 | ImuRosPublisherInterface() {} 39 | 40 | /** 41 | * @brief Destructor for ImuRosPublisherInterface. 42 | */ 43 | virtual ~ImuRosPublisherInterface() {} 44 | 45 | /** 46 | * @brief Set the message data provider. 47 | * @param dataProvider Data provider. 48 | */ 49 | virtual void setMessageProvider(ImuDataProviderInterface * dataProvider) = 0; 50 | 51 | /** 52 | * @brief Publish the sensor_msgs::msg::Imu message. 53 | */ 54 | virtual void publish() = 0; 55 | 56 | protected: 57 | /*! The ros2 Node data member. */ 58 | std::shared_ptr m_node; 59 | }; 60 | 61 | #endif // ACCELERATION_ROS_PUBLISHER_INTERFACE_H 62 | -------------------------------------------------------------------------------- /include/adi_imu/ros_publisher_group.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file ros_publisher_group.h 3 | * @brief Header for acceleration, gyroscope and temperature publisher. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #ifndef ROS_PUBLISHER_GROUP_H 22 | #define ROS_PUBLISHER_GROUP_H 23 | 24 | #include 25 | 26 | #include "adi_imu/ros_publisher_group_interface.h" 27 | 28 | /** 29 | * @brief Class ROS publisher group. 30 | */ 31 | class RosPublisherGroup : public RosPublisherGroupInterface 32 | { 33 | public: 34 | /** 35 | * @brief Constructor for RosPublisherGroup. 36 | * @param node The ros2 Node instance. 37 | */ 38 | RosPublisherGroup(std::shared_ptr & node); 39 | 40 | /** 41 | * @brief Destructor for RosPublisherGroup. 42 | */ 43 | ~RosPublisherGroup(); 44 | 45 | /** 46 | * @brief Sets the accelGyroTempRosPublisher publisher in the publisher group. 47 | * @param accelGyroTempRosPublisher The publisher to be set in the group. 48 | */ 49 | void setAccelGyroTempRosPublisher( 50 | AccelGyroTempRosPublisherInterface * accelGyroTempRosPublisher) override; 51 | 52 | #ifdef ADIS_HAS_DELTA_BURST 53 | /** 54 | * @brief Sets the velAngTempRosPublisher publisher in the publisher group. 55 | * @param velAngTempRosPublisher The publisher to be set in the group. 56 | */ 57 | void setVelAngTempRosPublisher(VelAngTempRosPublisherInterface * velAngTempRosPublisher) override; 58 | #endif 59 | 60 | /** 61 | * @brief Sets the imuRosPublisher publisher in the publisher group. 62 | * @param imuRosPublisher The publisher to be set in the group. 63 | */ 64 | void setImuRosPublisher(ImuRosPublisherInterface * imuRosPublisher) override; 65 | 66 | /** 67 | * @brief Sets the imuFullMeasuredDataRosPublisher publisher in the publisher 68 | * group. 69 | * @param imuFullMeasuredDataRosPublisher The imuFullMeasuredDataRosPublisher 70 | * to be set in the group. 71 | */ 72 | void setImuFullMeasuredDataRosPublisher( 73 | ImuFullMeasuredDataRosPublisherInterface * imuFullMeasuredDataRosPublisher) override; 74 | 75 | /** 76 | * @brief Sets the imuControlParameters instance in the publisher group. 77 | * @param imuControlParameters The imuControlParameters instance to be set in 78 | * the group. 79 | */ 80 | void setImuControlParameters(ImuControlParameters * imuControlParameters) override; 81 | 82 | /** 83 | * @brief Run the thread responsible for publishing messages and for 84 | * performing parameter configuration. 85 | */ 86 | void run() override; 87 | 88 | private: 89 | /*! Variable to retain AccelGyroTemp message provider. */ 90 | AccelGyroTempRosPublisherInterface * m_accelGyroTempRosPublisher; 91 | #ifdef ADIS_HAS_DELTA_BURST 92 | /*! Variable to retain VelAngTemp message provider. */ 93 | VelAngTempRosPublisherInterface * m_velAngTempRosPublisher; 94 | #endif 95 | /*! Variable to retain Imu message provider. */ 96 | ImuRosPublisherInterface * m_imuRosPublisher; 97 | /*! Variable to retain ImuFullMeasuredData message provider. */ 98 | ImuFullMeasuredDataRosPublisherInterface * m_imuFullMeasuredDataRosPublisher; 99 | /*! Variable to retain m_imuControlParameters instance. */ 100 | ImuControlParameters * m_imuControlParameters; 101 | }; 102 | 103 | #endif // ROS_PUBLISHER_GROUP_H 104 | -------------------------------------------------------------------------------- /include/adi_imu/ros_publisher_group_interface.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file ros_publisher_group_interface.h 3 | * @brief Interface for a group of publishers. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #ifndef ROS_PUBLISHER_GROUP_INTERFACE_H 22 | #define ROS_PUBLISHER_GROUP_INTERFACE_H 23 | 24 | #include 25 | #include 26 | 27 | #include "adi_imu/ros_task.h" 28 | #include "adis_data_access.h" 29 | 30 | class AccelGyroTempRosPublisherInterface; 31 | class ImuRosPublisherInterface; 32 | class VelAngTempRosPublisherInterface; 33 | class ImuFullMeasuredDataRosPublisherInterface; 34 | class ImuControlParameters; 35 | 36 | /** 37 | * @brief Interface for publisher group. 38 | */ 39 | class RosPublisherGroupInterface : public RosTask 40 | { 41 | public: 42 | /** 43 | * @brief Constructor for RosPublisherGroupInterface. 44 | */ 45 | RosPublisherGroupInterface() {} 46 | 47 | /** 48 | * @brief Destructor for RosPublisherGroupInterface. 49 | */ 50 | virtual ~RosPublisherGroupInterface() {} 51 | 52 | /** 53 | * @brief Sets the accelGyroTempRosPublisher publisher in the publisher group. 54 | * @param accelGyroTempRosPublisher The publisher to be set in the group. 55 | */ 56 | virtual void setAccelGyroTempRosPublisher( 57 | AccelGyroTempRosPublisherInterface * accelGyroTempRosPublisher) = 0; 58 | 59 | #ifdef ADIS_HAS_DELTA_BURST 60 | /** 61 | * @brief Sets the velAngTempRosPublisher publisher in the publisher group. 62 | * @param velAngTempRosPublisher The publisher to be set in the group. 63 | */ 64 | virtual void setVelAngTempRosPublisher( 65 | VelAngTempRosPublisherInterface * velAngTempRosPublisher) = 0; 66 | #endif 67 | 68 | /** 69 | * @brief Sets the imuRosPublisher publisher in the publisher group. 70 | * @param imuRosPublisher The publisher to be set in the group. 71 | */ 72 | virtual void setImuRosPublisher(ImuRosPublisherInterface * imuRosPublisher) = 0; 73 | 74 | /** 75 | * @brief Sets the imuFullMeasuredDataRosPublisher publisher in the publisher 76 | * group. 77 | * @param imuFullMeasuredDataRosPublisher The imuFullMeasuredDataRosPublisher 78 | * to be set in the group. 79 | */ 80 | virtual void setImuFullMeasuredDataRosPublisher( 81 | ImuFullMeasuredDataRosPublisherInterface * imuFullMeasuredDataRosPublisher) = 0; 82 | 83 | /** 84 | * @brief Sets the imuControlParameters instance in the publisher group. 85 | * @param imuControlParameters The imuControlParameters instance to be set in 86 | * the group. 87 | */ 88 | virtual void setImuControlParameters(ImuControlParameters * imuControlParameters) = 0; 89 | 90 | protected: 91 | /*! The ros2 Node data member. */ 92 | std::shared_ptr m_node; 93 | }; 94 | 95 | #endif // ROS_PUBLISHER_GROUP_INTERFACE_H 96 | -------------------------------------------------------------------------------- /include/adi_imu/ros_task.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file ros_task.h 3 | * @brief Header for ros imu task. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #ifndef ROS_TASK_H 22 | #define ROS_TASK_H 23 | 24 | /** 25 | * @brief Interface for running a task in a thread. 26 | */ 27 | class RosTask 28 | { 29 | public: 30 | /** 31 | * @brief Constructor for RosTask. 32 | * 33 | * This is the default constructor for interface 34 | * RosTask. 35 | * 36 | */ 37 | RosTask() {} 38 | 39 | /** 40 | * @brief Destructor for RosTask. 41 | * 42 | * This is a virtual destructor for RosTask. 43 | * 44 | */ 45 | virtual ~RosTask() {} 46 | 47 | /** 48 | * @brief Method that run on a thread. 49 | * 50 | * This function will run on a thread and a class 51 | * that implement this method will have concurrent support. 52 | * 53 | */ 54 | virtual void run() = 0; 55 | }; 56 | 57 | #endif // ROS_TASK_H 58 | -------------------------------------------------------------------------------- /include/adi_imu/velangtemp_data_provider.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file velangtemp_data_provider.h 3 | * @brief Header for providing temperature, delta velocity and delta angle 4 | * data. 5 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 6 | ******************************************************************************* 7 | * Copyright 2023(c) Analog Devices, Inc. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | ******************************************************************************/ 21 | 22 | #ifndef VELANGTEMP_DATA_PROVIDER_H 23 | #define VELANGTEMP_DATA_PROVIDER_H 24 | 25 | #include "adi_imu/iio_wrapper.h" 26 | #include "adi_imu/velangtemp_data_provider_interface.h" 27 | 28 | /** 29 | * @brief Class for delta angle, delta velocity and temperature buffered 30 | * data provider. 31 | */ 32 | class VelAngTempDataProvider : public VelAngTempDataProviderInterface 33 | { 34 | public: 35 | /** 36 | * @brief Constructor for VelAngTempDataProvider. 37 | */ 38 | VelAngTempDataProvider(); 39 | 40 | /** 41 | * @brief Destructor for VelAngTempDataProvider. 42 | */ 43 | ~VelAngTempDataProvider(); 44 | 45 | /** 46 | * @brief Populate VelAngTempData message with measured data. 47 | * @param message Message containing the measured data. 48 | * @return Return true if the message parameter is successfully populated with 49 | * measured data and false otherwise. 50 | */ 51 | bool getData(adi_imu::msg::VelAngTempData & message) override; 52 | 53 | private: 54 | /*! This data member is used to access sensor information via libiio. */ 55 | IIOWrapper m_iio_wrapper; 56 | }; 57 | 58 | #endif // VELANGTEMP_DATA_PROVIDER_H 59 | -------------------------------------------------------------------------------- /include/adi_imu/velangtemp_data_provider_interface.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file velangtemp_data_provider_interface.h 3 | * @brief Interface for providing temperature, delta velocity and 4 | * delta angle data. 5 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 6 | ******************************************************************************* 7 | * Copyright 2023(c) Analog Devices, Inc. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | ******************************************************************************/ 21 | 22 | #ifndef VELANGTEMP_DATA_PROVIDER_INTERFACE_H 23 | #define VELANGTEMP_DATA_PROVIDER_INTERFACE_H 24 | 25 | #include "adi_imu/msg/vel_ang_temp_data.hpp" 26 | 27 | /** 28 | * @brief Interface for delta angle, delta velocity and temperature buffered 29 | * data provider. 30 | */ 31 | class VelAngTempDataProviderInterface 32 | { 33 | public: 34 | /** 35 | * @brief Constructor for VelAngTempDataProviderInterface. 36 | */ 37 | VelAngTempDataProviderInterface() {} 38 | 39 | /** 40 | * @brief Destructor for VelAngTempDataProviderInterface. 41 | */ 42 | virtual ~VelAngTempDataProviderInterface() {} 43 | 44 | /** 45 | * @brief Populate VelAngTempData message with measured data. 46 | * @param message Message containing the measured data. 47 | * @return Return true if the message parameter is successfully populated with 48 | * measured data and false otherwise. 49 | */ 50 | virtual bool getData(adi_imu::msg::VelAngTempData & message) = 0; 51 | }; 52 | 53 | #endif // VELANGTEMP_DATA_PROVIDER_INTERFACE_H 54 | -------------------------------------------------------------------------------- /include/adi_imu/velangtemp_ros_publisher.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file velangtemp_ros_publisher.h 3 | * @brief Header temperature, delta velocity and delta angle publisher. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #ifndef VELANGTEMP_ROS_PUBLISHER_H 22 | #define VELANGTEMP_ROS_PUBLISHER_H 23 | 24 | #include 25 | 26 | #include "adi_imu/velangtemp_data_provider_interface.h" 27 | #include "adi_imu/velangtemp_ros_publisher_interface.h" 28 | 29 | /** 30 | * @brief Class for delta velocity, delta angle and temperature publisher. 31 | */ 32 | class VelAngTempRosPublisher : public VelAngTempRosPublisherInterface 33 | { 34 | public: 35 | /** 36 | * @brief Constructor for VelAngTempRosPublisher. 37 | * @param node The ros2 Node instance. 38 | */ 39 | VelAngTempRosPublisher(std::shared_ptr & node); 40 | 41 | /** 42 | * @brief Destructor for VelAngTempRosPublisher. 43 | */ 44 | ~VelAngTempRosPublisher(); 45 | 46 | /** 47 | * @brief Set the message data provider. 48 | * @param dataProvider Data provider. 49 | */ 50 | void setMessageProvider(VelAngTempDataProviderInterface * dataProvider) override; 51 | 52 | /** 53 | * @brief Publish the VelAngTempData message. 54 | */ 55 | void publish() override; 56 | 57 | private: 58 | /*! This variable retains the data provider instance. */ 59 | VelAngTempDataProviderInterface * m_data_provider; 60 | 61 | /*! This variable retains the publisher instance. */ 62 | rclcpp::Publisher::SharedPtr m_publisher; 63 | 64 | /*! This variable retains the message that is published. */ 65 | adi_imu::msg::VelAngTempData m_message; 66 | }; 67 | 68 | #endif // VELANGTEMP_ROS_PUBLISHER_H 69 | -------------------------------------------------------------------------------- /include/adi_imu/velangtemp_ros_publisher_interface.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file velangletemp_ros_publisher_interface.h 3 | * @brief Interface temperature, delta velocity and delta angle publisher. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #ifndef VELANGTEMP_ROS_PUBLISHER_INTERFACE_H 22 | #define VELANGTEMP_ROS_PUBLISHER_INTERFACE_H 23 | 24 | #include 25 | #include 26 | 27 | class VelAngTempDataProviderInterface; 28 | 29 | /** 30 | * @brief Interface for delta velocity, delta angle and temperature publisher. 31 | */ 32 | class VelAngTempRosPublisherInterface 33 | { 34 | public: 35 | /** 36 | * @brief Constructor for VelAngTempRosPublisherInterface. 37 | */ 38 | VelAngTempRosPublisherInterface() {} 39 | 40 | /** 41 | * @brief Destructor for VelAngTempRosPublisherInterface. 42 | */ 43 | virtual ~VelAngTempRosPublisherInterface() {} 44 | 45 | /** 46 | * @brief Set the message data provider. 47 | * @param dataProvider Data provider. 48 | */ 49 | virtual void setMessageProvider(VelAngTempDataProviderInterface * dataProvider) = 0; 50 | 51 | /** 52 | * @brief Publish the VelAngTempData message. 53 | */ 54 | virtual void publish() = 0; 55 | 56 | protected: 57 | /*! The ros2 Node data member. */ 58 | std::shared_ptr m_node; 59 | }; 60 | 61 | #endif // VELANGTEMP_ROS_PUBLISHER_INTERFACE_H 62 | -------------------------------------------------------------------------------- /include/adi_imu/worker_thread.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file worker_thread.h 3 | * @brief Header for ros imu threads. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #ifndef WORKER_THREAD_H 22 | #define WORKER_THREAD_H 23 | 24 | #include 25 | 26 | #include "adi_imu/ros_task.h" 27 | 28 | /** 29 | * @brief Class for running a task in a thread. 30 | */ 31 | class WorkerThread : public std::thread 32 | { 33 | public: 34 | /** 35 | * @brief Constructor for WorkerThread. 36 | * @param rosTask A class that implements RosTask interface. 37 | */ 38 | WorkerThread(RosTask * rosTask); 39 | 40 | /** 41 | * @brief Destructor for WorkerThread. 42 | */ 43 | ~WorkerThread(); 44 | 45 | /** 46 | * @brief Method that runs on a thread. 47 | */ 48 | void runTask(); 49 | 50 | private: 51 | /*! This data member will run the method run on a thread. */ 52 | RosTask * m_rosTask; 53 | }; 54 | 55 | #endif // WORKER_THREAD_H 56 | -------------------------------------------------------------------------------- /launch/imu_tof_fusion.launch.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import launch 4 | import launch_ros.actions 5 | 6 | from ament_index_python.packages import get_package_share_directory 7 | 8 | def generate_launch_description(): 9 | 10 | rviz_param = launch.substitutions.LaunchConfiguration( 11 | 'rviz_param', 12 | default=os.path.join( 13 | get_package_share_directory('adi_imu'), 14 | 'rviz', 15 | 'imu_tof_fusion.rviz')) 16 | 17 | adi_imu_node = launch_ros.actions.Node( 18 | package='adi_imu', 19 | executable='adi_imu_node', 20 | parameters=[{'measured_data_topic_selection': 2}, 21 | # the IP address of the processing unit to which the IMU is connected to 22 | {'iio_context_string': "ip:0.0.0.0"},], 23 | remappings=[('/imu','/imu/data_raw')], 24 | output='screen' 25 | ) 26 | 27 | imu_filter_madgwick_node = launch_ros.actions.Node( 28 | package='imu_filter_madgwick', 29 | executable='imu_filter_madgwick_node', 30 | parameters=[{'use_mag': False},], 31 | output='screen' 32 | ) 33 | 34 | tof_node = launch_ros.actions.Node( 35 | package='tof_ros2cpp', 36 | executable='tof_ros2cpp_node', 37 | arguments=['ip=10.42.0.1', 'config_file=config/config_adsd3500_adsd3100.json','mode=3'], 38 | output='screen' 39 | ) 40 | 41 | tf = launch_ros.actions.Node( 42 | package='tf2_ros', 43 | executable='static_transform_publisher', 44 | arguments=['0','0','0','0','0','0','imu','aditof_xyz_img'] 45 | ) 46 | 47 | rviz = launch_ros.actions.Node( 48 | package='rviz2', 49 | executable='rviz2', 50 | arguments=['-d', rviz_param] 51 | ) 52 | 53 | 54 | return launch.LaunchDescription([ 55 | adi_imu_node, 56 | imu_filter_madgwick_node, 57 | tof_node, 58 | tf, 59 | rviz, 60 | ]) 61 | -------------------------------------------------------------------------------- /launch/imu_with_madgwick_filter_rviz.launch.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import launch 4 | import launch_ros.actions 5 | 6 | from ament_index_python.packages import get_package_share_directory 7 | 8 | def generate_launch_description(): 9 | 10 | rviz_param = launch.substitutions.LaunchConfiguration( 11 | 'rviz_param', 12 | default=os.path.join( 13 | get_package_share_directory('adi_imu'), 14 | 'rviz', 15 | 'imu_with_madgwick_filter_rviz.rviz')) 16 | 17 | adi_imu_node = launch_ros.actions.Node( 18 | package='adi_imu', 19 | executable='adi_imu_node', 20 | parameters=[{'measured_data_topic_selection': 2}, 21 | # the IP address of the processing unit to which the IMU is connected to 22 | {'iio_context_string': "ip:0.0.0.0"},], 23 | remappings=[('/imu','/imu/data_raw')], 24 | output='screen' 25 | ) 26 | 27 | imu_filter_madgwick_node = launch_ros.actions.Node( 28 | package='imu_filter_madgwick', 29 | executable='imu_filter_madgwick_node', 30 | parameters=[{'use_mag': False},], 31 | output='screen' 32 | ) 33 | 34 | rviz = launch_ros.actions.Node( 35 | package='rviz2', 36 | executable='rviz2', 37 | arguments=['-d', rviz_param] 38 | ) 39 | 40 | 41 | return launch.LaunchDescription([ 42 | adi_imu_node, 43 | imu_filter_madgwick_node, 44 | rviz, 45 | ]) 46 | -------------------------------------------------------------------------------- /msg/AccelGyroTempData.msg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # @file AccelGyroTempData.msg 3 | # @brief Definition of AccelGyroTempData message 4 | # @author RBolboac (ramona.bolboaca@analog.com) 5 | ################################################################################ 6 | # Copyright 2023(c) Analog Devices, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | ################################################################################ 20 | 21 | # message header 22 | std_msgs/Header header 23 | 24 | # 3-axis acceleration [m/s^2] 25 | geometry_msgs/Vector3 linear_acceleration 26 | 27 | # 3-axis angular velocity [rad/s] 28 | geometry_msgs/Vector3 angular_velocity 29 | 30 | # imu internal temperature [°C] 31 | float64 temperature 32 | -------------------------------------------------------------------------------- /msg/ImuFullMeasuredData.msg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # @file ImuFullMeasuredData.msg 3 | # @brief Definition of ImuFullMeasuredData message 4 | # @author RBolboac (ramona.bolboaca@analog.com) 5 | ################################################################################ 6 | # Copyright 2023(c) Analog Devices, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | ################################################################################ 20 | 21 | # message header 22 | std_msgs/Header header 23 | 24 | # 3-axis acceleration [m/s^2] 25 | geometry_msgs/Vector3 linear_acceleration 26 | 27 | # 3-axis angular velocity [rad/s] 28 | geometry_msgs/Vector3 angular_velocity 29 | 30 | # 3-axis delta velocity (delta between two consecutive measurements) [m/s] 31 | geometry_msgs/Vector3 delta_velocity 32 | 33 | # 3-axis delta angle (delta between two consecutive measurements) [radians] 34 | geometry_msgs/Vector3 delta_angle 35 | 36 | # imu internal temperature [°C] 37 | float64 temperature 38 | -------------------------------------------------------------------------------- /msg/ImuIdentificationData.msg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # @file ImuIdentificationData.msg 3 | # @brief Definition of ImuIdentificationData message 4 | # @author RBolboac (ramona.bolboaca@analog.com) 5 | ################################################################################ 6 | # Copyright 2023(c) Analog Devices, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | ################################################################################ 20 | 21 | # message header 22 | std_msgs/Header header 23 | 24 | # firmware revision for the imu internal firmware 25 | string firmware_revision 26 | 27 | # firmware date for the imu internal firmware 28 | string firmware_date 29 | 30 | # imu product identification 31 | uint32 product_id 32 | 33 | # imu lot specific serial number 34 | uint32 serial_number 35 | 36 | # imu gyroscope measurement range 37 | string gyroscope_measurement_range 38 | -------------------------------------------------------------------------------- /msg/VelAngTempData.msg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # @file VelAngTempData.msg 3 | # @brief Definition of VelAngTempData message 4 | # @author RBolboac (ramona.bolboaca@analog.com) 5 | ################################################################################ 6 | # Copyright 2023(c) Analog Devices, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | ################################################################################ 20 | 21 | # message header 22 | std_msgs/Header header 23 | 24 | # 3-axis delta velocity (delta between two consecutive measurements) [m/s] 25 | geometry_msgs/Vector3 delta_velocity 26 | 27 | # 3-axis delta angle (delta between two consecutive measurements) [radians] 28 | geometry_msgs/Vector3 delta_angle 29 | 30 | # imu internal temperature [°C] 31 | float64 temperature 32 | -------------------------------------------------------------------------------- /msg/adis1646x/ImuDiagData.msg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # @file ImuDiagData.msg 3 | # @brief Definition of ImuDiagData message 4 | # @author Ramona Gradinariu (ramona.gradinariu@analog.com) 5 | ################################################################################ 6 | # Copyright 2023(c) Analog Devices, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | ################################################################################ 20 | 21 | # message header 22 | std_msgs/Header header 23 | 24 | # if true, one of the datapaths experienced an overrun condition 25 | bool diag_data_path_overrun 26 | 27 | # if true, the most recent imu memory flash failed 28 | bool diag_flash_memory_update_error 29 | 30 | # if true, the total number of SPI SCLK cycles is not equal to an integer multiple of 16 31 | bool diag_spi_communication_error 32 | 33 | # if true, the imu voltage across VDD and GND < 2.9V, which causes data processing to stop 34 | bool diag_standby_mode 35 | 36 | # if true, the imu self-test routine failed 37 | bool diag_sensor_self_test_error 38 | 39 | # if true, there is a failure in imu flash memory 40 | bool diag_flash_memory_test_error 41 | 42 | # if true, the internal data sampling clock does not synchronize with the external clock (only in scaled sync mode) 43 | bool diag_clock_error 44 | 45 | # if true, the imu flash memory was written more times than the data-sheet specified endurance 46 | bool diag_flash_memory_write_count_exceeded_error 47 | 48 | # the value of the imu flash writes 49 | uint32 flash_counter 50 | 51 | 52 | -------------------------------------------------------------------------------- /msg/adis1647x/ImuDiagData.msg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # @file ImuDiagData.msg 3 | # @brief Definition of ImuDiagData message 4 | # @author Ramona Gradinariu (ramona.gradinariu@analog.com) 5 | ################################################################################ 6 | # Copyright 2023(c) Analog Devices, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | ################################################################################ 20 | 21 | # message header 22 | std_msgs/Header header 23 | 24 | # if true, one of the datapaths experienced an overrun condition 25 | bool diag_data_path_overrun 26 | 27 | # if true, the most recent imu memory flash failed 28 | bool diag_flash_memory_update_error 29 | 30 | # if true, the total number of SPI SCLK cycles is not equal to an integer multiple of 16 31 | bool diag_spi_communication_error 32 | 33 | # if true, the imu voltage across VDD and GND < 2.9V, which causes data processing to stop 34 | bool diag_standby_mode 35 | 36 | # if true, the imu self-test routine failed 37 | bool diag_sensor_self_test_error 38 | 39 | # if true, there is a failure in imu flash memory 40 | bool diag_flash_memory_test_error 41 | 42 | # if true, the internal data sampling clock does not synchronize with the external clock (only in scaled sync mode) 43 | bool diag_clock_error 44 | 45 | # if true, the imu flash memory was written more times than the data-sheet specified endurance 46 | bool diag_flash_memory_write_count_exceeded_error 47 | 48 | # the value of the imu flash writes 49 | uint32 flash_counter 50 | 51 | 52 | -------------------------------------------------------------------------------- /msg/adis1650x/ImuDiagData.msg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # @file ImuDiagData.msg 3 | # @brief Definition of ImuDiagData message 4 | # @author RBolboac (ramona.bolboaca@analog.com) 5 | ################################################################################ 6 | # Copyright 2023(c) Analog Devices, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | ################################################################################ 20 | 21 | # message header 22 | std_msgs/Header header 23 | 24 | # if true, one of the datapaths experienced an overrun condition 25 | bool diag_data_path_overrun 26 | 27 | # if true, the most recent imu memory flash failed 28 | bool diag_flash_memory_update_error 29 | 30 | # if true, the total number of SPI SCLK cycles is not equal to an integer multiple of 16 31 | bool diag_spi_communication_error 32 | 33 | # if true, the imu voltage across VDD and GND < 2.9V, which causes data processing to stop 34 | bool diag_standby_mode 35 | 36 | # if true, the imu self-test routine failed 37 | bool diag_sensor_self_test_error 38 | 39 | # if true, there is a failure in imu flash memory 40 | bool diag_flash_memory_test_error 41 | 42 | # if true, the internal data sampling clock does not synchronize with the external clock (only in scaled sync mode) 43 | bool diag_clock_error 44 | 45 | # if true, a failure occurred on accelerometer 46 | bool diag_acceleration_self_test_error 47 | 48 | # if true, a failure occurred on gyroscope 1 49 | bool diag_gyroscope1_self_test_error 50 | 51 | # if true, a failure occurred on gyroscope 2 52 | bool diag_gyroscope2_self_test_error 53 | 54 | # if true, the imu flash memory was written more times than the data-sheet specified endurance 55 | bool diag_flash_memory_write_count_exceeded_error 56 | 57 | # the value of the imu flash writes 58 | uint32 flash_counter 59 | -------------------------------------------------------------------------------- /msg/adis1654x/ImuDiagData.msg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # @file ImuDiagData.msg 3 | # @brief Definition of ImuDiagData message 4 | # @author Robert Budai (robert.budai@analog.com) 5 | ################################################################################ 6 | # Copyright 2023(c) Analog Devices, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | ################################################################################ 20 | 21 | # message header 22 | std_msgs/Header header 23 | 24 | # if true, one of the datapaths experienced an overrun condition 25 | bool diag_data_path_overrun 26 | 27 | # if true, the most recent imu memory flash failed 28 | bool diag_flash_memory_update_error 29 | 30 | # if true, sensor automatically reset themselves to clear an issue 31 | bool diag_automatic_reset 32 | 33 | # if true, while operating in scaled sync mode, indicates the sampling time is not scaling correctly 34 | bool diag_clock_error 35 | 36 | # if true, indicates the occurrence of a processing overrun 37 | bool diag_processing_overrun 38 | 39 | # if true, the most recent imu memory flash failed 40 | bool diag_flash_memory_test_error 41 | 42 | # if true, indicates the failure of the inertial sensor 43 | bool diag_sensor_self_test_error 44 | 45 | #if true, indicates communication error on SPI interface 46 | bool diag_spi_communication_error 47 | 48 | # if true, indicates failure on CRC calculation 49 | bool diag_crc_error 50 | 51 | #if true, indicates the device booted up using the backup memory bank 52 | bool diag_boot_mem_fail 53 | 54 | # if true, a failure occurred on x axis gyroscope 55 | bool diag_x_axis_gyroscope_failure 56 | 57 | # if true, a failure occurred on y axis gyroscope 58 | bool diag_y_axis_gyroscope_failure 59 | 60 | # if true, a failure occurred on z axis gyroscope 61 | bool diag_z_axis_gyroscope_failure 62 | 63 | # if true, a failure occurred on x axis accelerometer 64 | bool diag_x_axis_accelerometer_failure 65 | 66 | # if true, a failure occurred on y axis accelerometer 67 | bool diag_y_axis_accelerometer_failure 68 | 69 | # if true, a failure occurred on z axis accelerometer 70 | bool diag_z_axis_accelerometer_failure 71 | 72 | # if true, the imu flash memory was written more times than the data-sheet specified endurance 73 | bool diag_flash_memory_write_count_exceeded_error 74 | 75 | # the value of the imu flash writes 76 | uint32 flash_counter 77 | -------------------------------------------------------------------------------- /msg/adis1655x/ImuDiagData.msg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # @file ImuDiagData.msg 3 | # @brief Definition of ImuDiagData message 4 | # @author Robert Budai (robert.budai@analog.com) 5 | ################################################################################ 6 | # Copyright 2023(c) Analog Devices, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | ################################################################################ 20 | 21 | # message header 22 | std_msgs/Header header 23 | 24 | # if true, one of the datapaths experienced an overrun condition 25 | bool diag_data_path_overrun 26 | 27 | # if true, the most recent imu memory flash failed 28 | bool diag_flash_memory_update_error 29 | 30 | # if true, sensor automatically reset themselves to clear an issue 31 | bool diag_automatic_reset 32 | 33 | # if true, while operating in scaled sync mode, indicates the sampling time is not scaling correctly 34 | bool diag_clock_error 35 | 36 | # if true, the most recent imu memory flash failed 37 | bool diag_flash_memory_test_error 38 | 39 | # if true, indicates the failure of the inertial sensor 40 | bool diag_sensor_self_test_error 41 | 42 | #if true, indicates communication error on SPI interface 43 | bool diag_spi_communication_error 44 | 45 | # if true, indicates failure on CRC calculation 46 | bool diag_crc_error 47 | 48 | # if true, a failure occurred on x axis gyroscope 49 | bool diag_x_axis_gyroscope_failure 50 | 51 | # if true, a failure occurred on y axis gyroscope 52 | bool diag_y_axis_gyroscope_failure 53 | 54 | # if true, a failure occurred on z axis gyroscope 55 | bool diag_z_axis_gyroscope_failure 56 | 57 | # if true, a failure occurred on x axis accelerometer 58 | bool diag_x_axis_accelerometer_failure 59 | 60 | # if true, a failure occurred on y axis accelerometer 61 | bool diag_y_axis_accelerometer_failure 62 | 63 | # if true, a failure occurred on z axis accelerometer 64 | bool diag_z_axis_accelerometer_failure 65 | 66 | # if true, the imu flash memory was written more times than the data-sheet specified endurance 67 | bool diag_flash_memory_write_count_exceeded_error 68 | 69 | # the value of the imu flash writes 70 | uint32 flash_counter 71 | -------------------------------------------------------------------------------- /msg/adis1657x/ImuDiagData.msg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # @file ImuDiagData.msg 3 | # @brief Definition of ImuDiagData message 4 | # @author RBolboac (ramona.bolboaca@analog.com) 5 | ################################################################################ 6 | # Copyright 2023(c) Analog Devices, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | ################################################################################ 20 | 21 | # message header 22 | std_msgs/Header header 23 | 24 | # if true, the imu failed to initialize properly 25 | bool diag_sensor_initialization_failure 26 | 27 | # if true, one of the datapaths experienced an overrun condition 28 | bool diag_data_path_overrun 29 | 30 | # if true, the most recent imu memory flash failed 31 | bool diag_flash_memory_update_error 32 | 33 | # if true, the total number of SPI SCLK cycles is not equal to an integer multiple of 16 34 | bool diag_spi_communication_error 35 | 36 | # if true, the imu voltage across VDD and GND < 2.9V, which causes data processing to stop 37 | bool diag_standby_mode 38 | 39 | # if true, the imu self-test routine failed 40 | bool diag_sensor_self_test_error 41 | 42 | # if true, there is a failure in imu flash memory 43 | bool diag_flash_memory_test_error 44 | 45 | # if true, the internal data sampling clock does not synchronize with the external clock (only in scaled sync mode) 46 | bool diag_clock_error 47 | 48 | # if true, a failure occurred on x axis gyroscope 49 | bool diag_x_axis_gyroscope_failure 50 | 51 | # if true, a failure occurred on y axis gyroscope 52 | bool diag_y_axis_gyroscope_failure 53 | 54 | # if true, a failure occurred on z axis gyroscope 55 | bool diag_z_axis_gyroscope_failure 56 | 57 | # if true, a failure occurred on x axis accelerometer 58 | bool diag_x_axis_accelerometer_failure 59 | 60 | # if true, a failure occurred on y axis accelerometer 61 | bool diag_y_axis_accelerometer_failure 62 | 63 | # if true, a failure occurred on z axis accelerometer 64 | bool diag_z_axis_accelerometer_failure 65 | 66 | # if true, a fault occurred in the imu microcontroller 67 | bool diag_aduc_mcu_fault 68 | 69 | # if true, the imu flash memory was written more times than the data-sheet specified endurance 70 | bool diag_flash_memory_write_count_exceeded_error 71 | 72 | # the value of the imu flash writes 73 | uint32 flash_counter 74 | -------------------------------------------------------------------------------- /package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | adi_imu 5 | 0.0.1 6 | Publisher for ADI IMUs 7 | Analog Devices 8 | Apache License Version 2.0 9 | 10 | https://github.com/analogdevicesinc/imu_ros2 11 | https://analogdevicesinc.github.io/imu_ros2/ 12 | https://github.com/analogdevicesinc/imu_ros2/issues 13 | 14 | rbolboac 15 | 16 | ament_cmake 17 | rclcpp 18 | std_msgs 19 | sensor_msgs 20 | geometry_msgs 21 | libiio-dev 22 | 23 | builtin_interfaces 24 | rosidl_default_generators 25 | 26 | builtin_interfaces 27 | rosidl_default_runtime 28 | 29 | ament_lint_auto 30 | ament_cmake_gtest 31 | 32 | rosidl_interface_packages 33 | 34 | 35 | ament_cmake 36 | 37 | 38 | -------------------------------------------------------------------------------- /rviz/imu_tof_fusion.rviz: -------------------------------------------------------------------------------- 1 | Panels: 2 | - Class: rviz_common/Displays 3 | Help Height: 78 4 | Name: Displays 5 | Property Tree Widget: 6 | Expanded: 7 | - /Global Options1 8 | - /Status1 9 | - /PointCloud21 10 | Splitter Ratio: 0.5 11 | Tree Height: 747 12 | - Class: rviz_common/Selection 13 | Name: Selection 14 | - Class: rviz_common/Tool Properties 15 | Expanded: 16 | - /2D Goal Pose1 17 | - /Publish Point1 18 | Name: Tool Properties 19 | Splitter Ratio: 0.5886790156364441 20 | - Class: rviz_common/Views 21 | Expanded: 22 | - /Current View1 23 | Name: Views 24 | Splitter Ratio: 0.5 25 | - Class: rviz_common/Time 26 | Experimental: false 27 | Name: Time 28 | SyncMode: 0 29 | SyncSource: PointCloud2 30 | Visualization Manager: 31 | Class: "" 32 | Displays: 33 | - Alpha: 1 34 | Autocompute Intensity Bounds: true 35 | Autocompute Value Bounds: 36 | Max Value: 13796.2744140625 37 | Min Value: 0 38 | Value: true 39 | Axis: Z 40 | Channel Name: intensity 41 | Class: rviz_default_plugins/PointCloud2 42 | Color: 255; 255; 255 43 | Color Transformer: AxisColor 44 | Decay Time: 0 45 | Enabled: true 46 | Invert Rainbow: false 47 | Max Color: 255; 255; 255 48 | Max Intensity: 4096 49 | Min Color: 0; 0; 0 50 | Min Intensity: 0 51 | Name: PointCloud2 52 | Position Transformer: XYZ 53 | Selectable: true 54 | Size (Pixels): 1 55 | Size (m): 0.009999999776482582 56 | Style: Points 57 | Topic: 58 | Depth: 5 59 | Durability Policy: Volatile 60 | Filter size: 10 61 | History Policy: Keep Last 62 | Reliability Policy: Reliable 63 | Value: /tof_camera/xyz 64 | Use Fixed Frame: true 65 | Use rainbow: true 66 | Value: true 67 | Enabled: true 68 | Global Options: 69 | Background Color: 48; 48; 48 70 | Fixed Frame: odom 71 | Frame Rate: 30 72 | Name: root 73 | Tools: 74 | - Class: rviz_default_plugins/Interact 75 | Hide Inactive Objects: true 76 | - Class: rviz_default_plugins/MoveCamera 77 | - Class: rviz_default_plugins/Select 78 | - Class: rviz_default_plugins/FocusCamera 79 | - Class: rviz_default_plugins/Measure 80 | Line color: 128; 128; 0 81 | - Class: rviz_default_plugins/SetInitialPose 82 | Covariance x: 0.25 83 | Covariance y: 0.25 84 | Covariance yaw: 0.06853891909122467 85 | Topic: 86 | Depth: 5 87 | Durability Policy: Volatile 88 | History Policy: Keep Last 89 | Reliability Policy: Reliable 90 | Value: /initialpose 91 | - Class: rviz_default_plugins/SetGoal 92 | Topic: 93 | Depth: 5 94 | Durability Policy: Volatile 95 | History Policy: Keep Last 96 | Reliability Policy: Reliable 97 | Value: /goal_pose 98 | - Class: rviz_default_plugins/PublishPoint 99 | Single click: true 100 | Topic: 101 | Depth: 5 102 | Durability Policy: Volatile 103 | History Policy: Keep Last 104 | Reliability Policy: Reliable 105 | Value: /clicked_point 106 | Transformation: 107 | Current: 108 | Class: rviz_default_plugins/TF 109 | Value: true 110 | Views: 111 | Current: 112 | Class: rviz_default_plugins/Orbit 113 | Distance: 15354.0322265625 114 | Enable Stereo Rendering: 115 | Stereo Eye Separation: 0.05999999865889549 116 | Stereo Focal Distance: 1 117 | Swap Stereo Eyes: false 118 | Value: false 119 | Focal Point: 120 | X: 0 121 | Y: 0 122 | Z: 0 123 | Focal Shape Fixed Size: true 124 | Focal Shape Size: 0.05000000074505806 125 | Invert Z Axis: false 126 | Name: Current View 127 | Near Clip Distance: 0.009999999776482582 128 | Pitch: 1.5697963237762451 129 | Target Frame: 130 | Value: Orbit (rviz) 131 | Yaw: 0.4535779356956482 132 | Saved: ~ 133 | Window Geometry: 134 | Displays: 135 | collapsed: false 136 | Height: 1044 137 | Hide Left Dock: false 138 | Hide Right Dock: false 139 | QMainWindow State: 000000ff00000000fd00000004000000000000015600000376fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d00000376000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f00000376fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003d00000376000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000007800000003efc0100000002fb0000000800540069006d0065010000000000000780000002fb00fffffffb0000000800540069006d006501000000000000045000000000000000000000050f0000037600000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 140 | Selection: 141 | collapsed: false 142 | Time: 143 | collapsed: false 144 | Tool Properties: 145 | collapsed: false 146 | Views: 147 | collapsed: false 148 | Width: 1920 149 | X: 3840 150 | Y: 0 151 | -------------------------------------------------------------------------------- /rviz/imu_with_madgwick_filter_rviz.rviz: -------------------------------------------------------------------------------- 1 | Panels: 2 | - Class: rviz_common/Displays 3 | Help Height: 78 4 | Name: Displays 5 | Property Tree Widget: 6 | Expanded: 7 | - /Global Options1 8 | - /Status1 9 | - /Imu1 10 | - /Imu1/Box properties1 11 | Splitter Ratio: 0.5 12 | Tree Height: 747 13 | - Class: rviz_common/Selection 14 | Name: Selection 15 | - Class: rviz_common/Tool Properties 16 | Expanded: 17 | - /2D Goal Pose1 18 | - /Publish Point1 19 | Name: Tool Properties 20 | Splitter Ratio: 0.5886790156364441 21 | - Class: rviz_common/Views 22 | Expanded: 23 | - /Current View1 24 | Name: Views 25 | Splitter Ratio: 0.5 26 | - Class: rviz_common/Time 27 | Experimental: false 28 | Name: Time 29 | SyncMode: 0 30 | SyncSource: "" 31 | Visualization Manager: 32 | Class: "" 33 | Displays: 34 | - Alpha: 0.5 35 | Cell Size: 1 36 | Class: rviz_default_plugins/Grid 37 | Color: 160; 160; 164 38 | Enabled: true 39 | Line Style: 40 | Line Width: 0.029999999329447746 41 | Value: Lines 42 | Name: Grid 43 | Normal Cell Count: 0 44 | Offset: 45 | X: 0 46 | Y: 0 47 | Z: 0 48 | Plane: XY 49 | Plane Cell Count: 10 50 | Reference Frame: 51 | Value: true 52 | - Acceleration properties: 53 | Acc. vector alpha: 1 54 | Acc. vector color: 255; 0; 0 55 | Acc. vector scale: 1 56 | Derotate acceleration: true 57 | Enable acceleration: false 58 | Axes properties: 59 | Axes scale: 1 60 | Enable axes: true 61 | Box properties: 62 | Box alpha: 1 63 | Box color: 255; 0; 0 64 | Enable box: true 65 | x_scale: 1 66 | y_scale: 1 67 | z_scale: 1 68 | Class: rviz_imu_plugin/Imu 69 | Enabled: true 70 | Name: Imu 71 | Topic: 72 | Depth: 5 73 | Durability Policy: Volatile 74 | Filter size: 10 75 | History Policy: Keep Last 76 | Reliability Policy: Reliable 77 | Value: /imu/data 78 | Value: true 79 | fixed_frame_orientation: true 80 | Enabled: true 81 | Global Options: 82 | Background Color: 48; 48; 48 83 | Fixed Frame: imu 84 | Frame Rate: 30 85 | Name: root 86 | Tools: 87 | - Class: rviz_default_plugins/Interact 88 | Hide Inactive Objects: true 89 | - Class: rviz_default_plugins/MoveCamera 90 | - Class: rviz_default_plugins/Select 91 | - Class: rviz_default_plugins/FocusCamera 92 | - Class: rviz_default_plugins/Measure 93 | Line color: 128; 128; 0 94 | - Class: rviz_default_plugins/SetInitialPose 95 | Covariance x: 0.25 96 | Covariance y: 0.25 97 | Covariance yaw: 0.06853891909122467 98 | Topic: 99 | Depth: 5 100 | Durability Policy: Volatile 101 | History Policy: Keep Last 102 | Reliability Policy: Reliable 103 | Value: /initialpose 104 | - Class: rviz_default_plugins/SetGoal 105 | Topic: 106 | Depth: 5 107 | Durability Policy: Volatile 108 | History Policy: Keep Last 109 | Reliability Policy: Reliable 110 | Value: /goal_pose 111 | - Class: rviz_default_plugins/PublishPoint 112 | Single click: true 113 | Topic: 114 | Depth: 5 115 | Durability Policy: Volatile 116 | History Policy: Keep Last 117 | Reliability Policy: Reliable 118 | Value: /clicked_point 119 | Transformation: 120 | Current: 121 | Class: rviz_default_plugins/TF 122 | Value: true 123 | Views: 124 | Current: 125 | Class: rviz_default_plugins/Orbit 126 | Distance: 10 127 | Enable Stereo Rendering: 128 | Stereo Eye Separation: 0.05999999865889549 129 | Stereo Focal Distance: 1 130 | Swap Stereo Eyes: false 131 | Value: false 132 | Focal Point: 133 | X: 0 134 | Y: 0 135 | Z: 0 136 | Focal Shape Fixed Size: true 137 | Focal Shape Size: 0.05000000074505806 138 | Invert Z Axis: false 139 | Name: Current View 140 | Near Clip Distance: 0.009999999776482582 141 | Pitch: 0.785398006439209 142 | Target Frame: 143 | Value: Orbit (rviz) 144 | Yaw: 0.785398006439209 145 | Saved: ~ 146 | Window Geometry: 147 | Displays: 148 | collapsed: false 149 | Height: 1044 150 | Hide Left Dock: false 151 | Hide Right Dock: false 152 | QMainWindow State: 000000ff00000000fd00000004000000000000015600000376fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d00000376000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f00000376fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003d00000376000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000007800000003efc0100000002fb0000000800540069006d0065010000000000000780000002fb00fffffffb0000000800540069006d006501000000000000045000000000000000000000050f0000037600000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 153 | Selection: 154 | collapsed: false 155 | Time: 156 | collapsed: false 157 | Tool Properties: 158 | collapsed: false 159 | Views: 160 | collapsed: false 161 | Width: 1920 162 | X: 3840 163 | Y: 0 164 | -------------------------------------------------------------------------------- /scripts/format.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ############################################################################ 4 | # This script will format all source files (.h and .cpp) that are not 5 | # mentioned in .clangformatignore 6 | # Note that the script has to be ran from the same folder where 7 | # .clangformatignore is 8 | ########################################################################### 9 | 10 | ############################################################################ 11 | # Check if the file given as input has .h or .cpp extension 12 | ############################################################################ 13 | is_source_file() { 14 | local file="$1" 15 | 16 | EXTENSIONS=".h .hpp .cpp" 17 | 18 | for extension in $EXTENSIONS; do 19 | [[ "${file: -2}" == "$extension" || "${file: -4}" == "$extension" ]] && return 0 20 | done; 21 | 22 | return 1 23 | } 24 | 25 | 26 | ############################################################################ 27 | # Check if the file passed as arguments is ignored or not by clang format 28 | ############################################################################ 29 | is_not_ignored() { 30 | local file="$1" 31 | 32 | fileData=`cat .clangformatignore` 33 | 34 | for entry in $fileData; do 35 | if [ -d "${entry}" ]; then 36 | pushd ${entry} 37 | fileName=`basename ${file}` 38 | found=$(find -name ${fileName} | wc -l) 39 | if [ ${found} -gt 0 ]; then 40 | popd 41 | return 1 42 | else 43 | popd 44 | fi 45 | else 46 | if [ -f "${entry}" ]; then 47 | if [ "${file}" == "${entry}" ]; then 48 | return 1 49 | fi 50 | fi 51 | fi 52 | done; 53 | return 0 54 | } 55 | 56 | 57 | format_all() { 58 | git ls-tree -r --name-only HEAD | 59 | while read -r file; do 60 | if is_source_file "$file" && is_not_ignored "$file" 61 | then 62 | /usr/bin/clang-format -i "$file" 63 | fi 64 | 65 | done; 66 | } 67 | 68 | format_all 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/accelgyrotemp_data_provider.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file accelgyrotemp_data_provider.cpp 3 | * @brief Implementation for providing acceleration, gyroscope and 4 | * temperature data provider. 5 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 6 | ******************************************************************************* 7 | * Copyright 2023(c) Analog Devices, Inc. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | ******************************************************************************/ 21 | 22 | #include "adi_imu/accelgyrotemp_data_provider.h" 23 | 24 | AccelGyroTempDataProvider::AccelGyroTempDataProvider() {} 25 | 26 | AccelGyroTempDataProvider::~AccelGyroTempDataProvider() {} 27 | 28 | bool AccelGyroTempDataProvider::getData(adi_imu::msg::AccelGyroTempData & message) 29 | { 30 | if (!m_iio_wrapper.updateBuffer(ACCEL_GYRO_BUFFERED_DATA)) return false; 31 | 32 | message.linear_acceleration.x = m_iio_wrapper.getBuffLinearAccelerationX(); 33 | message.linear_acceleration.y = m_iio_wrapper.getBuffLinearAccelerationY(); 34 | message.linear_acceleration.z = m_iio_wrapper.getBuffLinearAccelerationZ(); 35 | 36 | message.angular_velocity.x = m_iio_wrapper.getBuffAngularVelocityX(); 37 | message.angular_velocity.y = m_iio_wrapper.getBuffAngularVelocityY(); 38 | message.angular_velocity.z = m_iio_wrapper.getBuffAngularVelocityZ(); 39 | 40 | message.temperature = m_iio_wrapper.getBuffTemperature(); 41 | 42 | message.header.frame_id = "accelgyrotempdata"; 43 | m_iio_wrapper.getBuffSampleTimestamp(message.header.stamp.sec, message.header.stamp.nanosec); 44 | 45 | return true; 46 | } 47 | -------------------------------------------------------------------------------- /src/accelgyrotemp_ros_publisher.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file accelgyrotemp_ros_publisher.cpp 3 | * @brief Implementation for acceleration, gyroscope and temperature 4 | * publisher. 5 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 6 | ******************************************************************************* 7 | * Copyright 2023(c) Analog Devices, Inc. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | ******************************************************************************/ 21 | 22 | #include "adi_imu/accelgyrotemp_ros_publisher.h" 23 | 24 | #include 25 | #include 26 | 27 | AccelGyroTempRosPublisher::AccelGyroTempRosPublisher(std::shared_ptr & node) 28 | { 29 | m_node = node; 30 | m_publisher = node->create_publisher("accelgyrotempdata", 10); 31 | } 32 | 33 | AccelGyroTempRosPublisher::~AccelGyroTempRosPublisher() { delete m_data_provider; } 34 | 35 | void AccelGyroTempRosPublisher::setMessageProvider( 36 | AccelGyroTempDataProviderInterface * dataProvider) 37 | { 38 | m_data_provider = dataProvider; 39 | } 40 | 41 | void AccelGyroTempRosPublisher::publish() 42 | { 43 | if (m_data_provider->getData(m_message)) { 44 | if (!m_message.header.stamp.sec && !m_message.header.stamp.nanosec) { 45 | rclcpp::Time now = m_node->get_clock()->now(); 46 | m_message.header.stamp = now; 47 | } 48 | m_publisher->publish(m_message); 49 | } else 50 | RCLCPP_INFO( 51 | rclcpp::get_logger("accelgyrotemp_ros_publisher"), 52 | "error reading accelerometer, gyroscope and temperature buffered data"); 53 | } 54 | -------------------------------------------------------------------------------- /src/imu_data_provider.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_ros_publisher.cpp 3 | * @brief Implementation for providing IMU ros standard data. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #include "adi_imu/imu_data_provider.h" 22 | 23 | #include 24 | 25 | ImuDataProvider::ImuDataProvider() {} 26 | 27 | ImuDataProvider::~ImuDataProvider() {} 28 | 29 | bool ImuDataProvider::getData(sensor_msgs::msg::Imu & message) 30 | { 31 | if (!m_iio_wrapper.updateBuffer(ACCEL_GYRO_BUFFERED_DATA)) return false; 32 | 33 | message.linear_acceleration.x = m_iio_wrapper.getBuffLinearAccelerationX(); 34 | message.linear_acceleration.y = m_iio_wrapper.getBuffLinearAccelerationY(); 35 | message.linear_acceleration.z = m_iio_wrapper.getBuffLinearAccelerationZ(); 36 | 37 | message.angular_velocity.x = m_iio_wrapper.getBuffAngularVelocityX(); 38 | message.angular_velocity.y = m_iio_wrapper.getBuffAngularVelocityY(); 39 | message.angular_velocity.z = m_iio_wrapper.getBuffAngularVelocityZ(); 40 | 41 | message.header.frame_id = "imu"; 42 | m_iio_wrapper.getBuffSampleTimestamp(message.header.stamp.sec, message.header.stamp.nanosec); 43 | 44 | message.orientation_covariance[0] = -1; 45 | 46 | return true; 47 | } 48 | -------------------------------------------------------------------------------- /src/imu_diag_data_provider.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_diag_data_provider.cpp 3 | * @brief Implementation for providing diagnosis data for adis. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #include "adi_imu/imu_diag_data_provider.h" 22 | 23 | #include 24 | 25 | ImuDiagDataProvider::ImuDiagDataProvider() {} 26 | 27 | ImuDiagDataProvider::~ImuDiagDataProvider() {} 28 | 29 | bool ImuDiagDataProvider::getData(adi_imu::msg::ImuDiagData & message) 30 | { 31 | message.header.frame_id = "imudiagdata"; 32 | 33 | #ifdef ADIS_SNSR_INIT_FAIL 34 | if (!m_iio_wrapper.diag_sensor_initialization_failure(message.diag_sensor_initialization_failure)) 35 | return false; 36 | #endif 37 | 38 | #ifdef ADIS_DATA_PATH_OVERRUN 39 | if (!m_iio_wrapper.diag_data_path_overrun(message.diag_data_path_overrun)) return false; 40 | #endif 41 | 42 | #ifdef ADIS_WDG_TIMER_FLAG 43 | if (!m_iio_wrapper.diag_automatic_reset(message.diag_automatic_reset)) return false; 44 | #endif 45 | 46 | #ifdef ADIS_FLS_MEM_UPDATE_FAIL 47 | if (!m_iio_wrapper.diag_flash_memory_update_error(message.diag_flash_memory_update_error)) 48 | return false; 49 | #endif 50 | 51 | #ifdef ADIS_SPI_COMM_ERR 52 | if (!m_iio_wrapper.diag_spi_communication_error(message.diag_spi_communication_error)) 53 | return false; 54 | #endif 55 | 56 | #ifdef ADIS_CRC_ERROR 57 | if (!m_iio_wrapper.diag_crc_error(message.diag_crc_error)) return false; 58 | #endif 59 | 60 | #ifdef ADIS_STDBY_MODE 61 | if (!m_iio_wrapper.diag_standby_mode(message.diag_standby_mode)) return false; 62 | #endif 63 | 64 | #ifdef ADIS_SNSR_FAIL 65 | if (!m_iio_wrapper.diag_sensor_self_test_error(message.diag_sensor_self_test_error)) return false; 66 | #endif 67 | 68 | #ifdef ADIS_FLASH_MEMORY_TEST 69 | if (!m_iio_wrapper.diag_flash_memory_test_error(message.diag_flash_memory_test_error)) 70 | return false; 71 | #endif 72 | 73 | #ifdef ADIS_CLK_ERR 74 | if (!m_iio_wrapper.diag_clock_error(message.diag_clock_error)) return false; 75 | #endif 76 | 77 | #ifdef ADIS_GYRO1_FAIL 78 | if (!m_iio_wrapper.diag_gyroscope1_self_test_error(message.diag_gyroscope1_self_test_error)) 79 | return false; 80 | #endif 81 | 82 | #ifdef ADIS_GYRO2_FAIL 83 | if (!m_iio_wrapper.diag_gyroscope2_self_test_error(message.diag_gyroscope2_self_test_error)) 84 | return false; 85 | #endif 86 | 87 | #ifdef ADIS_ACCEL_FAIL 88 | if (!m_iio_wrapper.diag_acceleration_self_test_error(message.diag_acceleration_self_test_error)) 89 | return false; 90 | #endif 91 | 92 | #ifdef ADIS_GYRO_X_FAIL 93 | if (!m_iio_wrapper.diag_x_axis_gyroscope_failure(message.diag_x_axis_gyroscope_failure)) 94 | return false; 95 | #endif 96 | 97 | #ifdef ADIS_GYRO_Y_FAIL 98 | if (!m_iio_wrapper.diag_y_axis_gyroscope_failure(message.diag_y_axis_gyroscope_failure)) 99 | return false; 100 | #endif 101 | 102 | #ifdef ADIS_GYRO_Z_FAIL 103 | if (!m_iio_wrapper.diag_z_axis_gyroscope_failure(message.diag_z_axis_gyroscope_failure)) 104 | return false; 105 | #endif 106 | 107 | #ifdef ADIS_ACCEL_X_FAIL 108 | if (!m_iio_wrapper.diag_x_axis_accelerometer_failure(message.diag_x_axis_accelerometer_failure)) 109 | return false; 110 | #endif 111 | 112 | #ifdef ADIS_ACCEL_Y_FAIL 113 | if (!m_iio_wrapper.diag_y_axis_accelerometer_failure(message.diag_y_axis_accelerometer_failure)) 114 | return false; 115 | #endif 116 | 117 | #ifdef ADIS_ACCEL_Z_FAIL 118 | if (!m_iio_wrapper.diag_z_axis_accelerometer_failure(message.diag_z_axis_accelerometer_failure)) 119 | return false; 120 | #endif 121 | 122 | #ifdef ADIS_ADUC_MCU_FAULT 123 | if (!m_iio_wrapper.diag_aduc_mcu_fault(message.diag_aduc_mcu_fault)) return false; 124 | #endif 125 | 126 | if (!m_iio_wrapper.diag_flash_memory_write_count_exceeded_error( 127 | message.diag_flash_memory_write_count_exceeded_error)) 128 | return false; 129 | 130 | return m_iio_wrapper.flash_counter(message.flash_counter); 131 | } 132 | -------------------------------------------------------------------------------- /src/imu_diag_ros_publisher.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_diag_ros_publisher.cpp 3 | * @brief Implementation for adis diagnosis publisher. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #include "adi_imu/imu_diag_ros_publisher.h" 22 | 23 | #include 24 | 25 | ImuDiagRosPublisher::ImuDiagRosPublisher(std::shared_ptr & node) 26 | { 27 | m_node = node; 28 | m_publisher = node->create_publisher("imudiagdata", 10); 29 | } 30 | 31 | ImuDiagRosPublisher::~ImuDiagRosPublisher() { delete m_data_provider; } 32 | 33 | void ImuDiagRosPublisher::setMessageProvider(ImuDiagDataProviderInterface * dataProvider) 34 | { 35 | m_data_provider = dataProvider; 36 | } 37 | 38 | void ImuDiagRosPublisher::run() 39 | { 40 | std::thread::id this_id = std::this_thread::get_id(); 41 | std::cout << "thread " << this_id << " started...\n"; 42 | RCLCPP_INFO(rclcpp::get_logger("imu_diag_ros_publisher"), "startThread: ImuDiagRosPublisher"); 43 | 44 | while (rclcpp::ok()) { 45 | if (m_data_provider->getData(m_message)) { 46 | rclcpp::Time now = m_node->get_clock()->now(); 47 | m_message.header.stamp = now; 48 | m_publisher->publish(m_message); 49 | } else 50 | RCLCPP_INFO(rclcpp::get_logger("imu_diag_ros_publisher"), "error reading diagnosis data"); 51 | } 52 | 53 | this_id = std::this_thread::get_id(); 54 | std::cout << "thread " << this_id << " ended...\n"; 55 | RCLCPP_INFO(rclcpp::get_logger("imu_diag_ros_publisher"), "endThread: ImuDiagRosPublisher"); 56 | } 57 | -------------------------------------------------------------------------------- /src/imu_full_measured_data_provider.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_full_measured_data_provider.cpp 3 | * @brief Implementation for acceleration, gyroscope, temperature, delta 4 | * velocity, delta angle and temperature data provider. 5 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 6 | ******************************************************************************* 7 | * Copyright 2023(c) Analog Devices, Inc. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | ******************************************************************************/ 21 | 22 | #include "adi_imu/imu_full_measured_data_provider.h" 23 | 24 | ImuFullMeasuredDataProvider::ImuFullMeasuredDataProvider() {} 25 | 26 | ImuFullMeasuredDataProvider::~ImuFullMeasuredDataProvider() {} 27 | 28 | bool ImuFullMeasuredDataProvider::getData(adi_imu::msg::ImuFullMeasuredData & data) 29 | { 30 | m_iio_wrapper.stopBufferAcquisition(); 31 | 32 | data.header.frame_id = "imufullmeasureddata"; 33 | 34 | if (!m_iio_wrapper.getConvertedLinearAccelerationX(data.linear_acceleration.x)) return false; 35 | 36 | if (!m_iio_wrapper.getConvertedLinearAccelerationY(data.linear_acceleration.y)) return false; 37 | 38 | if (!m_iio_wrapper.getConvertedLinearAccelerationZ(data.linear_acceleration.z)) return false; 39 | 40 | if (!m_iio_wrapper.getConvertedAngularVelocityX(data.angular_velocity.x)) return false; 41 | 42 | if (!m_iio_wrapper.getConvertedAngularVelocityY(data.angular_velocity.y)) return false; 43 | 44 | if (!m_iio_wrapper.getConvertedAngularVelocityZ(data.angular_velocity.z)) return false; 45 | 46 | if (!m_iio_wrapper.getConvertedDeltaVelocityX(data.delta_velocity.x)) return false; 47 | 48 | if (!m_iio_wrapper.getConvertedDeltaVelocityY(data.delta_velocity.y)) return false; 49 | 50 | if (!m_iio_wrapper.getConvertedDeltaVelocityZ(data.delta_velocity.z)) return false; 51 | 52 | if (!m_iio_wrapper.getConvertedDeltaAngleX(data.delta_angle.x)) return false; 53 | 54 | if (!m_iio_wrapper.getConvertedDeltaAngleY(data.delta_angle.y)) return false; 55 | 56 | if (!m_iio_wrapper.getConvertedDeltaAngleZ(data.delta_angle.z)) return false; 57 | 58 | return m_iio_wrapper.getConvertedTemperature(data.temperature); 59 | } 60 | -------------------------------------------------------------------------------- /src/imu_full_measured_data_ros_publisher.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_full_measured_data_ros_publisher.cpp 3 | * @brief Implementation for acceleration, gyroscope, temperature, delta 4 | * velocity, delta angle and temperature publisher. 5 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 6 | ******************************************************************************* 7 | * Copyright 2023(c) Analog Devices, Inc. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | *******************************************************************************/ 21 | 22 | #include "adi_imu/imu_full_measured_data_ros_publisher.h" 23 | 24 | #include 25 | #include 26 | 27 | ImuFullMeasuredDataRosPublisher::ImuFullMeasuredDataRosPublisher( 28 | std::shared_ptr & node) 29 | { 30 | m_node = node; 31 | m_publisher = 32 | node->create_publisher("imufullmeasureddata", 10); 33 | } 34 | 35 | ImuFullMeasuredDataRosPublisher::~ImuFullMeasuredDataRosPublisher() { delete m_data_provider; } 36 | 37 | void ImuFullMeasuredDataRosPublisher::setMessageProvider( 38 | ImuFullMeasuredDataProviderInterface * dataProvider) 39 | { 40 | m_data_provider = dataProvider; 41 | } 42 | 43 | void ImuFullMeasuredDataRosPublisher::publish() 44 | { 45 | if (m_data_provider->getData(m_message)) { 46 | rclcpp::Time now = m_node->get_clock()->now(); 47 | m_message.header.stamp = now; 48 | m_publisher->publish(m_message); 49 | } else 50 | RCLCPP_INFO( 51 | rclcpp::get_logger("imu_full_measured_data_ros_publisher"), 52 | "error reading full measured data"); 53 | } 54 | -------------------------------------------------------------------------------- /src/imu_identification_data_provider.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_identification_data_provider.cpp 3 | * @brief Implementation for imu identification data provider. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #include "adi_imu/imu_identification_data_provider.h" 22 | 23 | ImuIdentificationDataProvider::ImuIdentificationDataProvider() {} 24 | 25 | ImuIdentificationDataProvider::~ImuIdentificationDataProvider() {} 26 | 27 | bool ImuIdentificationDataProvider::getData(adi_imu::msg::ImuIdentificationData & message) 28 | { 29 | message.header.frame_id = "imuidentificationdata"; 30 | 31 | if (!m_iio_wrapper.firmware_revision(message.firmware_revision)) return false; 32 | 33 | if (!m_iio_wrapper.firmware_date(message.firmware_date)) return false; 34 | 35 | if (!m_iio_wrapper.product_id(message.product_id)) return false; 36 | 37 | if (!m_iio_wrapper.serial_number(message.serial_number)) return false; 38 | 39 | return m_iio_wrapper.gyroscope_measurement_range(message.gyroscope_measurement_range); 40 | } 41 | -------------------------------------------------------------------------------- /src/imu_identification_ros_publisher.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_identification_ros_publisher.cpp 3 | * @brief Implementation for imu identification publisher. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #include "adi_imu/imu_identification_ros_publisher.h" 22 | 23 | #include 24 | 25 | ImuIdentificationRosPublisher::ImuIdentificationRosPublisher(std::shared_ptr & node) 26 | { 27 | m_node = node; 28 | m_publisher = 29 | node->create_publisher("imuidentificationdata", 10); 30 | } 31 | 32 | ImuIdentificationRosPublisher::~ImuIdentificationRosPublisher() { delete m_data_provider; } 33 | 34 | void ImuIdentificationRosPublisher::setMessageProvider( 35 | ImuIdentificationDataProviderInterface * dataProvider) 36 | { 37 | m_data_provider = dataProvider; 38 | } 39 | 40 | void ImuIdentificationRosPublisher::run() 41 | { 42 | std::thread::id this_id = std::this_thread::get_id(); 43 | std::cout << "thread " << this_id << " started...\n"; 44 | RCLCPP_INFO( 45 | rclcpp::get_logger("imu_identification_ros_publisher"), 46 | "startThread: ImuIdentificationRosPublisher"); 47 | 48 | // read data only once 49 | m_data_provider->getData(m_message); 50 | 51 | while (rclcpp::ok()) { 52 | rclcpp::Time now = m_node->get_clock()->now(); 53 | m_message.header.stamp = now; 54 | m_publisher->publish(m_message); 55 | } 56 | 57 | this_id = std::this_thread::get_id(); 58 | std::cout << "thread " << this_id << " ended...\n"; 59 | RCLCPP_INFO( 60 | rclcpp::get_logger("imu_identification_ros_publisher"), 61 | "endThread: ImuIdentificationRosPublisher"); 62 | } 63 | -------------------------------------------------------------------------------- /src/imu_ros2_node.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ /** 2 | * @file adi_imu_node.cpp 3 | * @brief Implementation for IMU node. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************** 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | *******************************************************************************/ 20 | 21 | #include "adi_imu/accelgyrotemp_data_provider.h" 22 | #include "adi_imu/accelgyrotemp_ros_publisher.h" 23 | #include "adi_imu/imu_control_parameters.h" 24 | #include "adi_imu/imu_data_provider.h" 25 | #include "adi_imu/imu_diag_data_provider.h" 26 | #include "adi_imu/imu_diag_ros_publisher.h" 27 | #include "adi_imu/imu_full_measured_data_provider.h" 28 | #include "adi_imu/imu_full_measured_data_ros_publisher.h" 29 | #include "adi_imu/imu_identification_data_provider.h" 30 | #include "adi_imu/imu_identification_ros_publisher.h" 31 | #include "adi_imu/imu_ros_publisher.h" 32 | #include "adi_imu/ros_publisher_group.h" 33 | #include "adi_imu/ros_publisher_group_interface.h" 34 | #ifdef ADIS_HAS_DELTA_BURST 35 | #include "adi_imu/velangtemp_data_provider.h" 36 | #include "adi_imu/velangtemp_ros_publisher.h" 37 | #endif 38 | 39 | #include "adi_imu/worker_thread.h" 40 | #include "rclcpp/rclcpp.hpp" 41 | 42 | /** 43 | * @brief main function to run imu-ros2 44 | * @param argc argument count 45 | * @param argv arguments value array 46 | * @return Should not return if successful (will run continuously), error code 47 | * otherwise. 48 | */ 49 | int main(int argc, char * argv[]) 50 | { 51 | int ret; 52 | rclcpp::init(argc, argv); 53 | 54 | std::shared_ptr imu_node = rclcpp::Node::make_shared("adi_imu_node"); 55 | 56 | std::thread::id this_id = std::this_thread::get_id(); 57 | std::cout << "mainthread " << this_id << " running...\n"; 58 | RCLCPP_INFO(rclcpp::get_logger("rclcpp_main"), "running: main thread"); 59 | 60 | auto param_desc = rcl_interfaces::msg::ParameterDescriptor{}; 61 | param_desc.description = 62 | "\nDefault value is \'local:\', to be used when the adi_imu node is running locally." 63 | "\nIf the adi_imu node is running remotely, please use \'ip:rpi_ip_address\',"; 64 | 65 | imu_node->declare_parameter("iio_context_string", "local:", param_desc); 66 | 67 | /* First make sure IIO context is available */ 68 | std::string context = 69 | imu_node->get_parameter("iio_context_string").get_parameter_value().get(); 70 | IIOWrapper m_iio_wrapper; 71 | ret = m_iio_wrapper.createContext(context.c_str()); 72 | 73 | if (ret) { 74 | std::runtime_error("Error IIO context, exiting ROS2 node"); 75 | rclcpp::shutdown(); 76 | return 0; 77 | } 78 | ImuControlParameters * ctrl_params = new ImuControlParameters(imu_node); 79 | 80 | AccelGyroTempDataProviderInterface * accel_gyro_data_provider = new AccelGyroTempDataProvider(); 81 | AccelGyroTempRosPublisherInterface * accel_gyro_publisher = 82 | new AccelGyroTempRosPublisher(imu_node); 83 | accel_gyro_publisher->setMessageProvider(accel_gyro_data_provider); 84 | 85 | ImuDataProviderInterface * imu_std_data_provider = new ImuDataProvider(); 86 | ImuRosPublisherInterface * imu_std_publisher = new ImuRosPublisher(imu_node); 87 | imu_std_publisher->setMessageProvider(imu_std_data_provider); 88 | 89 | #ifdef ADIS_HAS_DELTA_BURST 90 | VelAngTempDataProviderInterface * vel_ang_data_provider = new VelAngTempDataProvider(); 91 | VelAngTempRosPublisherInterface * vel_ang_publisher = new VelAngTempRosPublisher(imu_node); 92 | vel_ang_publisher->setMessageProvider(vel_ang_data_provider); 93 | #endif 94 | 95 | ImuFullMeasuredDataProviderInterface * full_data_provider = new ImuFullMeasuredDataProvider(); 96 | ImuFullMeasuredDataRosPublisherInterface * full_data_publisher = 97 | new ImuFullMeasuredDataRosPublisher(imu_node); 98 | full_data_publisher->setMessageProvider(full_data_provider); 99 | 100 | RosPublisherGroupInterface * publisher_group = new RosPublisherGroup(imu_node); 101 | publisher_group->setAccelGyroTempRosPublisher(accel_gyro_publisher); 102 | #ifdef ADIS_HAS_DELTA_BURST 103 | publisher_group->setVelAngTempRosPublisher(vel_ang_publisher); 104 | #endif 105 | publisher_group->setImuRosPublisher(imu_std_publisher); 106 | publisher_group->setImuFullMeasuredDataRosPublisher(full_data_publisher); 107 | publisher_group->setImuControlParameters(ctrl_params); 108 | 109 | RosTask * publisher_group_task = dynamic_cast(publisher_group); 110 | 111 | ImuIdentificationDataProviderInterface * ident_data_provider = 112 | new ImuIdentificationDataProvider(); 113 | ImuIdentificationRosPublisherInterface * ident_publisher = 114 | new ImuIdentificationRosPublisher(imu_node); 115 | ident_publisher->setMessageProvider(ident_data_provider); 116 | RosTask * ident_task = dynamic_cast(ident_publisher); 117 | 118 | ImuDiagDataProviderInterface * diag_data_provider = nullptr; 119 | ImuDiagRosPublisherInterface * diag_publisher = nullptr; 120 | RosTask * diag_task = nullptr; 121 | 122 | diag_data_provider = new ImuDiagDataProvider(); 123 | diag_publisher = new ImuDiagRosPublisher(imu_node); 124 | diag_publisher->setMessageProvider(diag_data_provider); 125 | 126 | diag_task = dynamic_cast(diag_publisher); 127 | 128 | WorkerThread publisher_group_thread(publisher_group_task); 129 | WorkerThread ident_thread(ident_task); 130 | WorkerThread diag_thread(diag_task); 131 | 132 | diag_thread.join(); 133 | ident_thread.join(); 134 | publisher_group_thread.join(); 135 | 136 | delete ctrl_params; 137 | delete accel_gyro_publisher; 138 | #ifdef ADIS_HAS_DELTA_BURST 139 | delete vel_ang_publisher; 140 | #endif 141 | delete imu_std_publisher; 142 | delete full_data_publisher; 143 | delete ident_publisher; 144 | delete diag_publisher; 145 | 146 | rclcpp::shutdown(); 147 | 148 | return 0; 149 | } 150 | -------------------------------------------------------------------------------- /src/imu_ros_publisher.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_ros_publisher.cpp 3 | * @brief Implementation for standard ros imu data publisher. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #include "adi_imu/imu_ros_publisher.h" 22 | 23 | #include 24 | #include 25 | 26 | ImuRosPublisher::ImuRosPublisher(std::shared_ptr & node) 27 | { 28 | m_node = node; 29 | m_publisher = node->create_publisher("imu", 10); 30 | } 31 | 32 | ImuRosPublisher::~ImuRosPublisher() { delete m_data_provider; } 33 | 34 | void ImuRosPublisher::setMessageProvider(ImuDataProviderInterface * dataProvider) 35 | { 36 | m_data_provider = dataProvider; 37 | } 38 | 39 | void ImuRosPublisher::publish() 40 | { 41 | if (m_data_provider->getData(m_message)) { 42 | if (!m_message.header.stamp.sec && !m_message.header.stamp.nanosec) { 43 | rclcpp::Time now = m_node->get_clock()->now(); 44 | m_message.header.stamp = now; 45 | } 46 | m_publisher->publish(m_message); 47 | } else 48 | RCLCPP_INFO( 49 | rclcpp::get_logger("imu_ros_publisher"), "error reading standard imu buffered data"); 50 | } 51 | -------------------------------------------------------------------------------- /src/ros_publisher_group.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file ros_publisher_group.cpp 3 | * @brief Implementation for group of publishers. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #include "adi_imu/ros_publisher_group.h" 22 | 23 | #include 24 | #include 25 | 26 | #include "adi_imu/accelgyrotemp_ros_publisher_interface.h" 27 | #include "adi_imu/imu_control_parameters.h" 28 | #include "adi_imu/imu_full_measured_data_ros_publisher_interface.h" 29 | #include "adi_imu/imu_ros_publisher_interface.h" 30 | #ifdef ADIS_HAS_DELTA_BURST 31 | #include "adi_imu/velangtemp_ros_publisher_interface.h" 32 | #endif 33 | 34 | RosPublisherGroup::RosPublisherGroup(std::shared_ptr & node) { m_node = node; } 35 | 36 | RosPublisherGroup::~RosPublisherGroup() {} 37 | 38 | void RosPublisherGroup::setAccelGyroTempRosPublisher( 39 | AccelGyroTempRosPublisherInterface * accelGyroTempRosPublisher) 40 | { 41 | m_accelGyroTempRosPublisher = accelGyroTempRosPublisher; 42 | } 43 | 44 | #ifdef ADIS_HAS_DELTA_BURST 45 | void RosPublisherGroup::setVelAngTempRosPublisher( 46 | VelAngTempRosPublisherInterface * velAngTempRosPublisher) 47 | { 48 | m_velAngTempRosPublisher = velAngTempRosPublisher; 49 | } 50 | #endif 51 | 52 | void RosPublisherGroup::setImuRosPublisher(ImuRosPublisherInterface * imuRosPublisher) 53 | { 54 | m_imuRosPublisher = imuRosPublisher; 55 | } 56 | 57 | void RosPublisherGroup::setImuFullMeasuredDataRosPublisher( 58 | ImuFullMeasuredDataRosPublisherInterface * imuFullMeasuredDataRosPublisher) 59 | { 60 | m_imuFullMeasuredDataRosPublisher = imuFullMeasuredDataRosPublisher; 61 | } 62 | 63 | void RosPublisherGroup::setImuControlParameters(ImuControlParameters * imuControlParameters) 64 | { 65 | m_imuControlParameters = imuControlParameters; 66 | } 67 | 68 | void RosPublisherGroup::run() 69 | { 70 | std::thread::id this_id = std::this_thread::get_id(); 71 | std::cout << "thread " << this_id << " started...\n"; 72 | RCLCPP_INFO(rclcpp::get_logger("ros_publisher_group"), "startThread: RosPublisherGroup"); 73 | 74 | int32_t measuredDataSelection; 75 | 76 | while (rclcpp::ok()) { 77 | measuredDataSelection = 78 | m_node->get_parameter("measured_data_topic_selection").get_parameter_value().get(); 79 | 80 | switch (measuredDataSelection) { 81 | case ACCEL_GYRO_BUFFERED_DATA: 82 | m_accelGyroTempRosPublisher->publish(); 83 | break; 84 | #ifdef ADIS_HAS_DELTA_BURST 85 | case DELTAVEL_DELTAANG_BUFFERED_DATA: 86 | m_velAngTempRosPublisher->publish(); 87 | break; 88 | #endif 89 | case IMU_STD_MSG_DATA: 90 | m_imuRosPublisher->publish(); 91 | break; 92 | case FULL_MEASURED_DATA: 93 | m_imuFullMeasuredDataRosPublisher->publish(); 94 | break; 95 | default: { 96 | RCLCPP_INFO( 97 | rclcpp::get_logger("ros_publisher_group"), 98 | "Invalid value for measured_data_topic_selection parameter."); 99 | break; 100 | } 101 | } 102 | 103 | m_imuControlParameters->handleControlParams(); 104 | 105 | rclcpp::spin_some(m_node); 106 | } 107 | 108 | this_id = std::this_thread::get_id(); 109 | std::cout << "thread " << this_id << " ended...\n"; 110 | RCLCPP_INFO(rclcpp::get_logger("ros_publisher_group"), "endThread: RosPublisherGroup"); 111 | } 112 | -------------------------------------------------------------------------------- /src/velangtemp_data_provider.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file velangtemp_data_provider.cpp 3 | * @brief Implementation for temperature, delta velocity and delta angle 4 | * data provider. 5 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 6 | ******************************************************************************* 7 | * Copyright 2023(c) Analog Devices, Inc. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | ******************************************************************************/ 21 | 22 | #include "adi_imu/velangtemp_data_provider.h" 23 | 24 | VelAngTempDataProvider::VelAngTempDataProvider() {} 25 | 26 | VelAngTempDataProvider::~VelAngTempDataProvider() {} 27 | 28 | bool VelAngTempDataProvider::getData(adi_imu::msg::VelAngTempData & message) 29 | { 30 | #ifdef ADIS_HAS_DELTA_BURST 31 | if (!m_iio_wrapper.updateBuffer(DELTAVEL_DELTAANG_BUFFERED_DATA)) return false; 32 | 33 | message.delta_angle.x = m_iio_wrapper.getBuffDeltaAngleX(); 34 | message.delta_angle.y = m_iio_wrapper.getBuffDeltaAngleY(); 35 | message.delta_angle.z = m_iio_wrapper.getBuffDeltaAngleZ(); 36 | 37 | message.delta_velocity.x = m_iio_wrapper.getBuffDeltaVelocityX(); 38 | message.delta_velocity.y = m_iio_wrapper.getBuffDeltaVelocityY(); 39 | message.delta_velocity.z = m_iio_wrapper.getBuffDeltaVelocityZ(); 40 | 41 | message.temperature = m_iio_wrapper.getBuffTemperature(); 42 | 43 | message.header.frame_id = "velangtempdata"; 44 | m_iio_wrapper.getBuffSampleTimestamp(message.header.stamp.sec, message.header.stamp.nanosec); 45 | 46 | return true; 47 | #else 48 | return false; 49 | #endif 50 | } 51 | -------------------------------------------------------------------------------- /src/velangtemp_ros_publisher.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file velangtemp_ros_publisher.cpp 3 | * @brief Implementation for temperature, delta velocity and delta angle 4 | * publisher. 5 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 6 | ******************************************************************************* 7 | * Copyright 2023(c) Analog Devices, Inc. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | *******************************************************************************/ 21 | 22 | #include "adi_imu/velangtemp_ros_publisher.h" 23 | 24 | #include 25 | #include 26 | 27 | VelAngTempRosPublisher::VelAngTempRosPublisher(std::shared_ptr & node) 28 | { 29 | m_node = node; 30 | m_publisher = node->create_publisher("velangtempdata", 10); 31 | } 32 | 33 | VelAngTempRosPublisher::~VelAngTempRosPublisher() { delete m_data_provider; } 34 | 35 | void VelAngTempRosPublisher::setMessageProvider(VelAngTempDataProviderInterface * dataProvider) 36 | { 37 | m_data_provider = dataProvider; 38 | } 39 | 40 | void VelAngTempRosPublisher::publish() 41 | { 42 | if (m_data_provider->getData(m_message)) { 43 | if (!m_message.header.stamp.sec && !m_message.header.stamp.nanosec) { 44 | rclcpp::Time now = m_node->get_clock()->now(); 45 | m_message.header.stamp = now; 46 | } 47 | m_publisher->publish(m_message); 48 | } else 49 | RCLCPP_INFO( 50 | rclcpp::get_logger("velangtemp_ros_publisher"), 51 | "error reading delta angle, delta velocity and temperature buffered data"); 52 | } 53 | -------------------------------------------------------------------------------- /src/worker_thread.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file worker_thread.cpp 3 | * @brief Implementation for ros imu threads. 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************* 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | ******************************************************************************/ 20 | 21 | #include "adi_imu/worker_thread.h" 22 | 23 | WorkerThread::WorkerThread(RosTask * rosTask) 24 | : std::thread([this] { this->runTask(); }), m_rosTask(rosTask) 25 | { 26 | } 27 | 28 | WorkerThread::~WorkerThread() {} 29 | 30 | void WorkerThread::runTask() { m_rosTask->run(); } 31 | -------------------------------------------------------------------------------- /test/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | adi_imu_test 5 | 0.0.1 6 | Tests for ADI IMUs Publisher 7 | rbolboac 8 | Apache License Version 2.0 9 | 10 | ament_cmake 11 | rclcpp 12 | std_msgs 13 | sensor_msgs 14 | 15 | ament_cmake_gtest 16 | 17 | builtin_interfaces 18 | rosidl_default_generators 19 | builtin_interfaces 20 | rosidl_default_runtime 21 | 22 | rosidl_interface_packages 23 | 24 | 25 | ament_cmake 26 | 27 | 28 | -------------------------------------------------------------------------------- /test/src/accelgyrotemp_subscriber_test.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file accelgyrotemp_subscriber_test.cpp 3 | * @brief Test acceleration, gyroscope and temperature 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************** 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | *******************************************************************************/ 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include "adi_imu/iio_wrapper.h" 27 | #include "adi_imu/msg/accel_gyro_temp_data.hpp" 28 | 29 | /** 30 | * @brief Class for testing AccelGyroTempData. 31 | * 32 | * This class instantiates a subscriber node and listens to data on 33 | * AccelGyroTempData topic and compares it against a range of expected 34 | * values. 35 | */ 36 | class AccelGyroTempSubscriberTest : public ::testing::Test 37 | { 38 | public: 39 | /** 40 | * @brief Set up the test case. 41 | */ 42 | static void SetUpTestCase() {} 43 | 44 | /** 45 | * @brief Tear down the test case. 46 | */ 47 | static void TearDownTestCase() { rclcpp::shutdown(); } 48 | }; 49 | 50 | /** 51 | * @brief AccelGyroTempSubscriberTest 52 | * 53 | * This test instantiates a subscriber node and listens to data on 54 | * AccelGyroTempData topic and compares it against a range of expected 55 | * values. 56 | */ 57 | TEST(AccelGyroTempSubscriberTest, test_accelgyrotemp_publisher) 58 | { 59 | IIOWrapper iio_wrapper; 60 | 61 | auto node = rclcpp::Node::make_shared("test_accelgyrotempdata_publisher"); 62 | 63 | node->declare_parameter("iio_context_string", "local:"); 64 | 65 | std::string context = 66 | node->get_parameter("iio_context_string").get_parameter_value().get(); 67 | IIOWrapper m_iio_wrapper; 68 | m_iio_wrapper.createContext(context.c_str()); 69 | 70 | std::string topic = "accelgyrotempdata"; 71 | 72 | double scale_accel = iio_wrapper.get_scale_accel(); 73 | double scale_anglvel = iio_wrapper.get_scale_anglvel(); 74 | double scale_temp = iio_wrapper.get_scale_temp(); 75 | bool callbackExecuted = false; 76 | 77 | auto callback = [&scale_accel, &scale_anglvel, &scale_temp, 78 | &callbackExecuted](adi_imu::msg::AccelGyroTempData msg) -> void { 79 | RCLCPP_INFO( 80 | rclcpp::get_logger("accelgyrotemp_subscriber_test"), 81 | "\nlinear acceleration x axis: %f \nlinear acceleration y axis: %f\nlinear acceleration z " 82 | "axis: %f\nangular velocity x axis: %f\nangular velocity y axis: %f\nangular velocity z " 83 | "axis: %f\n" 84 | "temperature: %f\n ", 85 | msg.linear_acceleration.x, msg.linear_acceleration.y, msg.linear_acceleration.z, 86 | msg.angular_velocity.x, msg.angular_velocity.y, msg.angular_velocity.z, msg.temperature); 87 | 88 | int32_t minint = -2147483648; 89 | int32_t maxint = 2147483647; 90 | 91 | double maxRangeAccel = maxint * scale_accel; 92 | double minRangeAccel = minint * scale_accel; 93 | 94 | double maxRangeAngvel = maxint * scale_anglvel; 95 | double minRangeAngvel = minint * scale_anglvel; 96 | 97 | int32_t minint16 = -32768; 98 | int32_t maxint16 = 32767; 99 | 100 | double maxRangeTemp = maxint16 * scale_temp; 101 | double minRangeTemp = minint16 * scale_temp; 102 | 103 | ASSERT_TRUE(msg.linear_acceleration.x >= minRangeAccel); 104 | ASSERT_TRUE(msg.linear_acceleration.y >= minRangeAccel); 105 | ASSERT_TRUE(msg.linear_acceleration.z >= minRangeAccel); 106 | 107 | ASSERT_TRUE(msg.linear_acceleration.x <= maxRangeAccel); 108 | ASSERT_TRUE(msg.linear_acceleration.y <= maxRangeAccel); 109 | ASSERT_TRUE(msg.linear_acceleration.z <= maxRangeAccel); 110 | 111 | ASSERT_TRUE(msg.angular_velocity.x >= minRangeAngvel); 112 | ASSERT_TRUE(msg.angular_velocity.y >= minRangeAngvel); 113 | ASSERT_TRUE(msg.angular_velocity.z >= minRangeAngvel); 114 | 115 | ASSERT_TRUE(msg.angular_velocity.x <= maxRangeAngvel); 116 | ASSERT_TRUE(msg.angular_velocity.y <= maxRangeAngvel); 117 | ASSERT_TRUE(msg.angular_velocity.z <= maxRangeAngvel); 118 | 119 | ASSERT_TRUE(msg.temperature >= minRangeTemp); 120 | ASSERT_TRUE(msg.temperature <= maxRangeTemp); 121 | 122 | callbackExecuted = true; 123 | }; 124 | 125 | rclcpp::executors::SingleThreadedExecutor executor; 126 | executor.add_node(node); 127 | 128 | auto subscriber = node->create_subscription(topic, 10, callback); 129 | 130 | std::chrono::seconds sec(1); 131 | 132 | while (!callbackExecuted) executor.spin_once(sec); 133 | } 134 | -------------------------------------------------------------------------------- /test/src/imu_diag_subscriber_test.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu__diag_subscriber_test.cpp 3 | * @brief Test imu diag data 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************** 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | *******************************************************************************/ 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include "adi_imu/adis_data_access.h" 27 | #include "adi_imu/msg/imu_diag_data.hpp" 28 | 29 | /** 30 | * @brief Class for testing ImuDiagData. 31 | * 32 | * This class instantiates a subscriber node and listens to data on 33 | * ImuDiagData topic and compares it against a range of expected 34 | * values. 35 | */ 36 | class ImuDiagSubscriberTest : public ::testing::Test 37 | { 38 | public: 39 | /** 40 | * @brief Set up the test case. 41 | */ 42 | static void SetUpTestCase() {} 43 | 44 | /** 45 | * @brief Tear down the test case. 46 | */ 47 | static void TearDownTestCase() { rclcpp::shutdown(); } 48 | }; 49 | 50 | /** 51 | * @brief ImuDiagSubscriberTest 52 | * 53 | * This test instantiates a subscriber node and listens to data on 54 | * ImuDiagData topic and compares it against a range of expected 55 | * values. 56 | */ 57 | TEST(ImuDiagSubscriberTest, test_imu__diag_data_publisher) 58 | { 59 | auto node = rclcpp::Node::make_shared("test_imudiagdata_publisher"); 60 | 61 | std::string topic = "imudiagdata"; 62 | bool callbackExecuted = false; 63 | 64 | auto callback = [&callbackExecuted](adi_imu::msg::ImuDiagData msg) -> void { 65 | 66 | #ifdef ADIS_SNSR_INIT_FAIL 67 | ASSERT_TRUE(msg.diag_sensor_initialization_failure == false); 68 | #endif 69 | #ifdef ADIS_DATA_PATH_OVERRUN 70 | ASSERT_TRUE(msg.diag_data_path_overrun == false); 71 | #endif 72 | #ifdef ADIS_WDG_TIMER_FLAG 73 | ASSERT_TRUE(msg.diag_automatic_reset == false); 74 | #endif 75 | #ifdef ADIS_FLS_MEM_UPDATE_FAIL 76 | ASSERT_TRUE(msg.diag_flash_memory_update_error == false); 77 | #endif 78 | #ifdef ADIS_SPI_COMM_ERR 79 | ASSERT_TRUE(msg.diag_spi_communication_error == false); 80 | #endif 81 | #ifdef ADIS_CRC_ERROR 82 | ASSERT_TRUE(msg.diag_crc_error == false); 83 | #endif 84 | #ifdef ADIS_STDBY_MODE 85 | ASSERT_TRUE(msg.diag_standby_mode == false); 86 | #endif 87 | #ifdef ADIS_SNSR_FAIL 88 | ASSERT_TRUE(msg.diag_sensor_self_test_error == false); 89 | #endif 90 | #ifdef ADIS_MEM_FAIL 91 | ASSERT_TRUE(msg.diag_flash_memory_test_error == false); 92 | #endif 93 | #ifdef ADIS_CLK_ERR 94 | ASSERT_TRUE(msg.diag_clock_error == false); 95 | #endif 96 | #ifdef ADIS_ACCEL_FAIL 97 | ASSERT_TRUE(msg.diag_acceleration_self_test_error == false); 98 | #endif 99 | #ifdef ADIS_GYRO1_FAIL 100 | ASSERT_TRUE(msg.diag_gyroscope1_self_test_error == false); 101 | #endif 102 | #ifdef ADIS_GYRO2_FAIL 103 | ASSERT_TRUE(msg.diag_gyroscope2_self_test_error == false); 104 | #endif 105 | #ifdef ADIS_GYRO_X_FAIL 106 | ASSERT_TRUE(msg.diag_x_axis_gyroscope_failure == false); 107 | #endif 108 | #ifdef ADIS_GYRO_Y_FAIL 109 | ASSERT_TRUE(msg.diag_y_axis_gyroscope_failure == false); 110 | #endif 111 | #ifdef ADIS_GYRO_Z_FAIL 112 | ASSERT_TRUE(msg.diag_z_axis_gyroscope_failure == false); 113 | #endif 114 | #ifdef ADIS_ACCEL_X_FAIL 115 | ASSERT_TRUE(msg.diag_x_axis_accelerometer_failure == false); 116 | #endif 117 | #ifdef ADIS_ACCEL_Y_FAIL 118 | ASSERT_TRUE(msg.diag_y_axis_accelerometer_failure == false); 119 | #endif 120 | #ifdef ADIS_ACCEL_Z_FAIL 121 | ASSERT_TRUE(msg.diag_z_axis_accelerometer_failure == false); 122 | #endif 123 | #ifdef ADIS_ADUC_MCU_FAULT 124 | ASSERT_TRUE(msg.diag_aduc_mcu_fault == false); 125 | #endif 126 | ASSERT_TRUE(msg.diag_flash_memory_write_count_exceeded_error == false); 127 | 128 | ASSERT_TRUE(msg.flash_counter < ADIS_FLS_MEM_ENDURANCE); 129 | callbackExecuted = true; 130 | }; 131 | 132 | rclcpp::executors::SingleThreadedExecutor executor; 133 | executor.add_node(node); 134 | 135 | auto subscriber = node->create_subscription(topic, 10, callback); 136 | 137 | std::chrono::seconds sec(1); 138 | 139 | while (!callbackExecuted) executor.spin_once(sec); 140 | } 141 | -------------------------------------------------------------------------------- /test/src/imu_identification_subscriber_test.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_identification_subscriber_test.cpp 3 | * @brief Test imu identification data 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************** 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | *******************************************************************************/ 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include "adi_imu/iio_wrapper.h" 27 | #include "adi_imu/msg/imu_identification_data.hpp" 28 | 29 | /** 30 | * @brief Class for testing ImuIdentificationData. 31 | * 32 | * This class instantiates a subscriber node and listens to data on 33 | * ImuIdentificationData topic and compares it against a range of expected 34 | * values. 35 | */ 36 | class ImuIdentificationSubscriberTest : public ::testing::Test 37 | { 38 | public: 39 | /** 40 | * @brief Set up the test case. 41 | */ 42 | static void SetUpTestCase() {} 43 | 44 | /** 45 | * @brief Tear down the test case. 46 | */ 47 | static void TearDownTestCase() { rclcpp::shutdown(); } 48 | }; 49 | 50 | /** 51 | * @brief ImuIdentificationSubscriberTest 52 | * 53 | * This test instantiates a subscriber node and listens to data on 54 | * ImuIdentificationData topic and compares it against a range of expected 55 | * values. 56 | */ 57 | TEST(ImuIdentificationSubscriberTest, test_imu_identification_publisher) 58 | { 59 | IIOWrapper iio_wrapper; 60 | 61 | auto node = rclcpp::Node::make_shared("test_imuidentificationdata_publisher"); 62 | 63 | node->declare_parameter("iio_context_string", "local:"); 64 | 65 | std::string context = 66 | node->get_parameter("iio_context_string").get_parameter_value().get(); 67 | IIOWrapper m_iio_wrapper; 68 | m_iio_wrapper.createContext(context.c_str()); 69 | 70 | std::string topic = "imuidentificationdata"; 71 | 72 | bool callbackExecuted = false; 73 | adi_imu::msg::ImuIdentificationData imu_message; 74 | 75 | iio_wrapper.firmware_revision(imu_message.firmware_revision); 76 | iio_wrapper.firmware_date(imu_message.firmware_date); 77 | iio_wrapper.product_id(imu_message.product_id); 78 | iio_wrapper.serial_number(imu_message.serial_number); 79 | iio_wrapper.gyroscope_measurement_range(imu_message.gyroscope_measurement_range); 80 | 81 | auto callback = [&imu_message, 82 | &callbackExecuted](adi_imu::msg::ImuIdentificationData msg) -> void { 83 | RCLCPP_INFO( 84 | rclcpp::get_logger("imu_identification_subscriber_test"), 85 | "\nproduct id: %d" 86 | "\nserial number: %d" 87 | "\nfirmware revision: %s" 88 | "\nfirmare date: %s" 89 | "\ngyroscope measurement range: %s", 90 | msg.product_id, msg.serial_number, msg.firmware_revision.c_str(), msg.firmware_date.c_str(), 91 | msg.gyroscope_measurement_range.c_str()); 92 | ASSERT_TRUE(msg.firmware_revision == imu_message.firmware_revision); 93 | ASSERT_TRUE(msg.firmware_date == imu_message.firmware_date); 94 | ASSERT_TRUE(msg.product_id == imu_message.product_id); 95 | ASSERT_TRUE(msg.serial_number == imu_message.serial_number); 96 | ASSERT_TRUE(msg.gyroscope_measurement_range == imu_message.gyroscope_measurement_range); 97 | callbackExecuted = true; 98 | }; 99 | 100 | rclcpp::executors::SingleThreadedExecutor executor; 101 | executor.add_node(node); 102 | 103 | auto subscriber = 104 | node->create_subscription(topic, 10, callback); 105 | 106 | std::chrono::seconds sec(1); 107 | 108 | while (!callbackExecuted) executor.spin_once(sec); 109 | } 110 | -------------------------------------------------------------------------------- /test/src/imu_subscriber_test.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file imu_subscriber_test.cpp 3 | * @brief Test acceleration 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************** 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | *******************************************************************************/ 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "adi_imu/iio_wrapper.h" 28 | 29 | /** 30 | * @brief Class for testing sensor_msgs::msg::Imu. 31 | * 32 | * This class instantiates a subscriber node and listens to data on 33 | * sensor_msgs::msg::Imu topic and compares it against a range of expected 34 | * values. 35 | */ 36 | class ImuSubscriberTest : public ::testing::Test 37 | { 38 | public: 39 | /** 40 | * @brief Set up the test case. 41 | */ 42 | static void SetUpTestCase() {} 43 | 44 | /** 45 | * @brief Tear down the test case. 46 | */ 47 | static void TearDownTestCase() { rclcpp::shutdown(); } 48 | }; 49 | 50 | /** 51 | * @brief ImuSubscriberTest 52 | * 53 | * This test instantiates a subscriber node and listens to data on 54 | * sensor_msgs::msg::Imu topic and compares it against a range of expected 55 | * values. 56 | */ 57 | TEST(ImuSubscriberTest, test_imu_publisher) 58 | { 59 | IIOWrapper iio_wrapper; 60 | 61 | auto node = rclcpp::Node::make_shared("test_imu_publisher"); 62 | 63 | node->declare_parameter("iio_context_string", "local:"); 64 | 65 | std::string context = 66 | node->get_parameter("iio_context_string").get_parameter_value().get(); 67 | IIOWrapper m_iio_wrapper; 68 | m_iio_wrapper.createContext(context.c_str()); 69 | 70 | std::string topic = "imu"; 71 | 72 | double scale_accel = iio_wrapper.get_scale_accel(); 73 | double scale_angvel = iio_wrapper.get_scale_anglvel(); 74 | 75 | bool callbackExecuted = false; 76 | 77 | auto callback = [&scale_accel, &scale_angvel, 78 | &callbackExecuted](sensor_msgs::msg::Imu msg) -> void { 79 | RCLCPP_INFO( 80 | rclcpp::get_logger("imu_subscriber_test"), 81 | "\nlinear acceleration x axis: %f \nlinear acceleration y axis: %f\nlinear acceleration z " 82 | "axis: %f\n" 83 | "angular velocity x axis: %f\nangular velocity y axis: %f\nangular velocity z axis: %f\n", 84 | msg.linear_acceleration.x, msg.linear_acceleration.y, msg.linear_acceleration.z, 85 | msg.angular_velocity.x, msg.angular_velocity.y, msg.angular_velocity.z); 86 | 87 | int32_t minint = -2147483648; 88 | int32_t maxint = 2147483647; 89 | 90 | double maxRangeAccel = maxint * scale_accel; 91 | double minRangeAccel = minint * scale_accel; 92 | 93 | double maxRangeAngvel = maxint * scale_angvel; 94 | double minRangeAngvel = minint * scale_angvel; 95 | 96 | ASSERT_TRUE(msg.linear_acceleration.x >= minRangeAccel); 97 | ASSERT_TRUE(msg.linear_acceleration.y >= minRangeAccel); 98 | ASSERT_TRUE(msg.linear_acceleration.z >= minRangeAccel); 99 | 100 | ASSERT_TRUE(msg.linear_acceleration.x <= maxRangeAccel); 101 | ASSERT_TRUE(msg.linear_acceleration.y <= maxRangeAccel); 102 | ASSERT_TRUE(msg.linear_acceleration.z <= maxRangeAccel); 103 | 104 | ASSERT_TRUE(msg.angular_velocity.x >= minRangeAngvel); 105 | ASSERT_TRUE(msg.angular_velocity.y >= minRangeAngvel); 106 | ASSERT_TRUE(msg.angular_velocity.z >= minRangeAngvel); 107 | 108 | ASSERT_TRUE(msg.angular_velocity.x <= maxRangeAngvel); 109 | ASSERT_TRUE(msg.angular_velocity.y <= maxRangeAngvel); 110 | ASSERT_TRUE(msg.angular_velocity.z <= maxRangeAngvel); 111 | callbackExecuted = true; 112 | }; 113 | 114 | rclcpp::executors::SingleThreadedExecutor executor; 115 | executor.add_node(node); 116 | 117 | auto subscriber = node->create_subscription(topic, 10, callback); 118 | 119 | std::chrono::seconds sec(1); 120 | 121 | while (!callbackExecuted) executor.spin_once(sec); 122 | } 123 | -------------------------------------------------------------------------------- /test/src/utest.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file utest.cpp 3 | * @brief Main function for testing 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************** 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | *******************************************************************************/ 20 | 21 | #include 22 | 23 | #include 24 | 25 | TEST(TestSuite, myworkcell_core_framework) { ASSERT_TRUE(true); } 26 | 27 | int main(int argc, char ** argv) 28 | { 29 | rclcpp::init(argc, argv); 30 | testing::InitGoogleTest(&argc, argv); 31 | return RUN_ALL_TESTS(); 32 | } 33 | -------------------------------------------------------------------------------- /test/src/velangtemp_subscriber_test.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @file velangtemp_subscriber_test.cpp 3 | * @brief Test vel ang temp publisher 4 | * @author Vasile Holonec (Vasile.Holonec@analog.com) 5 | ******************************************************************************** 6 | * Copyright 2023(c) Analog Devices, Inc. 7 | 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | *******************************************************************************/ 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include "adi_imu/iio_wrapper.h" 27 | #include "adi_imu/msg/vel_ang_temp_data.hpp" 28 | 29 | /** 30 | * @brief Class for testing VelAngTempData. 31 | * 32 | * This class instantiates a subscriber node and listens to data on 33 | * VelAngTempData topic and compares it against a range of expected 34 | * values. 35 | */ 36 | class VelAngTempSubscriberTest : public ::testing::Test 37 | { 38 | public: 39 | /** 40 | * @brief Set up the test case. 41 | */ 42 | static void SetUpTestCase() {} 43 | 44 | /** 45 | * @brief Tear down the test case. 46 | */ 47 | static void TearDownTestCase() { rclcpp::shutdown(); } 48 | }; 49 | 50 | /** 51 | * @brief VelAngTempSubscriberTest 52 | * 53 | * This test instantiates a subscriber node and listens to data on 54 | * VelAngTempData topic and compares it against a range of expected 55 | * values. 56 | */ 57 | #ifdef ADIS_HAS_DELTA_BURST 58 | TEST(VelAngTempSubscriberTest, test_velangtemp_publisher) 59 | { 60 | IIOWrapper iio_wrapper; 61 | 62 | auto node = rclcpp::Node::make_shared("test_velangtempdata_publisher"); 63 | 64 | node->declare_parameter("iio_context_string", "local:"); 65 | 66 | std::string context = 67 | node->get_parameter("iio_context_string").get_parameter_value().get(); 68 | IIOWrapper m_iio_wrapper; 69 | m_iio_wrapper.createContext(context.c_str()); 70 | 71 | std::string topic = "velangtempdata"; 72 | 73 | double scale_deltavelocity = iio_wrapper.get_scale_deltavelocity(); 74 | double scale_deltaangl = iio_wrapper.get_scale_deltaangl(); 75 | double scale_temp = iio_wrapper.get_scale_temp(); 76 | bool callbackExecuted = false; 77 | 78 | auto callback = [&scale_deltavelocity, &scale_deltaangl, &scale_temp, 79 | &callbackExecuted](adi_imu::msg::VelAngTempData msg) -> void { 80 | RCLCPP_INFO( 81 | rclcpp::get_logger("velangtemp_subscriber_test"), 82 | "delta velocity x axis: %f \ndelta velocity y axis: %f\ndelta velocity z axis: %f\n" 83 | "delta angle x axis: %f\ndelta angle y axis: %f\ndelta angle z axis: %f\n" 84 | "temperature: %f\n", 85 | msg.delta_velocity.x, msg.delta_velocity.y, msg.delta_velocity.z, msg.delta_angle.x, 86 | msg.delta_angle.y, msg.delta_angle.z, msg.temperature); 87 | 88 | int32_t minint = -2147483648; 89 | int32_t maxint = 2147483647; 90 | 91 | double maxRangeVelocity = maxint * scale_deltavelocity; 92 | double minRangeVelocity = minint * scale_deltavelocity; 93 | 94 | double maxRangeRot = maxint * scale_deltaangl; 95 | double minRangeRot = minint * scale_deltaangl; 96 | 97 | int32_t minint16 = -32768; 98 | int32_t maxint16 = 32767; 99 | 100 | double maxRangeTemp = maxint16 * scale_temp; 101 | double minRangeTemp = minint16 * scale_temp; 102 | 103 | ASSERT_TRUE( 104 | msg.delta_velocity.x >= minRangeVelocity && msg.delta_velocity.x <= maxRangeVelocity); 105 | ASSERT_TRUE( 106 | msg.delta_velocity.y >= minRangeVelocity && msg.delta_velocity.y <= maxRangeVelocity); 107 | ASSERT_TRUE( 108 | msg.delta_velocity.z >= minRangeVelocity && msg.delta_velocity.z <= maxRangeVelocity); 109 | ASSERT_TRUE(msg.delta_angle.x >= minRangeRot && msg.delta_angle.x <= maxRangeRot); 110 | ASSERT_TRUE(msg.delta_angle.y >= minRangeRot && msg.delta_angle.y <= maxRangeRot); 111 | ASSERT_TRUE(msg.delta_angle.z >= minRangeRot && msg.delta_angle.z <= maxRangeRot); 112 | ASSERT_TRUE(msg.temperature >= minRangeTemp && msg.temperature <= maxRangeTemp); 113 | callbackExecuted = true; 114 | }; 115 | 116 | rclcpp::executors::SingleThreadedExecutor executor; 117 | executor.add_node(node); 118 | 119 | auto subscriber = node->create_subscription(topic, 10, callback); 120 | 121 | std::chrono::seconds sec(1); 122 | 123 | while (!callbackExecuted) executor.spin_once(sec); 124 | } 125 | #endif 126 | -------------------------------------------------------------------------------- /test/utest_launch.test: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | --------------------------------------------------------------------------------