sdformat_urdf icon indicating copy to clipboard operation
sdformat_urdf copied to clipboard

how to assign sensor in sdf so that this converter can understand and work correctly

Open TZECHIN6 opened this issue 11 months ago • 1 comments

I am struggling how to assign a camera_link and camera_optical_link in the sdf file. From this document, it suggest to only use sdf for easy maintenance, and I found this package to take sdf and convert to urdf.

But in the readme of this package, it said the should be included inside ... so how should be included in the sdf and maintain a correct relation with robot, say base_link

Looking for anyone could help me clearing the concept.

<?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.305 0 0.08" rpy="0 0 0"/>
    </joint>

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


    <joint name="camera_optical_joint" type="fixed">
        <parent link="camera_link"/>
        <child link="camera_link_optical"/>
        <origin xyz="0 0 0" rpy="${-pi/2} 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.089</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>

Actually I want to know how about urdf file can be written in sdf format. The plugin part can be skipped.

TZECHIN6 avatar Jan 15 '25 07:01 TZECHIN6

Push! Anyone has idea how to work on this? should I put the sensor tag outside the link tag? I dont mind sharing my sdf to anyone would like to help on this. Thanks so much. I would like to keep only one sdf file instead of creating a urdf that duplicate the sdf.

TZECHIN6 avatar Jan 28 '25 07:01 TZECHIN6

You probably have figured it out by now but for anyone coming across this issue in the future, the sensor should be nested inside the link as in "regular" sdf. This approach might raise a warning like [WARN] [1749037370.899454319] [sdformat_urdf]: SDFormat link [link] has a <sensor>, but URDF does not support this but the model is still spawned correctly. If you take a look at the test files inside this repository (the imu example specifically), the developers have also used this approach.

elmeripk avatar Jun 04 '25 11:06 elmeripk

Thanks for answering the question @elmeripk ! I'll close this as answered.

Here's the link to the test file with the IMU:

https://github.com/ros/sdformat_urdf/blob/9cbd5153f48fb192f394f5bb32bb8ee16e6263b1/sdformat_test_files/models/link_sensor_imu/link_sensor_imu.sdf#L30-L31

sloretz avatar Jun 04 '25 16:06 sloretz

Yes and thanks. I have just ignored the warning for right now.

TZECHIN6 avatar Jun 05 '25 01:06 TZECHIN6