So, basically...I learned that ROS2 foxy does not support SDF with plugins and ROS2. So, I had to re-update one for URDF instead of SDF. I made SDF enitrely from Gazebo11.
So, the question is why can't I put wheels on the box? Take a look at this URDF code:
<?xml version="1.0"?>
<robot name="my_robot" xmlns:xacro="http://ros.org/wiki/xacro">
<!-- Define robot constants -->
<xacro:property name="base_width" value="0.2159"/>
<xacro:property name="base_length" value="0.1524"/>
<xacro:property name="base_height" value="0.10795"/>
<xacro:property name="wheel_radius" value="0.0325"/>
<xacro:property name="wheel_width" value="0.02"/>
<xacro:property name="wheel_ygap" value="0.088"/>
<xacro:property name="wheel_zoff" value="0.05"/>
<xacro:property name="wheel_xoff" value="0.1"/>
<xacro:property name="caster_xoff" value="0.14"/>
<!-- Robot Base -->
<link name="base_link">
<visual>
<geometry>
<box size="0.2159 0.1524 0.10795"/>
</geometry>
<material name="Cyan">
<color rgba="0 1.0 1.0 1.0"/>
</material>
</visual>
</link>
<!-- Robot Footprint -->
<link name="base_footprint"/>
<joint name="base_joint" type="fixed">
<parent link="base_link"/>
<child link="base_footprint"/>
<origin xyz="0.0 0.0 ${-(wheel_radius+wheel_zoff)}" rpy="0 0 0"/>
</joint>
<!-- Wheels -->
<xacro:macro name="wheel" params="prefix x_reflect y_reflect">
<link name="${prefix}_link">
<visual>
<origin xyz="0 0 0" rpy="${pi/2} 0 0"/>
<geometry>
<cylinder radius="${wheel_radius}" length="${wheel_width}"/>
</geometry>
<material name="Gray">
<color rgba="0.5 0.5 0.5 1.0"/>
</material>
</visual>
</link>
<joint name="${prefix}_joint" type="continuous">
<parent link="base_link"/>
<child link="${prefix}_link"/>
<origin xyz="${x_reflect*wheel_xoff} ${y_reflect*(base_width/6+wheel_ygap)} ${-wheel_zoff}" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
</joint>
</xacro:macro>
<xacro:wheel prefix="drivewhl_rl" x_reflect="-1" y_reflect="1" />
<xacro:wheel prefix="drivewhl_rr" x_reflect="-1" y_reflect="-1" />
<xacro:wheel prefix="drivewhl_fl" x_reflect="1" y_reflect="1" />
<xacro:wheel prefix="drivewhl_fr" x_reflect="1" y_reflect="-1" />
</robot>
The model look like this
As for my SDF code and picture like this:
<link name='chassis'>
<pose>0 0 .1 0 0 0</pose>
<inertial>
<inertia>
<ixx>1.000000</ixx>
<ixy>0.000000</ixy>
<ixz>0.000000</ixz>
<iyy>1.000000</iyy>
<iyz>0.000000</iyz>
<izz>1.000000</izz>
</inertia>
<mass>1</mass>
</inertial>
<collision name='collision'>
<geometry>
<box>
<size>0.2159 0.1524 0.10795</size>
</box>
</geometry>
</collision>
<visual name='visual'>
<geometry>
<box>
<size>0.2159 0.1524 0.10795</size>
</box>
</geometry>
</visual>
</link>
<link name="front_left_wheel">
<pose>0.1 0.088 0.05 0 1.5707 1.5707</pose>
<mass>0.75</mass>
<collision name="collision">
<geometry>
<cylinder>
<radius>0.0325</radius>
<length>.02</length>
</cylinder>
</geometry>
</collision>
<visual name="visual">
<geometry>
<cylinder>
<radius>0.0325</radius>
<length>.02</length>
</cylinder>
</geometry>
<surface>
<friction>
<ode>
<mu>10</mu>
<mu2>10</mu2>
<slip1>0.000000</slip1>
<slip2>0.000000</slip2>
</ode>
</friction>
</surface>
</visual>
</link>
<link name="front_right_wheel">
<pose>0.1 -0.088 0.05 0 1.5707 1.5707</pose>
<mass>0.75</mass>
<collision name="collision">
<geometry>
<cylinder>
<radius>0.0325</radius>
<length>.02</length>
</cylinder>
</geometry>
</collision>
<visual name="visual">
<geometry>
<cylinder>
<radius>0.0325</radius>
<length>.02</length>
</cylinder>
</geometry>
<surface>
<friction>
<ode>
<mu>10</mu>
<mu2>10</mu2>
<slip1>0.000000</slip1>
<slip2>0.000000</slip2>
</ode>
</friction>
</surface>
</visual>
</link>
<link name="rear_right_wheel">
<pose>-0.1 -0.088 0.05 0 1.5707 1.5707</pose>
<mass>0.75</mass>
<collision name="collision">
<geometry>
<cylinder>
<radius>0.0325</radius>
<length>.02</length>
</cylinder>
</geometry>
<surface>
<friction>
<ode>
<mu>10</mu>
<mu2>10</mu2>
<slip1>0.000000</slip1>
<slip2>0.000000</slip2>
</ode>
</friction>
</surface>
</collision>
<visual name="visual">
<geometry>
<cylinder>
<radius>0.0325</radius>
<length>.02</length>
</cylinder>
</geometry>
</visual>
</link>
<link name="rear_left_wheel">
<pose>-0.1 0.088 0.05 0 1.5707 1.5707</pose>
<mass>0.75</mass>
<collision name="collision">
<geometry>
<cylinder>
<radius>0.0325</radius>
<length>.02</length>
</cylinder>
</geometry>
<surface>
<friction>
<ode>
<mu>10</mu>
<mu2>10</mu2>
<slip1>0.000000</slip1>
<slip2>0.000000</slip2>
</ode>
</friction>
</surface>
</collision>
<visual name="visual">
<geometry>
<cylinder>
<radius>0.0325</radius>
<length>.02</length>
</cylinder>
</geometry>
</visual>
</link>
The model looks like this
I ran it in rviz using UDFR and the error says
bwuk@robots:~/my_robot$ ros2 launch my_robot_description display.launch.py
[INFO] [launch]: All log files can be found below /home/bwuk/.ros/log/2021-08-13-13-13-16-752823-robots-533156
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [joint_state_publisher_gui-1]: process started with pid [533159]
[INFO] [robot_state_publisher-2]: process started with pid [533161]
[INFO] [rviz2-3]: process started with pid [533163]
[robot_state_publisher-2] Parsing robot urdf xml string.
[robot_state_publisher-2] Link base_footprint had 0 children
[robot_state_publisher-2] Link drivewhl_fl_link had 0 children
[robot_state_publisher-2] Link drivewhl_fr_link had 0 children
[robot_state_publisher-2] Link drivewhl_rl_link had 0 children
[robot_state_publisher-2] Link drivewhl_rr_link had 0 children
[robot_state_publisher-2] [INFO] [1628881997.684661614] [robot_state_publisher]: got segment base_footprint
[robot_state_publisher-2] [INFO] [1628881997.684822903] [robot_state_publisher]: got segment base_link
[robot_state_publisher-2] [INFO] [1628881997.684846357] [robot_state_publisher]: got segment drivewhl_fl_link
[robot_state_publisher-2] [INFO] [1628881997.684861905] [robot_state_publisher]: got segment drivewhl_fr_link
[robot_state_publisher-2] [INFO] [1628881997.684876402] [robot_state_publisher]: got segment drivewhl_rl_link
[robot_state_publisher-2] [INFO] [1628881997.684889159] [robot_state_publisher]: got segment drivewhl_rr_link
[rviz2-3] [INFO] [1628881998.195248946] [rviz2]: Stereo is NOT SUPPORTED
[rviz2-3] [INFO] [1628881998.195549872] [rviz2]: OpenGl version: 4.6 (GLSL 4.6)
[rviz2-3] [INFO] [1628881998.232085561] [rviz2]: Stereo is NOT SUPPORTED
[rviz2-3] Parsing robot urdf xml string.
[rviz2-3] Warning: Invalid frame ID "drivewhl_fl_link" passed to canTransform argument source_frame - frame does not exist
[rviz2-3] at line 133 in /home/bwuk/ros2_foxy/src/ros2/geometry2/tf2/src/buffer_core.cpp
[rviz2-3] Warning: Invalid frame ID "drivewhl_fr_link" passed to canTransform argument source_frame - frame does not exist
[rviz2-3] at line 133 in /home/bwuk/ros2_foxy/src/ros2/geometry2/tf2/src/buffer_core.cpp
[rviz2-3] Warning: Invalid frame ID "drivewhl_rl_link" passed to canTransform argument source_frame - frame does not exist
[rviz2-3] at line 133 in /home/bwuk/ros2_foxy/src/ros2/geometry2/tf2/src/buffer_core.cpp
[rviz2-3] Warning: Invalid frame ID "drivewhl_rr_link" passed to canTransform argument source_frame - frame does not exist
[rviz2-3] at line 133 in /home/bwuk/ros2_foxy/src/ros2/geometry2/tf2/src/buffer_core.cpp
[rviz2-3] Warning: Invalid frame ID "drivewhl_fl_link" passed to canTransform argument source_frame - frame does not exist
[rviz2-3] at line 133 in /home/bwuk/ros2_foxy/src/ros2/geometry2/tf2/src/buffer_core.cpp
[rviz2-3] Warning: Invalid frame ID "drivewhl_fr_link" passed to canTransform argument source_frame - frame does not exist
[rviz2-3] at line 133 in /home/bwuk/ros2_foxy/src/ros2/geometry2/tf2/src/buffer_core.cpp
[rviz2-3] Warning: Invalid frame ID "drivewhl_rl_link" passed to canTransform argument source_frame - frame does not exist
[rviz2-3] at line 133 in /home/bwuk/ros2_foxy/src/ros2/geometry2/tf2/src/buffer_core.cpp
[rviz2-3] Warning: Invalid frame ID "drivewhl_rr_link" passed to canTransform argument source_frame - frame does not exist
[rviz2-3] at line 133 in /home/bwuk/ros2_foxy/src/ros2/geometry2/tf2/src/buffer_core.cpp
[rviz2-3] Warning: Invalid frame ID "drivewhl_fl_link" passed to canTransform argument source_frame - frame does not exist
[rviz2-3] at line 133 in /home/bwuk/ros2_foxy/src/ros2/geometry2/tf2/src/buffer_core.cpp
The question is why can't it attach to the chassis(body or base) even if the SDF can attach them easily?
P.S. If you happen to know how to control one wheel for one plugin (forward or backward), please let me know the plugin!
Originally posted by kak13 on ROS Answers with karma: 113 on 2021-08-13
Post score: 0