Odom not published when using image_transport_plugins

asked 2023-03-15 04:51:34 -0500

praveen_khm gravatar image

updated 2023-03-15 05:03:17 -0500

Hi,

I am new to ROS and working on a four wheel robot driving on differential drive. I am able to visualize everything on Gazebo and display the same on Rviz2. After connecting camera xacro, I can visualize it under gazebo and Rviz2.

The issue starts when I try to install ros-foxy-image-transport-plugins. This plugin somehow messes up everything and Odom is not published. When I try to spawn the robot, it says Frame Odom does not exist. Also, transforms for wheels and camera joint throws an error as wheel not mapped to odom, camera not mapped to odom etc.

When I remove the plugin, everything works magically again. Can someone kindly check and help me on this please?

Setup: ROS 2 Foxy Running on Ubuntu 20.04

Gazebo : Classic Version

My Experience with ROS : 1 out of 10:)

camera.xacro

    <?xml version="1.0" ?>


    <robot xmlns:xacro="http://www.ros.org/wiki/xacro">

      <joint name="camera_joint" type="fixed">
        <parent link="chassis" />
        <child link="camera_link" />
        <origin xyz="0.14 0 0.045" rpy="0 0 0" />
      </joint>

  <link name="camera_link">
    <visual>
      <geometry>
        <box size="0.010 0.03 0.03"/>
      </geometry>
      <material name="red">
      </material>
    </visual>
  </link>

  <joint name="camera_optical_joint" type="fixed">
    <parent link="camera_link"/>
    <child link="camera_link_optical"/>
    <origin xyz="0.0 0.0 0.0" rpy="${-pi/2} 0.0 ${-pi/2}"/>
  </joint>

  <link name="camera_link_optical"></link>

    <gazebo reference="camera_link">
        <material>Gazebo/Red</material>
        <sensor name="camera" type="camera">
            <pose> 0 0 0 0 0 0 </pose>
            <visualize>true</visualize>
            <update_rate>10</update_rate>
              <camera>
                <horizontal_fov>1.809</horizontal_fov>
                <image>
                  <format>R8G8B8</format>
                  <width>640</width>
                  <height>480</height>
                </image>
                <clip>
                  <near>0.05</near>
                  <far>8.0</far>
                </clip>
              </camera>
            <plugin name="camera_controller" filename="libgazebo_ros_camera.so">
                <frame_name>camera_link_optical</frame_name>
            </plugin>
        </sensor>
    </gazebo>
</robot>

camera.launch.py

    import os

from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    return LaunchDescription([

        Node(
            package='v4l2_camera',
            executable='v4l2_camera_node',
            output='screen',
            parameters=[{
                'image_size': [640,480],
                'camera_frame_id': 'camera_link_optical'
                }]
    )
    ])

gazebo_control.xacro

    <?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">

  <gazebo>
    <plugin name='diff_drive' filename='libgazebo_ros_diff_drive.so'>
        <!-- WHEEL INFORMATION -->
        <num_wheel_pairs>2</num_wheel_pairs>

        <right_joint>front_right_joint</right_joint>
        <left_joint>front_left_joint</left_joint>
        <right_joint>back_right_joint</right_joint>
        <left_joint>back_left_joint</left_joint>    

        <wheel_separation>0.24</wheel_separation>   
        <wheel_separation>0.24</wheel_separation>   

        <wheel_diameter>0.13</wheel_diameter>
        <wheel_diameter>0.13</wheel_diameter>

        <!-- LIMITS -->
        <max_wheel_torque>200</max_wheel_torque>
        <max_wheel_acceleration>10.0</max_wheel_acceleration>

        <!-- OUTPUT -->
        <odometry_topic>odom</odometry_topic>
        <odometry_frame>odom</odometry_frame>
        <robot_base_frame>base_link</robot_base_frame>

        <publish_odom>true</publish_odom>
        <publish_odom_tf>true</publish_odom_tf>
        <publish_wheel_tf>true</publish_wheel_tf>
    </plugin>

    <plugin name="gazebo_ros_joint_state_publisher" filename="libgazebo_ros_joint_state_publisher.so">
      <updateRate>20</updateRate>
      <joint_name>front_right_joint</joint_name>
      <joint_name>front_left_joint</joint_name>
      <joint_name>back_right_joint</joint_name>
      <joint_name>back_left_joint</joint_name>
    </plugin>
  </gazebo>
</robot>
edit retag flag offensive close merge delete

Comments

anyone can help me here plz?

praveen_khm gravatar image praveen_khm  ( 2023-03-15 15:26:36 -0500 )edit