0
$\begingroup$

I have ROS2/Python/Gazebo project, and I use robot localization like this:

    robot_localization_node = Node(
        package='robot_localization',
        executable='ekf_node',
        name='ekf_filter_node',
        namespace='',
        output='screen',
        parameters=[ 
            os.path.join(def_bringup_dir, 'config', 'temp.yaml'),
            {'use_sim_time': use_sim_time }
        ],
    )   

I only have /odom and /imu in my yaml file.

Now, if I set use_sim_time to False, I can see filtered odometry messages. If set to True - no messages.

I have checked all other nodes, looks like they have use_sim_time set to True.

I understand that "something is wrong", but I would appreciate any suggestions in terms "where to look".

=========== Update

I think I was able to narrow it: /clock isn't being published.

Here is how I launch Gazebo:

gazebo_node = ExecuteProcess( cmd=['gazebo', '--verbose', world, '-s', 'libgazebo_ros_factory.so', '--use-sim-time'], output='screen')

Still no idea how to fix it. –

===== More Updates

Even more info, maybe someone can suggest:

gazebo_node = ExecuteProcess(
    cmd=['gazebo', '--verbose', world, '-s', 
        'libgazebo_ros_factory.so', '-r' '-sim-time'],
    output='screen')        
arrNodes.append(gazebo_node)

# ros2_node = ExecuteProcess(
#         cmd=['ros2', 'param', 'set', '/gazebo', 'use_sim_time', use_sim_time],
#         output='screen')
# arrNodes.append(ros2_node)

# Replaced by a single call below
# start_gazebo_server_cmd = ExecuteProcess(
#     cmd=['gzserver', '-s', 'libgazebo_ros_init.so', world, '-r' '-sim-time'],
#     cwd=[def_launch_dir], output='screen')
# arrNodes.append(start_gazebo_server_cmd)

If comments are switched, i.e. if I start client and server separately, /clock is published. Though, RViz doesn't receive robot position, and shows white outline, instead of a model.

I would definitely like to make first (combined) approach work, but not sure how to make it publish /clock

$\endgroup$
1
  • $\begingroup$ Updated above code with new info $\endgroup$ Sep 25, 2023 at 14:20

2 Answers 2

1
$\begingroup$

I think you need to start the ros gazebo bridge:

ros2 run ros_gz_bridge parameter_bridge /clock@rosgraph_msgs/msg/Clock[ignition.msgs.Clock

Depending on the Gazebo version, you might need to change ignition.msgs.Clock to gz.msgs.Clock in above command, due to the rename of 'Ignition Gazebo' to 'Gazebo Sim'.

https://index.ros.org/p/ros_gz_bridge/

$\endgroup$
5
  • $\begingroup$ I'll try, thank you. Yet, note that when I call client and server separately, /clock is published. Which means that maybe there is a direct approach, like some argument that I don't know about. $\endgroup$ Sep 25, 2023 at 18:34
  • $\begingroup$ BTW, I have Gazebo multi-robot simulator, version 11.11.0: does it use bridge? I thought it doesn't. $\endgroup$ Sep 25, 2023 at 18:39
  • $\begingroup$ And I use ROS2 Galactic. $\endgroup$ Sep 25, 2023 at 18:40
  • $\begingroup$ I mean, I think it should work without bridge - am I correct? $\endgroup$ Sep 25, 2023 at 18:52
  • $\begingroup$ I was referring to Gazebo Sim, i.e. "New Gazebo". Gazebo 11 is "Gazebo Classic". Not sure if it also needs the bridge... $\endgroup$
    – JRTG
    Sep 25, 2023 at 19:09
0
$\begingroup$

Funny error. In lidar, base frame was set to base_footprint, instead of base_link. No idea why it blocks publishing /clock, but...

The working project can be downloaded at robotics.snowcron.com

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.