Class HesaiHwInterface

Nested Relationships

Nested Types

Class Documentation

class HesaiHwInterface

Hardware interface of hesai driver.

Public Functions

explicit HesaiHwInterface(const std::shared_ptr<loggers::Logger> &logger)

Constructor.

~HesaiHwInterface()

Destructor.

Status initialize_tcp_driver()

Initializing tcp_driver for TCP communication.

Parameters:

setup_sensor – Whether to also initialize tcp_driver for sensor configuration

Returns:

Resulting status

Status finalize_tcp_driver()

Closes the TcpDriver and related resources.

Returns:

Status result

boost::property_tree::ptree parse_json(const std::string &str)

Parsing json string to property_tree.

Parameters:

str – JSON string

Returns:

Parsed property_tree

void receive_sensor_packet_callback(const std::vector<uint8_t> &buffer, const connections::UdpSocket::RxMetadata &metadata)

Callback function to receive the Cloud Packet data from the UDP Driver.

Parameters:

buffer – Buffer containing the data received from the UDP socket

Status sensor_interface_start()

Starting the interface that handles UDP streams.

Returns:

Resulting status

Status sensor_interface_stop()

Function for stopping the interface that handles UDP streams.

Returns:

Resulting status

Status get_sensor_configuration(const SensorConfigurationBase &sensor_configuration)

Printing sensor configuration.

Parameters:

sensor_configuration – SensorConfiguration for this interface

Returns:

Resulting status

Status get_calibration_configuration(CalibrationConfigurationBase &calibration_configuration)

Printing calibration configuration.

Parameters:

calibration_configuration – CalibrationConfiguration for the checking

Returns:

Resulting status

Status set_sensor_configuration(std::shared_ptr<const SensorConfigurationBase> sensor_configuration)

Setting sensor configuration.

Parameters:

sensor_configuration – SensorConfiguration for this interface

Returns:

Resulting status

Status register_scan_callback(connections::UdpSocket::callback_t scan_callback)

Registering callback for PandarScan.

Parameters:

scan_callback – Callback function

Returns:

Resulting status

std::string get_lidar_calibration_string()

Getting data with PTC_COMMAND_GET_LIDAR_CALIBRATION.

Returns:

Resulting status

std::vector<uint8_t> get_lidar_calibration_bytes()

Getting data with PTC_COMMAND_GET_LIDAR_CALIBRATION.

Returns:

Resulting status

HesaiPtpDiagStatus get_ptp_diag_status()

Getting data with PTC_COMMAND_PTP_DIAGNOSTICS (PTP STATUS)

Returns:

Resulting status

PtpTlvPortDataSet get_ptp_diag_port()

Getting data with PTC_COMMAND_PTP_DIAGNOSTICS (PTP TLV PORT_DATA_SET)

Returns:

Resulting status

PtpTlvTimeStatusNp get_ptp_diag_time()

Getting data with PTC_COMMAND_PTP_DIAGNOSTICS (PTP TLV TIME_STATUS_NP)

Returns:

Resulting status

HesaiPtpTlvGrandmasterSettingsNp get_ptp_diag_grandmaster()

Getting data with PTC_COMMAND_PTP_DIAGNOSTICS (PTP TLV GRANDMASTER_SETTINGS_NP)

Returns:

Resulting status

std::shared_ptr<HesaiInventoryBase> get_inventory()

Getting data with PTC_COMMAND_GET_INVENTORY_INFO.

Returns:

Resulting status

std::shared_ptr<HesaiConfigBase> get_config()

Getting data with PTC_COMMAND_GET_CONFIG_INFO.

Returns:

Resulting status

std::shared_ptr<HesaiLidarStatusBase> get_lidar_status()

Getting data with PTC_COMMAND_GET_LIDAR_STATUS.

Returns:

Resulting status

Status set_spin_rate(uint16_t rpm)

Setting value with PTC_COMMAND_SET_SPIN_RATE.

Parameters:

rpm – Spin rate

Returns:

Resulting status

Status set_sync_angle(int sync_angle, int angle)

Setting value with PTC_COMMAND_SET_SYNC_ANGLE.

Parameters:
  • sync_angle – Sync angle enable flag

  • angle – Angle value

Returns:

Resulting status

Status set_trigger_method(int trigger_method)

Setting mode with PTC_COMMAND_SET_TRIGGER_METHOD.

Parameters:

trigger_method – Trigger method

Returns:

Resulting status

Status set_standby_mode(int standby_mode)

Setting mode with PTC_COMMAND_SET_STANDBY_MODE.

Parameters:

standby_mode – Standby mode

