urdf-модель (данные о глубине отображаются в Rviz не в том месте, а нефиксированный стык не публикуется) - PullRequest
0 голосов
/ 17 июня 2020

Я новичок в ROS и связанных вопросах. Я создаю URDF-модель моего желаемого робота с камерой глубины. У меня 2 вопроса:

  1. Робот правильно смоделирован в беседке, но когда я добавляю какой-нибудь интересующий объект в беседку, я обнаружил, что рамка датчика моей камеры неправильная, и направление взгляда - это ось z. робот. Я прочитал некоторую связанную проблему, но смог ее исправить.

  2. Я использую плагин для драйвера салазок, но мои колеса робота не опубликованы в rviz, когда я проверил модель робота или rqt_garph, я мог см. колеса.

Не могли бы вы мне помочь?

Это мой urdf:

<?xml version="1.0"?>
<robot name="bluebot" xmlns:xacro="http://ros.org/wiki/xacro">
    <!-- base information-->
    <xacro:property name="base_length" value="0.50" />
    <xacro:property name="base_width" value="0.40" />
    <xacro:property name="base_height" value="0.10" />
    <xacro:property name="base_mass" value="14" />

    <!-- wheel information-->
    <xacro:property name="wheel_length" value="0.08" />
    <xacro:property name="wheel_radius" value="0.10" />
    <xacro:property name="wheel_mass" value="4.70" />

    <!-- camera_stand information-->
    <xacro:property name="camera_stand_length" value="0.10" />
    <xacro:property name="camera_stand_radius" value="0.05" />
    <xacro:property name="camera_stand_mass" value="2.50" />

    <!-- camera information-->
    <xacro:property name="camera_length" value="0.15" />
    <xacro:property name="camera_width" value="0.03" />
    <xacro:property name="camera_height" value="0.02" />
    <xacro:property name="camera_mass" value="1" />

    <xacro:property name="Pi" value="3.1415" />

    <!--inertial-->
    <xacro:macro name="solid_cuboid_inertial"  params="length width height mass">
        <inertial>
        <origin rpy="0 0 0" xyz="0 0 0"/>
            <mass value="${mass}"/>
            <inertia
                ixx="${(mass / 12) * ((base_height * base_height) + (base_length * base_length))}" ixy="0.0" ixz="0.0"
                iyy="${(mass / 12) * ((base_width * base_width) + (base_length * base_length))}" iyz="0.0"
                izz="${(mass / 12) * ((base_width * base_width) + (base_height * base_height))}"/>
        </inertial>
    </xacro:macro>

    <xacro:macro name="cylinder_inertial"  params="mass radius height">
        <inertial>
        <origin rpy="0 0 0" xyz="0 0 0"/>
            <mass value="${mass}"/>
            <inertia
                ixx="${(mass / 12) * ((3 * (radius * radius)) + ( height * height))}" ixy="0.0" ixz="0.0"
                iyy="${(mass / 12) * ((3 * ( radius* radius)) + ( height * height))}" iyz="0.0"
                izz="${(mass / 12) * (radius * radius)}"/>
        </inertial>
    </xacro:macro>

    <!--base_link-->
    <link name="base_link">
        <visual>
            <origin rpy="0 0 0" xyz="0 0 ${base_height / 2}"/>
            <geometry>
                <box size="${base_length} ${base_width} ${base_height}"/>
            </geometry>
        </visual>
        <collision>
            <geometry>
                <box size="${base_length} ${base_width} ${base_height}"/>
            </geometry>
        </collision>
        <xacro:solid_cuboid_inertial length="${base_length}" width="${base_width}" height="${base_height}" mass="${base_mass}"/>
    </link>

    <gazebo reference="base_link">
        <material>Gazebo/Blue</material>
    </gazebo>

    <!--wheel-->
    <xacro:macro name="wheel" params="name reflect1 reflect2">

        <link name="${name}_wheel_link">
            <visual>
            <origin rpy="0 0 0" xyz="0 0 0"/>
                <geometry>
                    <cylinder length ="${wheel_length}" radius="${wheel_radius}"/>
                </geometry>
            </visual>
            <collision>
                <geometry>
                    <cylinder length="${wheel_length}" radius="${wheel_radius}"/>
                </geometry>
            </collision>
            <xacro:cylinder_inertial mass="${wheel_mass}" radius="${wheel_radius}" height="${wheel_length}" />
        </link>

        <gazebo reference="${name}_wheel_link">
            <material>Gazebo/Gray</material>
            <mu1 value="10.0"/>
            <mu2 value="20.0"/>
        </gazebo>


        <joint name="${name}_wheel_joint" type="continuous">
            <parent link="base_link"/>
            <child link="${name}_wheel_link"/>
            <origin rpy="${Pi / 2} 0 0" xyz="${reflect2 * ((base_width / 2) + (wheel_length / 2))} ${reflect1 * base_length / 2} 0"/>
            <axis xyz="0 0 -1"/>
        </joint>

        <transmission name="${name}_wheel_transmission">
            <type>transmission_interface/SimpleTransmission</type>
            <actuator name="${name}_wheel_motor">
                <mechanicalReduction>1</mechanicalReduction>
            </actuator>
            <joint name="${name}_wheel_joint">
                <!-- <hardwareInterface>VelocityJointInterface</hardwareInterface> -->
                <hardwareInterface>EffortJointInterface</hardwareInterface>
            </joint>
        </transmission>
    </xacro:macro>
    <xacro:wheel name="right_front" reflect1="1" reflect2="1" />
    <xacro:wheel name="left_front" reflect1="-1" reflect2="1" />
    <xacro:wheel name="right_back" reflect1="1" reflect2="-1" />
    <xacro:wheel name="left_back" reflect1="-1" reflect2="-1" />




    <!--camera_stand-->
    <link name="camera_stand_link">
        <visual>
            <origin rpy="0 0 0" xyz="0 0 0"/>
            <geometry>
                <cylinder length="${camera_stand_length}" radius="${camera_stand_radius}"/>
            </geometry>
        </visual>
        <collision>
            <geometry>
                <cylinder length="${camera_stand_length}" radius="${camera_stand_radius}"/>
            </geometry>
        </collision>
        <xacro:cylinder_inertial mass="${camera_stand_mass}" radius="${camera_stand_radius}" height="${camera_stand_length}" />
    </link>
    <gazebo reference="camera_stand_link">
        <material>Gazebo/Blue</material>
    </gazebo>
    <joint name="camera_stand_joint" type="fixed">
        <parent link="base_link"/>
        <child link="camera_stand_link"/>
        <origin rpy="0 0 0" xyz="${base_width / 2} 0 ${(base_length / 2) - 0.10}"/>
    </joint>

    <!--camera-->
    <link name="camera_link">
        <visual>
            <origin rpy="0 0 0" xyz="0 0 0"/>
            <geometry>
                <box size="${camera_length} ${camera_width} ${camera_height}"/>
            </geometry>
        </visual>
        <collision>
            <geometry>
                <box size="${camera_length} ${camera_width} ${camera_height}"/>
            </geometry>
        </collision>
        <xacro:solid_cuboid_inertial length="${camera_length}" width="${camera_width}" height="${camera_height}" mass="${camera_mass}"/>
    </link>
    <gazebo reference="camera_link">
        <material>Gazebo/Yellow</material>
    </gazebo>

    <joint name="camera_joint" type="fixed">
        <parent link="base_link"/>
        <child link="camera_link"/>
        <origin rpy="0 0 ${Pi / 2}" xyz="${base_width / 2} 0 ${base_length / 2}"/>
    </joint>


    <link name="camera_sensor_link"/>

    <joint name="camera_sensor_joint" type="fixed">
        <parent link="camera_link"/>
        <child link="camera_sensor_link"/>
        <origin rpy="${-3 * Pi/2} ${Pi/2} ${Pi/2}" xyz="0 0 0"/>
        <!-- <origin rpy="${3*Pi/2} 0 ${Pi}" xyz="0 0 0"/> -->
    </joint>

    <gazebo reference="camera_sensor_link">
        <sensor type="depth" name="xtion_pro">       
            <always_on>true</always_on>
            <visualize>true</visualize>             
            <camera>
                <horizontal_fov>1.047</horizontal_fov>
                <image>
                    <width>640</width>===
                    <height>480</height>
                    <format>R8G8B8</format>
                </image>
                <depth_camera>
                </depth_camera>
                <clip>
                    <near>0.1</near>
                    <far>10</far>
                </clip>
            </camera>
            <plugin name="camera_plugin" filename="libgazebo_ros_openni_kinect.so">
                <baseline>0.2</baseline>
                <alwaysOn>true</alwaysOn>
                <!-- Keep this zero, update_rate in the parent <sensor> tag
                    will control the frame rate. -->
                <updateRate>0.0</updateRate>
                <cameraName>camera_ir</cameraName>
                <imageTopicName>/camera/color/image_raw</imageTopicName>
                <cameraInfoTopicName>/camera/color/camera_info</cameraInfoTopicName>
                <depthImageTopicName>/camera/depth/image_raw</depthImageTopicName>
                <depthImageCameraInfoTopicName>/camera/depth/camera_info</depthImageCameraInfoTopicName>
                <pointCloudTopicName>/camera/depth/points</pointCloudTopicName>
                <frameName>camera_sensor_link</frameName>
                <pointCloudCutoff>0.5</pointCloudCutoff>
                <pointCloudCutoffMax>3.0</pointCloudCutoffMax>
                <distortionK1>0</distortionK1>
                <distortionK2>0</distortionK2>
                <distortionK3>0</distortionK3>
                <distortionT1>0</distortionT1>
                <distortionT2>0</distortionT2>
                <CxPrime>0</CxPrime>
                <Cx>0</Cx>
                <Cy>0</Cy>
                <focalLength>0</focalLength>
                <hackBaseline>0</hackBaseline>
            </plugin>
        </sensor>
    </gazebo>

    <gazebo>
        <plugin name="skid_steer_drive_controller" filename="libgazebo_ros_skid_steer_drive.so">
            <updateRate>100.0</updateRate>
            <robotNamespace>/</robotNamespace>
            <leftFrontJoint>left_front_wheel_joint</leftFrontJoint>
            <rightFrontJoint>right_front_wheel_joint</rightFrontJoint>
            <leftRearJoint>left_back_wheel_joint</leftRearJoint>
            <rightRearJoint>right_back_wheel_joint</rightRearJoint>
            <wheelSeparation>0.4</wheelSeparation>
            <wheelDiameter>${wheel_radius * 2}</wheelDiameter>
            <robotBaseFrame>base_link</robotBaseFrame>
            <torque>20</torque>
            <topicName>cmd_vel</topicName>
            <broadcastTF>false</broadcastTF>
        </plugin>
    </gazebo>

    <gazebo>
        <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
        <robotNamespace>/</robotNamespace>
        </plugin>
    </gazebo>
