Skip to content
This repository was archived by the owner on Dec 13, 2025. It is now read-only.
This repository was archived by the owner on Dec 13, 2025. It is now read-only.

Cannot get LaserScanStamped range values #35

@pirobot

Description

@pirobot

I am using the develop branch and I'm trying to get the range values from a laser scanner sensor in Gazebo 2.3. The laser is defined in my model SDF using the libgazebo_ros_laser.so plugin and the scan appears fine in the Gazebo GUI as well as in the Topic Visualization.

When I run the following code, the range array always appears empty (prints out as []) whereas I expected to see the actual ranges. The header and scan fields of the message print fine so I know the callback is receiving the messages.

Here now is the code:

import trollius
from trollius import From

import pygazebo
import pygazebo.msg.laserscan_stamped_pb2

@trollius.coroutine
def publish_loop():
    manager = yield From(pygazebo.connect()) 

    def callback_lidar(data):
        message = pygazebo.msg.laserscan_stamped_pb2.LaserScanStamped.FromString(data)
        print message.scan.ranges

    subscriber = manager.subscribe('/gazebo/default/person_walking_lidar/lidar_link/laser/scan',
                     'gazebo.msgs.LaserScanStamped',
                     callback_lidar)

    yield From(subscriber.wait_for_connection())
    while(True):
        yield From(trollius.sleep(0.1))
        print('wait...')
    print(dir(manager))

import logging

logging.basicConfig()

loop = trollius.get_event_loop()
loop.run_until_complete(publish_loop())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions