Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add test for readSensorData() #57

Merged
merged 15 commits into from
Aug 20, 2024
Merged

Add test for readSensorData() #57

merged 15 commits into from
Aug 20, 2024

Conversation

YusukeKato
Copy link
Contributor

@YusukeKato YusukeKato commented Aug 7, 2024

What does this implement/fix?

RtUsb9axisimuRosDriver::readSensorData()を実行した後に以下の検証を行うテストを追加します。

  • センサから正しくデータを取得できているか
  • センサから取得したデータが正しく変換されているか

Does this close any currently open issues?

しません。

How has this been tested?

colcon testで全てのテストが通ることを確認しました。

Any other comments?

各センサデータの値の正誤判定において設定した精度が正しいか確認いただきたいです。

該当箇所:https://github.com/rt-net/rt_usb_9axisimu_driver/blob/add_read_test/test/test_driver.cpp#L418

下記の参考ページによると16bitの浮動小数点数では精度が11bit(10進数では3桁程度)ということなので、現状の実装では小数点第3位まで正しいか確認しています。

参考:https://ja.wikipedia.org/wiki/%E5%8D%8A%E7%B2%BE%E5%BA%A6%E6%B5%AE%E5%8B%95%E5%B0%8F%E6%95%B0%E7%82%B9%E6%95%B0

Checklists

@YusukeKato YusukeKato requested a review from ShotaAk August 9, 2024 08:38
@YusukeKato YusukeKato self-assigned this Aug 9, 2024
@YusukeKato YusukeKato added the Type: Feature New Feature label Aug 9, 2024
Copy link
Contributor

@ShotaAk ShotaAk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

いくつかコメントしたので確認お願いします。

include/rt_usb_9axisimu_driver/rt_usb_9axisimu_driver.hpp Outdated Show resolved Hide resolved
test/test_driver.cpp Outdated Show resolved Hide resolved
test/test_driver.cpp Outdated Show resolved Hide resolved
test/test_driver.cpp Outdated Show resolved Hide resolved
test/test_driver.cpp Outdated Show resolved Hide resolved
test/test_driver.cpp Show resolved Hide resolved
test/test_driver.cpp Outdated Show resolved Hide resolved
test/test_driver.cpp Outdated Show resolved Hide resolved
@YusukeKato
Copy link
Contributor Author

全てのコメントに対応しました。

Comment on lines 76 to 78
rt_usb_9axisimu::Consts consts;
const int test_firmfare_ver = 18;
consts.ChangeConvertor(test_firmfare_ver);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

細かい指摘です。constsはクラス内で使用されていないので削除してください。

Asciiの方も同様に削除してください。

Copy link
Contributor

@ShotaAk ShotaAk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ShotaAk ShotaAk merged commit c63da0b into ros2-devel Aug 20, 2024
2 checks passed
@ShotaAk ShotaAk deleted the add_read_test branch August 20, 2024 01:57
ShotaAk added a commit that referenced this pull request Aug 23, 2024
* Add unit tests (#52)

* Use pointer for SerialPort instance instead of inheritance

* Add test using fakeit

* Install git comand in indsutrial_ci

* Refactoring

* Update CI

* Use AFTER_SETUP_TARGET_WORKSPACE

* driverインスタンスのメンバ変数のテストを追加

* バイナリデータが読み込まれたことを確認するテストを追加

* ASCIIデータが読み込まれたことを確認するテストを追加

* バイナリでもASCIIでもないデータが読み込まれたことを確認するテストを追加

* テストが通る状態に修正

---------

Co-authored-by: ShotaAk <s.aoki@rt-net.jp>

* checkDataFormat() and unit test updates (#54)

* Binaryデータ出力時は実機とテストの両方で動作確認完了、ASCIIデータには未対応、デバッグ用出力あり

* 実機とテストの両方でBinaryとASCIIの判定に成功、BinaryでもASCIIでもないデータには未対応

* タイムアウト機能を追加&hasCompletedFormatCheck()と関係する変数を削除

* 不正なデータをチェックするようにテストを修正

* readを成功させるためにwhileループにsleep処理を追加

* 必要がなかったため、while文のsleep処理を削除

* テスト用データの作成で重複している箇所を関数化

* RCLCPP_INFOをWARNに変更&不要なコメントを削除

* const autoをできる限り使用

* actions/checkoutのバージョンを3から4に更新

* 読み取ったデータをある程度貯めてからデータ形式を判定するように変更

* 貯めるデータを更新するように修正

* メンバ変数の名前を修正&256を定数化

* Add test for readSensorData() (#57)

* readSensorData()実行後のhasRefreshedImuData()の応答のテストを追加

* テストにコメントを追加

* 0.0を入力として与えたテストを追加

* ASCII形式のテストデータを作成する際、引数で値を渡せるように変更

* Binary形式でもテストデータを引数で渡せるように変更

* テストケースを使い回せるように変更

* readSensorData()実行時にセンサデータが正しく変換されたか検証するテストを追加

* デバッグ用の関数を削除

* short intをint16_tに変更

* int16を8bitずつに分ける関数をhighとlowそれぞれ用意

* 既存のテストに影響を与えないようにデータ作成の関数をオーバーロード

* set_data関数をprivateに変更

* 変換後の数値を直打ち

* data_format_を設定する関数を削除

* 不要な箇所を削除

* Fix to get the latest data (#58)

* 最新データ取得のテストを追加

* PR#50を参考に最新のデータを取得できるように変更

* 複数セットのデータ取得時に最新のデータをセットするように変更、テストは通るが挙動がおかしい

* 最新データの取得方法を修正

* 取得するデータが適切な長さであることを保証する

* 2.1.0リリースのためにCHANGELOG.rstとpackage.xmlを更新 (#59)

* CHANGELOGを更新

* 2.1.0

---------

Co-authored-by: ShotaAk <s.aoki@rt-net.jp>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants