2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Dynamixelの位置制御で速度を操作する方法

Last updated at Posted at 2024-12-18

はじめに

こんにちは,ロボット制作などをしている高校生のBasalteと申します.
今回はDyamixelで位置制御をしているときに,その位置までに至るための速度を調節する方法を紹介します.

DynamixelSDK

今回はROS2 Humble DynamixelSDKでの動作確認となっています.
その他の環境では検証していません(バイナリを叩いているのでおそらくどの環境でも行けると思います).
DynamixelをROS2 Humble DynamixelSDKで扱う基本的なところはこちらで詳しく解説されているので,こちらをご覧ください.

Profile Velocity

Dynamixelの位置制御で速度を制御するために,Profile Velocityというものを使います.

基本的な位置制御をするROS2 C++を用意し,次の内容を書き足していきます.

こちらの記事の"Position Control Mode:位置制御"の章で使用している
ros2 run dynamixel_sdk_examples read_write_position_node
に書き足していきます.

まず必要な変数を追加します.

#define ADDR_DRIVE_MODE           10
#define TIME_BASED_PROFILE        4

#define PROFILE_VELOCITY          112

こちらの171行目付近のsetupDynamixel()の中に以下を追加します.
dxl_idはお好みで設定してください.そのままだと接続されているすべてのDynamixelでこの設定が適応されます.

dxl_comm_result = packetHandler->write1ByteTxRx(
        portHandler,
        dxl_id,
        ADDR_DRIVE_MODE,
        TIME_BASED_PROFILE,  
        &dxl_error
  );
  
uint32_t arm_profile = 1500;

dxl_comm_result = packetHandler->write4ByteTxRx(
        portHandler,
        dxl_id,
        PROFILE_VELOCITY,
        arm_profile,
        &dxl_error
  );

こうすることにより,Drive modeがTime based profileを表す4に設定され,Profile velocityがarm_profile変数の1500に定義されます.
この1500を変えることにより,速度を調整することができます.

速度調整

速度を調整するためにいちいち設定を変更してビルドファイルを削除しcolcon buildするのも面倒です.
そのため,Dynamixel Wiardで調整をすることができます.
Drive modeをBit 2 Time-based Profileに設定してsaveし,
image.png

Profile Velocityの数値を変更して位置制御で動かします.
image.png

トルクを入れたままProfile Velocityの値を変更して最適な設定を見つけることができます.(動く幅が狭いととてもゆっくりになるため、そのあたりも好みで調整しましょう)

おわりに

今回はDynamixelの位置制御時の速度を設定する方法を紹介しました.
今後もロボットに関する記事を投稿していきます.よろしくお願いいたします.

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?