Returns:

Resulting status

Status set_return_mode(int return_mode)

Setting mode with PTC_COMMAND_SET_RETURN_MODE.

Parameters:

return_mode – Return mode

Returns:

Resulting status

Status set_destination_ip(int dest_ip_1, int dest_ip_2, int dest_ip_3, int dest_ip_4, int port, int gps_port)

Setting IP with PTC_COMMAND_SET_DESTINATION_IP.

Parameters:
  • dest_ip_1 – The 1st byte represents the 1st section

  • dest_ip_2 – The 2nd byte represents the 2nd section

  • dest_ip_3 – The 3rd byte represents the 3rd section

  • dest_ip_4 – The 4th byte represents the 4th section

  • port – LiDAR Destination Port

  • gps_port – GPS Destination Port

Returns:

Resulting status

Status set_control_port(int ip_1, int ip_2, int ip_3, int ip_4, int mask_1, int mask_2, int mask_3, int mask_4, int gateway_1, int gateway_2, int gateway_3, int gateway_4, int vlan_flg, int vlan_id)

Setting IP with PTC_COMMAND_SET_CONTROL_PORT.

Parameters:
  • ip_1 – Device IP of the 1st byte represents the 1st section

  • ip_2 – Device IP of the 2nd byte represents the 2nd section

  • ip_3 – Device IP of the 3rd byte represents the 3rd section

  • ip_4 – Device IP of the 4th byte represents the 4th section

  • mask_1 – Device subnet mask of the 1st byte represents the 1st section

  • mask_2 – Device subnet mask of the 2nd byte represents the 2nd section

  • mask_3 – Device subnet mask of the 3rd byte represents the 3rd section

  • mask_4 – Device subnet mask of the 4th byte represents the 4th section

  • gateway_1 – Device gateway of the 1st byte represents the 1st section

  • gateway_2 – Device gateway of the 2nd byte represents the 2nd section

  • gateway_3 – Device gateway of the 3rd byte represents the 3rd section

  • gateway_4 – Device gateway of the 4th byte represents the 4th section

  • vlan_flg – VLAN Status

  • vlan_id – VLAN ID

Returns:

Resulting status

Status set_lidar_range(int method, std::vector<unsigned char> data)

Setting values with PTC_COMMAND_SET_LIDAR_RANGE.

Parameters:
  • method – Method

  • data – Set data

Returns:

Resulting status

Status set_lidar_range(int start, int end)

Setting values with PTC_COMMAND_SET_LIDAR_RANGE.

Parameters:
  • start – Start angle

  • end – End angle

Returns:

Resulting status

HesaiLidarRangeAll get_lidar_range()

Getting values with PTC_COMMAND_GET_LIDAR_RANGE.

Returns:

Resulting status

Status set_high_resolution_mode(bool enable)

Setting values with PTC_COMMAND_SET_HIGH_RESOLUTION_MODE.

Returns:

Resulting status

bool get_high_resolution_mode()

Getting values with PTC_COMMAND_GET_HIGH_RESOLUTION_MODE.

Returns:

Resulting status

Status set_up_close_blockage_detection(bool enable)

Setting values with PTC_COMMAND_SET_UP_CLOSE_BLOCKAGE_DETECTION.

Parameters:

enable – Enable up close blockage detection

Returns:

Resulting status

bool get_up_close_blockage_detection()

Getting values with PTC_COMMAND_GET_UP_CLOSE_BLOCKAGE_DETECTION.

Returns:

Resulting status

Status check_and_set_lidar_range(const HesaiCalibrationConfigurationBase &calibration)

Given the HW interface’s sensor configuration and a given calibration, set the sensor FoV (min and max angles) with appropriate padding around the FoV set in the configuration. This compensates for the points lost due to the sensor filtering FoV by raw encoder angle.

Parameters:

calibration – The calibration file of the sensor

Returns:

Status Resulting status of setting the FoV

Status set_clock_source(int clock_source)
Status set_ptp_config(int profile, int domain, int network, int switch_type, int logAnnounceInterval = 1, int logSyncInterval = 1, int logMinDelayReqInterval = 0)

Setting values with PTC_COMMAND_SET_PTP_CONFIG.

Parameters:
  • profile – IEEE timing and synchronization standard

  • domain – Domain attribute of the local clock

  • network – Network transport type of 1588v2

  • switch_type – Switch type of 802.1AS Automotive

  • logAnnounceInterval – Time interval between Announce messages, in units of log seconds (default: 1)

  • logSyncInterval – Time interval between Sync messages, in units of log seconds (default: 1)

  • logMinDelayReqInterval – Minimum permitted mean time between Delay_Req messages, in units of log seconds (default: 0)

