chvmp / champ

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

Robot's legs disappear when I run with hardware_connected:=true #96

Closed TonyLiu836 closed 1 year ago

TonyLiu836 commented 1 year ago

Hi,

I'm trying to integrate Champ with a physical robot based on the Open Quadruped design using a Raspberry Pi 3B+.

When I run the following:

roslaunch open_quadruped_config bringup.launch rviz:=true

Everything works correctly and the robot fully renders in Rviz and I am able to control it through teleop.

However, when I set the hardware_connected flag to true

roslaunch open_quadruped_config bringup.launch rviz:=true hardware_connected:=true

Only the body of the robot shows up correctly in RViz but none of the legs or shoulder pieces show up. I do not get any errors either.

Here's a screenshot showing the problem. Screenshot at 2022-08-18 09-43-45

Here's the launch file in the open_quadruped_config folder.

<launch>
    <arg name="robot_name"              default="/"/>  <!-- Change this for namespacing. -->
    <arg name="base_frame"             default="base_link"/> <!-- Link name of floating base. Do not touch this. -->
    <arg name="joints_map_file"        default="$(find open_quadruped_config)/config/joints/joints.yaml"/> <!--Path to list of joint names. Do not touch this. -->
    <arg name="links_map_file"         default="$(find open_quadruped_config)/config/links/links.yaml"/> <!-- Path to list of link names. Do not touch this. -->
    <arg name="gait_config_file"       default="$(find open_quadruped_config)/config/gait/gait.yaml"/>  <!-- Path to gait parameters. Do not touch this. -->
    <arg name="description_file"       default="$(find mini_ros)/urdf/spot_accessories.urdf"/> <!-- Path to URDF file Do not touch this. -->
    <arg name="gazebo"                 default="false" /> <!-- Set to true during simulation. This is auto-set to true from gazebo.launch. -->
    <arg name="rviz"                   default="false"/> <!-- Set to true to run rviz in parallel. -->
    <arg name="rviz_ref_frame"         default="odom"/> <!-- Default RVIZ reference frame. -->
    <arg name="has_imu"                default="true" /> <!-- Set to true if you want to visualize robot but there's no IMU. Only useful for microcontrollers. -->
    <arg name="lite"                   default="false" /> <!-- Set to true if you're using CHAMP lite version. Only useful for microcontrollers. -->
    <arg name="close_loop_odom"        default="false" /> <!-- Set to true if you want to calculate odometry using close loop. This is auto-set to true from gazebo.launch. -->
    <arg name="publish_foot_contacts"  default="true" /> <!-- Set to true if you want the controller to publish the foot contact states. This is auto-set to false from gazebo.launch. -->
    <arg name="publish_joint_control"  default="true" /> <!-- Set to true if you want the controller to publish the joint_states topic. This is auto-set to false from gazebo.launch. -->
    <arg name="laser"                  default="sim"/> <!-- Set to the 2D LIDAR you're using. See https://github.com/chvmp/champ/tree/master/champ_bringup/launch/include/laser .-->
    <arg name="joint_controller_topic" default="joint_group_position_controller/command" /> <!-- Change to remap command topic for actuator controller (ROS control).  -->
    <arg name="hardware_connected"     default="false" /> <!-- Flag useful to launch hardware connected launch files. This auto disables publishing joint_states. -->

    <arg if="$(eval arg('robot_name') == '/')"  name="frame_prefix" value="" />
    <arg unless="$(eval arg('robot_name') == '/')" name="frame_prefix" value="$(arg robot_name)/" />

    <include file="$(find champ_bringup)/launch/bringup.launch">
        <arg name="robot_name"             value="$(arg robot_name)"/>
        <arg name="base_frame"             value="$(arg base_frame)"/>
        <arg name="joints_map_file"        value="$(arg joints_map_file)"/>
        <arg name="links_map_file"         value="$(arg links_map_file)"/>
        <arg name="gait_config_file"       value="$(arg gait_config_file)"/>
        <arg name="description_file"       value="$(arg description_file)"/>
        <arg name="has_imu"                value="$(arg has_imu)"/>
        <arg name="gazebo"                 value="$(arg gazebo)"/>
        <arg name="lite"                   value="$(arg lite)"/>
        <arg name="laser"                  value="$(arg laser)"/>
        <arg name="rviz"                   value="$(arg rviz)"/>
        <arg name="rviz_ref_frame"         value="$(arg frame_prefix)$(arg rviz_ref_frame)"/>
        <arg name="joint_controller_topic" value="$(arg joint_controller_topic)" />
        <arg name="hardware_connected"     value="$(arg hardware_connected)" />
        <arg name="publish_foot_contacts"  value="$(arg publish_foot_contacts)" />
        <arg name="publish_joint_control"  value="$(arg publish_joint_control)" />
        <arg name="close_loop_odom"        value="$(arg close_loop_odom)" />
    </include>

    <group if="$(arg hardware_connected)">
        <node pkg="tf2_ros" type="static_transform_publisher" name="base_link_to_laser" args="0 0 0 0 0 0 $(arg frame_prefix)base_link $(arg frame_prefix)laser" />
        <node pkg="tf2_ros" type="static_transform_publisher" name="base_link_to_imu"   args="0 0 0 0 0 0 $(arg frame_prefix)base_link $(arg frame_prefix)imu_link" />

        <!-- include your hardware launch file here -->

        <node pkg="hardware_interface" type="hardware_interface" name="hardware_interface" output="screen"/>
        <!-- <node pkg="joint_traj_example" type="joint_traj_example" name="joint_traj_echo" output="screen"/> -->
    </group> 
</launch>

I'm quite new to using ROS, any help would be greatly appreciated. Thanks!

minghaohsu410168 commented 1 year ago

I have the same issue!

TonyLiu836 commented 1 year ago

I finally got everything working. Turns out I was not setting the header for JointState message correctly. Changing it to the following worked for me.

joint_state.header.stamp = ros::Time::now();  
coheonsb commented 1 year ago

@TonyLiu836 Same issue.

What files do I need to edit?

TonyLiu836 commented 1 year ago

@coheonsb

I added the line of code in my comment above to my own hardware interface file.