正常使用小乌龟控制节点控制机器人运动的备份示例代码

<launch>
<set_env name="GZ_SIM_RESOURCE_PATH" value="$(find-pkg-share gazebo_pkg)/etc/"/>
<group>
<let name="robot_description" value="$(command 'xacro $(find-pkg-share gazebo_pkg)/urdf/total.xacro')"/>
<node pkg="rviz2" exec="rviz2" name="rviz2" output="screen" args="-d $(find-pkg-share gazebo_pkg)/etc/empty1.rviz"/>
<!--rviz2 need this node below-->
<node pkg="robot_state_publisher" exec="robot_state_publisher" name="robot_state_publisher">
    <param name="robot_description" value="$(var robot_description)"/>
</node>
<node name="joint_state_publisher" exec="joint_state_publisher" pkg="joint_state_publisher"/>
<include file="$(find-pkg-share ros_gz_sim)/launch/gz_sim.launch.py">
    <arg name="ign_args" value="default.sdf"/>
</include>
<node pkg="ros_gz_sim" exec="create" args="-world default -topic /robot_description"> 
</node> 
<node pkg="ros_gz_bridge" exec="parameter_bridge" name="bridge1" args="turtle1/cmd_vel@geometry_msgs/msg/Twist@ignition.msgs.Twist">
</node>
<!--
<node pkg="ros_gz_bridge" exec="parameter_bridge" name="bridge2" args="/radar_sensor100@sensor_msgs/msg/LaserScan@ignition.msgs.LaserScan"/>
-->
</group>
</launch>
<robot name="move" xmlns:xacro="http://wiki.ros.org/wiki/xacro">
    <xacro:macro name="joint_trans" params="joint_name">
        <transmission name="${joint_name}_trans">
            <type>transmission_interface/SimpleTransmission</type>
            <joint name="${joint_name}">
                <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
            </joint>
            <actuator name="${joint_name}_motor">
                <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
                <mechanicalReduction>1</mechanicalReduction>
            </actuator>
        </transmission>
    </xacro:macro>
    <xacro:joint_trans joint_name="left_wheel2base" />
    <xacro:joint_trans joint_name="right_wheel2base" />
    <gazebo>
        <plugin
            filename="libignition-gazebo-diff-drive-system.so"
            name="ignition::gazebo::systems::DiffDrive">
            <left_joint>left_wheel2base</left_joint>
            <right_joint>right_wheel2base</right_joint> 
            <wheel_separation>${base_radius * 2}</wheel_separation> 
            <wheel_radius>${wheel_radius}</wheel_radius> 
            <odom_publish_frequency>1</odom_publish_frequency>
            <topic>turtle1/cmd_vel</topic>
        </plugin>
    </gazebo>
</robot>

/                        ///                                /        ///                                        //        //        //

<launch>
<set_env name="GZ_SIM_RESOURCE_PATH" value="$(find-pkg-share gazebo_pkg)/etc/"/>
<group>
<let name="robot_description" value="$(command 'xacro $(find-pkg-share gazebo_pkg)/urdf/total.xacro')"/>
<node pkg="rviz2" exec="rviz2" name="rviz2" output="screen" args="-d $(find-pkg-share gazebo_pkg)/etc/empty1.rviz"/>
<!--rviz2 need this node below-->
<node pkg="robot_state_publisher" exec="robot_state_publisher" name="robot_state_publisher">
    <param name="robot_description" value="$(var robot_description)"/>
</node>
<node name="joint_state_publisher" exec="joint_state_publisher" pkg="joint_state_publisher"/>
<include file="$(find-pkg-share ros_gz_sim)/launch/gz_sim.launch.py">
    <arg name="ign_args" value="default.sdf"/>
</include>
<node pkg="ros_gz_sim" exec="create" args="-world default -topic /robot_description"> 
</node> 
<node pkg="ros_gz_bridge" exec="parameter_bridge" name="bridge1" args="/turtle1/cmd_vel@geometry_msgs/msg/Twist@ignition.msgs.Twist">
</node><!--there must not be a '/' in upper line eg:/turtle1/cmd_vel is wrong-->
<!--
<node pkg="ros_gz_bridge" exec="parameter_bridge" name="bridge2" args="radar_sensor100@sensor_msgs/msg/LaserScan@ignition.msgs.LaserScan"/>
-->
</group>
</launch>
<robot name="move" xmlns:xacro="http://wiki.ros.org/wiki/xacro">
    <xacro:macro name="joint_trans" params="joint_name">
        <transmission name="${joint_name}_trans">
            <type>transmission_interface/SimpleTransmission</type>
            <joint name="${joint_name}">
                <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
            </joint>
            <actuator name="${joint_name}_motor">
                <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
                <mechanicalReduction>1</mechanicalReduction>
            </actuator>
        </transmission>
    </xacro:macro>
    <xacro:joint_trans joint_name="left_wheel2base" />
    <xacro:joint_trans joint_name="right_wheel2base" />
    <gazebo>
        <plugin
            filename="libignition-gazebo-diff-drive-system.so"
            name="ignition::gazebo::systems::DiffDrive">
            <left_joint>left_wheel2base</left_joint>
            <right_joint>right_wheel2base</right_joint> 
            <wheel_separation>${base_radius * 2}</wheel_separation> 
            <wheel_radius>${wheel_radius}</wheel_radius> 
            <odom_publish_frequency>1</odom_publish_frequency>
            <topic>/turtle1/cmd_vel</topic>
        </plugin>
    </gazebo>
</robot>

这2代码都可以正常运行,但是我搞不懂,为什么乌龟控制主题只有一个,接收控制的节点为什么可以是2个?一个是turtle1/cmd_vel

还有一个事/turtle1/cmd_vel呢难道解析的时候从第一个不是符号/的地方开始吗,如果这样//turtle1/cmd_vel也是合法的试试看

 

相关推荐

  1. C#与雷赛运动控制使用(二) - 轴控制系统

    2024-01-10 09:18:04       49 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-10 09:18:04       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-10 09:18:04       106 阅读
  3. 在Django里面运行非项目文件

    2024-01-10 09:18:04       87 阅读
  4. Python语言-面向对象

    2024-01-10 09:18:04       96 阅读

热门阅读

  1. php中的继承和接口

    2024-01-10 09:18:04       56 阅读
  2. Hive的时间处理函数from_unixtime和unix_timestamp

    2024-01-10 09:18:04       60 阅读
  3. 能源互联网:照亮我们绿色、智能的未来

    2024-01-10 09:18:04       64 阅读
  4. 【Leetcode】251.展开二维向量

    2024-01-10 09:18:04       50 阅读
  5. Unity两组Toggle一一对应关系

    2024-01-10 09:18:04       55 阅读
  6. Agisoft Metashape 地面点分类参数设置

    2024-01-10 09:18:04       62 阅读