Returns:

Resulting status

std::shared_ptr<HesaiPtpConfigBase> get_ptp_config()

Getting data with PTC_COMMAND_GET_PTP_CONFIG.

Returns:

Resulting status

Status set_ptp_lock_offset(uint8_t lock_offset)
uint8_t get_ptp_lock_offset()
Status send_reset()

Sending command with PTC_COMMAND_RESET.

Returns:

Resulting status

Status set_rot_dir(int mode)

Setting values with PTC_COMMAND_SET_ROTATE_DIRECTION.

Parameters:

mode – Rotation of the motor

Returns:

Resulting status

HesaiLidarMonitor get_lidar_monitor()

Getting data with PTC_COMMAND_LIDAR_MONITOR.

Returns:

Resulting status

void io_context_run()

Call run() of IO Context.

std::shared_ptr<boost::asio::io_context> get_io_context()

GetIO Context.

Returns:

IO Context

HesaiStatus set_spin_speed_async_http(std::shared_ptr<boost::asio::io_context> ctx, uint16_t rpm)

Setting spin_speed via HTTP API.

Parameters:
  • ctx – IO Context used

  • rpm – spin_speed (300, 600, 1200)

Returns:

Resulting status

HesaiStatus set_spin_speed_async_http(uint16_t rpm)

Setting spin_speed via HTTP API.

Parameters:

rpm – spin_speed (300, 600, 1200)

Returns:

Resulting status

HesaiStatus set_ptp_config_sync_http(std::shared_ptr<boost::asio::io_context> ctx, int profile, int domain, int network, int logAnnounceInterval, int logSyncInterval, int logMinDelayReqInterval)
HesaiStatus set_ptp_config_sync_http(int profile, int domain, int network, int logAnnounceInterval, int logSyncInterval, int logMinDelayReqInterval)
HesaiStatus set_sync_angle_sync_http(std::shared_ptr<boost::asio::io_context> ctx, int enable, int angle)
HesaiStatus set_sync_angle_sync_http(int enable, int angle)
HesaiStatus get_lidar_monitor_async_http(std::shared_ptr<boost::asio::io_context> ctx, std::function<void(const std::string &str)> str_callback)

Getting lidar_monitor via HTTP API.

Parameters:
  • ctx – IO Context

  • str_callback – Callback function for received string

Returns:

Resulting status

HesaiStatus get_lidar_monitor_async_http(std::function<void(const std::string &str)> str_callback)

Getting lidar_monitor via HTTP API.

Parameters:

str_callback – Callback function for received string

Returns:

Resulting status

HesaiStatus check_and_set_config(std::shared_ptr<const HesaiSensorConfiguration> sensor_configuration, std::shared_ptr<HesaiConfigBase> hesai_config)

Checking the current settings and changing the difference point.

Parameters:
  • sensor_configuration – Current SensorConfiguration

  • hesai_config – Current HesaiConfig

Returns:

Resulting status

HesaiStatus check_and_set_config(std::shared_ptr<const HesaiSensorConfiguration> sensor_configuration, HesaiLidarRangeAll hesai_lidar_range_all)

Checking the current settings and changing the difference point.

Parameters:
  • sensor_configuration – Current SensorConfiguration

  • hesai_lidar_range_all – Current HesaiLidarRangeAll

Returns:

Resulting status

HesaiStatus check_and_set_config()

Checking the current settings and changing the difference point.

Returns:

Resulting status

void set_target_model(int model)

Set target model number (for proper use of HTTP and TCP according to the support of the target model)

Parameters:

model – Model number

void set_target_model(nebula::drivers::SensorModel model)

Set target model number (for proper use of HTTP and TCP according to the support of the target model)

Parameters:

model – Model

bool use_http_set_spin_rate() const

Whether to use HTTP for setting SpinRate.

Returns:

Use HTTP

bool use_http_get_lidar_monitor() const

Whether to use HTTP for getting LidarMonitor.

Returns:

Use HTTP

Public Static Functions

static int nebula_model_to_hesai_model_no(nebula::drivers::SensorModel model)

Convert to model in Hesai protocol from nebula::drivers::SensorModel.

Parameters:

model

Returns:

static bool use_http_set_spin_rate(int model)

Whether to use HTTP for setting SpinRate.

Parameters:

model – Model number

Returns:

Use HTTP

static bool use_http_get_lidar_monitor(int model)

Whether to use HTTP for getting LidarMonitor.

Parameters:

model – Model number

Returns:

Use HTTP