welcom ! Handel home

2025年2月5日 星期三

(兩輪小車範例)解析 joint (輪子關節)

 

解析 joint (輪子關節)

這兩段 <joint> 代碼定義了機器人的 驅動輪,即:

  • 左輪 (left_wheel_hinge)
  • 右輪 (right_wheel_hinge)

這些關節 (joint) 讓 底盤 (chassis)輪子 (left_wheelright_wheel) 連接起來,並允許它們旋轉。


📌 結構解析

1️⃣ joint 的基本結構

<joint type="continuous" name="left_wheel_hinge"> <origin xyz="0.1 0.15 0" rpy="0 0 0"/> <child link="left_wheel"/> <parent link="chassis"/> <axis xyz="0 1 0" rpy="0 0 0"/> <limit effort="100" velocity="100"/> <joint_properties damping="0.0" friction="0.0"/> </joint>
  • type="continuous" → 這是 無限旋轉關節(適用於輪子)。
  • <origin> → 決定輪子的相對位置:
    • xyz="0.1 0.15 0" → 輪子在 chassis 的 **前方 (x=0.1)、左側 (y=0.15)、地面 (z=0)`。
    • rpy="0 0 0" → 沒有旋轉變化。
  • <child>輪子 (left_wheel) 是子連接點
  • <parent>底盤 (chassis) 是父連接點
  • <axis xyz="0 1 0"/>輪子沿 y 軸旋轉(這符合車輛運動)。

2️⃣ right_wheel_hinge (右輪)

<joint type="continuous" name="right_wheel_hinge"> <origin xyz="0.1 -0.15 0" rpy="0 0 0"/> <child link="right_wheel"/> <parent link="chassis"/> <axis xyz="0 1 0" rpy="0 0 0"/> <limit effort="100" velocity="100"/> <joint_properties damping="0.0" friction="0.0"/> </joint>
  • 與左輪結構相同,唯一不同的是:
    • xyz="0.1 -0.15 0" → 右輪位於 機器人右側 (y=-0.15)

3️⃣ axis (旋轉軸)

<axis xyz="0 1 0" rpy="0 0 0"/>
  • xyz="0 1 0" → 表示輪子沿 y 軸旋轉,這符合車輪的驅動方式。
  • 如果 axis="0 0 1",輪子就會z 軸旋轉,這是不對的(因為車輪應該前後轉動,而不是左右旋轉)。

4️⃣ limit (限制)

<limit effort="100" velocity="100"/>
  • effort="100" → 限制輪子的最大驅動力為 100,確保不會施加過大扭矩。
  • velocity="100" → 限制最大轉速 100,避免輪子轉動過快。

🚀 這些參數在 Gazebo 內影響物理模擬,可以根據需要調整


5️⃣ joint_properties (關節屬性)

<joint_properties damping="0.0" friction="0.0"/>
  • damping="0.0" → 無額外阻尼,表示關節沒有額外的減速效果。
  • friction="0.0" → 無摩擦力,表示輪子可以自由旋轉。

🛠 如果輪子在模擬中滑動過多,可能需要適當增加 dampingfriction


✅ 這段代碼的總結

部分作用細節
joint (連接底盤與輪子)定義輪子的旋轉方式無限旋轉 (continuous),可驅動機器人前進
<origin>設定輪子相對於底盤的位置xyz="0.1 ±0.15 0",前方 0.1m,左右 0.15m
<axis>定義旋轉軸xyz="0 1 0",輪子繞 y 軸旋轉
<limit>設定輪子驅動力與速度限制effort="100"velocity="100"
<joint_properties>設定摩擦與阻尼damping="0.0"friction="0.0"

🚀 可能的修改建議

1️⃣ 調整 limit 限制

  • 如果輪子轉動速度過快,可降低 velocity
    <limit effort="100" velocity="10"/>
    這樣可減少模擬中輪子的抖動。

2️⃣ 增加摩擦力

  • 如果輪子在 Gazebo 容易滑動,可以增加 摩擦 (friction)
    <joint_properties damping="0.1" friction="0.2"/>
    這會讓輪子更穩定,不會過度滑行。

🎯 總結

這段代碼為 機器人左/右輪的關節 (joint) 設定

  • 允許輪子無限旋轉 (continuous),適用於驅動輪。
  • 輪子繞 y 軸旋轉 (axis="0 1 0"),這是車輪的正確旋轉方式。
  • 限制最大驅動力 (effort=100) 和速度 (velocity=100),避免過快或過強驅動。
  • 目前 damping=0.0, friction=0.0,可能需要根據模擬情況調整,確保輪子不會無限滑動。

🚀 你還需要進一步的修改或測試嗎?

  • 需要 調整速度、摩擦力
  • 需要 加入馬達控制 (gazebo_ros_control)
  • 需要 讓機器人在 Gazebo 運行測試

=======================================================


  <joint type="continuous" name="left_wheel_hinge">
    <origin xyz="0.1 0.15 0" rpy="0 0 0"/>
    <child link="left_wheel"/>
    <parent link="chassis"/>
    <axis xyz="0 1 0" rpy="0 0 0"/>
    <limit effort="100" velocity="100"/>
    <joint_properties damping="0.0" friction="0.0"/>
  </joint>

  <joint type="continuous" name="right_wheel_hinge">
    <origin xyz="0.1 -0.15 0" rpy="0 0 0"/>
    <child link="right_wheel"/>
    <parent link="chassis"/>
    <axis xyz="0 1 0" rpy="0 0 0"/>
    <limit effort="100" velocity="100"/>
    <joint_properties damping="0.0" friction="0.0"/>
  </joint>


沒有留言: