discover_lidar module¶
- class discover_lidar.Lidar(callback=None, convert=False, subscribe=True)¶
Bases:
Config
A class for using the RPLidar A2. This is a two-dimensional lidar that provides 360-degree range-finding capabilities. It operates at an 8k sampling frequency, with a 12 meter scan range and 10 Hz rotational speed.
Methods
get_info
()A method which gives the user info about the configuration of the lidar.
A method which returns the latest LaserScan message object.
A method which lets the user know if the lidar is available on the rover.
set_callback
(func)A function that sets the callback function to be called whenever new scans from the Lidar are available.
A method which starts recording data from the lidar to a rosbag.
A method which stops recording data from the lidar to a rosbag.
A function allowing the user to subscribe to the scan topic at a time other than object instantiation.
- get_info()¶
A method which gives the user info about the configuration of the lidar. Items like scan rate, and scan distance are included.
- Parameters:
- None
- Returns:
- str
A string containing information about the lidar.
Examples
>>> from rover_api.discover_lidar import Lidar >>> scanner = Lidar() >>> info = scanner.get_info()
- get_latest_scan()¶
A method which returns the latest LaserScan message object.
- Parameters:
- None
- Returns:
- LaserScan
The latest LaserScan message object in the scan buffer.
Examples
>>> from rover_api.discover_lidar import Lidar >>> from sensor_msgs.msg import LaserScan >>> scanner = Lidar() >>> sscan = scanner1.get_latest_scan()
- is_available()¶
A method which lets the user know if the lidar is available on the rover.
- Parameters:
- None
- Returns:
- bool
A boolean value specifying if the lidar is available for the user.
Examples autosummary_generate setting.
- /home/cjb873/Discover/RoverAPI/rover_api/src/rover_api/discover_camera.py:docstring of discover_camera.Camera:22: WARNING: autosummary: stub file not found ‘discover_camera.Camera.get_jpg’. Check your autosummary_generate setting.
>>> from rover_api.discover_lidar import Lidar >>> scanner = Lidar(subscribe=False) >>> if scanner.is_available(): >>> scanner.subscribe_to_scan_topic()
- set_callback(func)¶
A function that sets the callback function to be called whenever new scans from the Lidar are available. The new callback function will not be called unless subscribe is set to True, or subscribe_to_scan_topic() has been called.
- Parameters:
- funcfunction
The new callback function
- Returns:
- None
Examples
>>> from rover_api.discover_lidar import Lidar >>> def cb_func(): >>> print("New scan published") >>> >>> scanner = Lidar(callback=None, subscribe=False) >>> scanner.set_callback(cb_func) >>> scanner.subscribe_to_scan_topic()
- start_recording()¶
A method which starts recording data from the lidar to a rosbag. The bag is named /experiment/<time_at_start>_scan.bag.
- Parameters:
- None
- Returns:
- None
Examples
>>> from rover_api.discover_lidar import Lidar >>> scanner = Lidar() >>> scanner.start_recording()
- stop_recording()¶
A method which stops recording data from the lidar to a rosbag. If convert was set to true in the constructor, the rosbag is converted to a pointcloud.
- Parameters:
- None
- Returns:
- None
Examples
>>> from rover_api.discover_lidar import Lidar >>> from time import sleep >>> scanner = Lidar() >>> scanner.start_recording() >>> sleep(3) >>> scanner.stop_recording()
- subscribe_to_scan_topic()¶
A function allowing the user to subscribe to the scan topic at a time other than object instantiation.
- Parameters:
- None
- Returns:
- None
Examples
>>> from rover_api.discover_lidar import Lidar >>> scanner = Lidar(subscribe=False) >>> scanner.subscribe_to_scan_topic()