ROS Image Msgs callback faster with gazebo running on the background

asked 2020-10-15 07:53:58 -0500

dogukan_altay gravatar image

updated 2022-08-28 10:56:14 -0500

lucasw gravatar image

Hello,

I have 2 nodes works at the same time. One node captures image via opencv VideoCapture and the other node subscribes the first node to fetch the images and do deep learning inference. If I start the nodes and Gazebo with roslaunch everything seems to working fine. However, if I start the nodes via rosrun and start the roscore from a different terminal the image callback in deep learning node is starting to slow down drastically. Below you can find the specifications for the nodes and the dummy roslaunch Im using. Thanks for the help.

Video Capture Node: - Video FPS: 30FPS - Publisher Queue Size: 1 ( To prevent caching) - Ros Rate: 30hz

Deep Learning Node: - Deep Learning Inference: 80hz - Subscriber Queue Size: 1 (To prevent caching) - Ros Rate: 30hz

Example Roslaunch Script:

<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="world_name" default="$(find gazebo_plugins)/world/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="screen"
args="$(arg command_arg1) $(arg command_arg2) $(arg command_arg3) -e $(arg physics) $(arg extra_gazebo_args) $(arg world_name)" />

<!-- start gazebo client -->
<group if="$(arg gui)">
<node name="gazebo_gui" pkg="gazebo_ros" type="gzclient" respawn="false" output="screen" args="$(arg command_arg3)"/>
</group>
<!--     Start the PTZ Camera Controller -->
<rosparam command="load" file="$(find <pkg_id>)/config/config_template.yaml" param=""/>
<node pkg="<pkg_id>" name="camera_stream_handler" type="camera_stream_handler" output="screen"/>-->
<node pkg="<pkg_id>" name="dl" type="dl.py" output="screen"/>

</launch>

edit retag flag offensive close merge delete