</robot>

и это мой файл запуска :

  <?xml version="1.0"?>
  <launch>

    <!-- these are the arguments you can pass this launch file, for example paused:=true -->
    <arg name="paused" default="false"/>
    <arg name="use_sim_time" default="true"/>
    <arg name="extra_gazebo_args" default=""/>
    <arg name="gui" default="true"/>
    <arg name="recording" default="false"/>
    <!-- Note that 'headless' is currently non-functional.  See gazebo_ros_pkgs issue #491 (-r arg does not disable
        rendering, but instead enables recording). The arg definition has been left here to prevent breaking downstream
        launch files, but it does nothing. -->
    <arg name="headless" default="false"/>
    <arg name="debug" default="false"/>
    <arg name="physics" default="ode"/>
    <arg name="verbose" default="false"/>
    <arg name="output" default="screen"/>
    <arg name="world_name" default="empty.world"/> <!-- Note: the world_name is with respect to GAZEBO_RESOURCE_PATH environmental variable -->
    <arg name="respawn_gazebo" default="false"/>
    <arg name="use_clock_frequency" default="false"/>
    <arg name="pub_clock_frequency" default="100"/>
    <arg name="enable_ros_network" default="true" />

    <!-- set use_sim_time flag -->
    <param name="/use_sim_time" value="$(arg use_sim_time)"/>

    <!-- set command arguments -->
    <arg unless="$(arg paused)" name="command_arg1" value=""/>
    <arg     if="$(arg paused)" name="command_arg1" value="-u"/>
    <arg unless="$(arg recording)" name="command_arg2" value=""/>
    <arg     if="$(arg recording)" name="command_arg2" value="-r"/>
    <arg unless="$(arg verbose)" name="command_arg3" value=""/>
    <arg     if="$(arg verbose)" name="command_arg3" value="--verbose"/>
    <arg unless="$(arg debug)" name="script_type" value="gzserver"/>
    <arg     if="$(arg debug)" name="script_type" value="debug"/>

    <!-- start gazebo server-->
    <group if="$(arg use_clock_frequency)">
      <param name="gazebo/pub_clock_frequency" value="$(arg pub_clock_frequency)" />
    </group>
    <group>
      <param name="gazebo/enable_ros_network" value="$(arg enable_ros_network)" />
    </group>
    <node name="gazebo" pkg="gazebo_ros" type="$(arg script_type)" respawn="$(arg respawn_gazebo)" output="$(arg output)"
    args="$(arg command_arg1) $(arg command_arg2) $(arg command_arg3) -e $(arg physics) $(arg extra_gazebo_args) $(find bluebot)/worlds/$(arg world_name)" />

    <!-- start gazebo client -->
    <group if="$(arg gui)">
      <node name="gazebo_gui" pkg="gazebo_ros" type="gzclient" respawn="false" output="$(arg output)" args="$(arg command_arg3)"/>
    </group>

    <!-- Convert an xacro and put on parameter server -->
    <param name="robot_description" command="xacro $(find bluebot)/urdf/bluebot.xacro" />

  <!-- Spawn a robot into Gazebo -->
    <node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-param robot_description -urdf -model bluebot" />

    <!-- <node name="joint_state_publisher" type="joint_state_publisher" pkg="joint_state_publisher" output="screen"/> -->

  <!-- load the controllers -->
    <!-- <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
      output="screen" ns="/" args="left_front_wheel_joint_position_controller right_front_wheel_joint_position_controller 
      left_back_wheel_joint_position_controller right_back_wheel_joint_position_controller joint_state_controller"/> -->

    <!-- convert joint states to TF transforms for rviz, etc -->
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"
      respawn="false" output="screen">
      <remap from="/joint_states" to="/bluebot/joint_states" />
    </node>
  </launch>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...