chvmp / champ

MIT Cheetah I Implementation
BSD 3-Clause "New" or "Revised" License
1.52k stars 354 forks source link

Can't change IMU orientation #128

Closed mattwilliamson closed 1 year ago

mattwilliamson commented 1 year ago

I have made a robot based on SpotMicro and it can walk around and map with LIDAR. I've also installed an IMU: BNO080. I am publishing to the /imu/data topic, but in RVIZ, it yaws when I pitch the robot up and down. All other axes are ignored. I tried a static transform, but it doesn't seem to affect anything.

I referred to http://docs.ros.org/en/melodic/api/robot_localization/html/preparing_sensor_data.html and tried this:

<node pkg="tf2_ros" type="static_transform_publisher" name="base_link_to_imu"   
    args="0 0 0 1.5708 1.5708 1.5708 $(arg frame_prefix)base_link $(arg frame_prefix)imu_link" />

I also tried in the URDF like this:

  <link name="imu_link">
    <inertial>
      <mass value="0.001"/>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <inertia ixx="1e-09" ixy="0.0" ixz="0.0" iyy="1e-09" iyz="0.0" izz="1e-09"/>
    </inertial>
  </link>
  <joint name="imu_joint" type="fixed">
    <parent link="base_link"/>
    <child link="imu_link"/>
    <origin rpy="0 1.5708 1.5708" xyz="0.0 -0.015 -0.013662"/>
  </joint>

But no matter what rotation I transform, pitching the robot up and down results in yaw in RVIZ.

Where can I apply a transform on the IMU data to correct the orientation?

Thanks!

mattwilliamson commented 1 year ago

A little more debugging info:

rosrun tf tf_echo imu_link base_link
At time 0.000
- Translation: [-0.014, -0.000, 0.015]
- Rotation: in Quaternion [0.500, -0.500, -0.500, 0.500]
            in RPY (radian) [1.571, 0.000, -1.571]
            in RPY (degree) [90.000, 0.000, -90.000]

Then I change the origin in the URDF:

At time 0.000
- Translation: [-0.014, 0.015, 0.000]
- Rotation: in Quaternion [0.000, -0.707, 0.000, 0.707]
            in RPY (radian) [0.000, -1.571, 0.000]
            in RPY (degree) [0.000, -90.000, 0.000]
mattwilliamson commented 1 year ago

I have resorted to using this transformer:

            <node pkg="imu_transformer" type="imu_transformer_node" name="imu_data_transformer" output="screen">
                <remap from="imu_in" to="imu_raw"/>
                <remap from="imu_out" to="imu"/>
                <param name="target_frame" value="base_link"/>
            </node>

With this URDF:

  <link name="imu_link">
    <inertial>
      <mass value="0.001"/>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <inertia ixx="1e-09" ixy="0.0" ixz="0.0" iyy="1e-09" iyz="0.0" izz="1e-09"/>
    </inertial>
  </link>
  <joint name="imu_joint" type="fixed">
    <parent link="base_link"/>
    <child link="imu_link"/>
    <origin rpy="0 1.570795 0" xyz="0.0 -0.015 -0.013662"/>
  </joint>

As I yaw the robot, I can see the Z axis changing on the imu/data/ topic, but somehow still in rviz, it only yaws if I pitch the robot.

mattwilliamson commented 1 year ago

I was able to solve this with the above transformer