SyrianSpock / realsense_gazebo_plugin

Intel RealSense R200 Gazebo ROS plugin and model
93 stars 78 forks source link

Attach camera to robot model #56

Open diebengay opened 4 years ago

diebengay commented 4 years ago

Hello! I have a robot model in gazebo. How can I attach the camera instance to my robot using urdf? I have tried it copying the content of _realsenseurdf.launch:

<param
    name="robot_description"
    command="$(find xacro)/xacro '$(find realsense_gazebo_plugin)/urdf/rs200_simulation.xacro'"
/>
<node
    name="spawn_model"
    pkg="gazebo_ros"
    type="spawn_model"
    args="-urdf -param robot_description -model rs200"
/>
<node name="state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"/>

in the simulation.launch of my project where I spawn the robot, and I created the camera instance too in the model.xacro of the robot:

<!-- Import macro for realsense-RS200 camera-->
<xacro:include filename="$(find realsense_gazebo_plugin)/urdf/realsense-RS200.macro.xacro"/>
<!-- Create camera instance -->
<xacro:realsense-rs200 prefix="" parent="base_link">
    <origin xyz="0 0 1.0" rpy="0 0 0" />   
</xacro:realsense-rs200>

but it doesn't link to the robot and spawns in a separated model called rs200. If I replace the rs200 in this line

args="-urdf -param robot_description -model rs200"

by the name of my robot model, the camera appears but the robot not.

iqedgarmg commented 4 years ago

I had the same issue, and I solved it by modifying the line of the launch file:

command="$(find xacro)/xacro '$(find realsense_gazebo_plugin)/urdf/rs200_simulation.xacro'"

to my robot model (with the camera instance):

command="$(find xacro)/xacro '$(find my_package)/urdf/my_model.xacro'"

And everything works fine.