ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

How to integrate a Realsense d435 camera to an existing drone?

asked 2022-05-27 06:41:08 -0600

naisor gravatar image

updated 2022-05-30 05:56:06 -0600

I am currently using Hector_Quadrotor and i am trying to simulate my drone as well as the d435 camera found in Realsense github. I am new to Ros and i can't seem to find a way to integrate it on my simulation. I can add the d435 camera model but on rviz, there are no links to the camera features (such as the RGB image, Depth image, point cloud etc)

It shows something like this : For frame [camera_d435_color_optical_frame]: Frame [camera_d435_color_optical_frame] does not exist

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2022-05-30 06:20:31 -0600

Joe28965 gravatar image

updated 2022-05-31 02:23:33 -0600

What do you mean by "I added the camera model". Do you mean you cloned and build it?

You will need to include the URDF in your hector drone and then call the macro in your hector drone urdf somewhere.

You can see an example of how it's done here.

Mind you, I'm going through the urdf from the macro and I'm not seeing the actual Gazebo parts. So I'm not sure that realsense_ros actually has a simulation component.

EDIT based on your comment:

Ah, I see, I was looking at the default branch. In that case, if you look at the d435 urdf, you will see that it calls the Gazebo plugin file that you linked. In other words, you need to call _d435.urdf.xacro and it will call _d435.gazebo.xacro for you.

Which is also what that launch file you linked does. The line that calls the model. And if you check the model you will see that it calls sensor_d435, not gazebo_d435.

EDIT 2:

So I took a look at that sensor_d435 macro and I noticed something.

All the links that you're missing (everything after camera_link) is due to a (honestly kinda weird) setting. The parameter use_nominal_extrinsics. There is an if statement that doesn't include the camera_depth_optical_frame and all the others if set to false.

Guess what the default value is set to? False.

So you need to change your macro to:

<xacro:sensor_d435 name="camera" parent="base_link" use_nominal_extrinsics="true">
    <origin xyz="0.1 0.0 -0.03" rpy="0 0 0"/>
</xacro:sensor_d435>

The weird thing is, they set it to true themselves in the launch file, so why they set it to false by default (or why it even exists to be honest) I do not understand.

edit flag offensive delete link more

Comments

I've found this this xacro . If i load it with this launch file it works.

But when i try to implement it in hector, it does not work correctly (rather, i cannot make it work).Maybe you could help with that?

naisor gravatar image naisor  ( 2022-05-30 07:08:34 -0600 )edit

So this is my launch file:

<launch>
  <include file="$(find hector_gazebo_worlds)/launch/world.launch"/>

  <!-- Spawn the hector_drone -->
  <include file="$(find hector_quadrotor_gazebo)/launch/spawn_quadrotor.launch" >
    <arg name="model" value="$(find hector_quadrotor_description)/urdf/hector_with_d435.gazebo.xacro"/>

<!-- Start rviz visualization with preset config -->
  <node pkg="rviz" type="rviz" name="rviz" args="-d $(find hector_quadrotor_demo)/rviz_cfg/d435.rviz"/>
   </launch>

So inside the hector_with_d435.gazebo.xacro i called the _d435.urdf.xacro as you said:

<xacro:include filename="$(find realsense2_description)/urdf/_d435.urdf.xacro" />
 <xacro:sensor_d435 name="camera" parent="base_link">
      <origin xyz="0.1 0.0 -0.03" rpy="0 0 0"/>
    </xacro:sensor_d435>

It launches the world with hector and the camera, but there is nothing on the sensors. It shows this error:

naisor gravatar image naisor  ( 2022-05-30 08:04:32 -0600 )edit

For frame [camera_depth_optical_frame]: Frame [camera_depth_optical_frame] does not exist. And the same for the rest of the topics

naisor gravatar image naisor  ( 2022-05-30 08:05:04 -0600 )edit

I definitely would expect it to work. Just so we're on the same page, could you either clarify what you mean by "It shows this error:" What is "it" in this regard? Also what do you mean with "the same for the rest of the topics?"

As for your launch file, the only thing I can imagine is that you don't actually close your <include>. Although to be honest it's been too long since I've worked with ROS1 so I'm not sure if it's necessary. Could you add </include> after your arg just for my peace of mind?

Joe28965 gravatar image Joe28965  ( 2022-05-30 08:25:23 -0600 )edit

Unfortunately the include isnt the problem.

When i open rviz and go to Image topics such as Depth , Rbg and the Point cloud, it shows there is no connected frame.

Also, when i execute the command rosrun rqt_tf tree rqt_tf tree, after the camera_link nothing appears. So the urdf just places the csmera there but nothing from the actual sensors.

naisor gravatar image naisor  ( 2022-05-30 12:28:18 -0600 )edit

Could you edit your original question to add a screenshot of RViz and a screenshot of rqt_tf? Then I can look at it tomorrow, you should have enough karma to add images.

Joe28965 gravatar image Joe28965  ( 2022-05-30 12:35:40 -0600 )edit

I was just about to output the rqt_tf_tree as you asked but your solution worked! Thank you so much for this Joe!!!

naisor gravatar image naisor  ( 2022-05-31 03:45:37 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2022-05-27 06:41:08 -0600

Seen: 1,627 times

Last updated: May 31 '22