Class SensorHttp

Class Documentation

class SensorHttp

An interface to communicate with Ouster sensors via http requests.

Public Functions

virtual ~SensorHttp() = default

Deconstruct the sensor http interface.

inline const ouster::sdk::core::Version &firmware_version() const

Returns the cached sensor FW version retrieved on construction.

Returns:

returns the sensor FW version

inline const std::string &hostname() const

Returns the hostname for the associated sensor.

Returns:

returns the sensor FW version

inline bool is_vlp() const

Returns if the sensor is a VLP variant.

Returns:

returns if it is a VLP variant

virtual std::string metadata(int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Queries the sensor metadata.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

Returns:

returns a json string of the sensor metadata.

virtual std::string sensor_info(int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Queries the sensor_info.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

Returns:

returns a json string representing the sensor_info.

virtual std::string get_config_params(bool active, int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Queries active/staged configuration on the sensor.

Parameters:
  • active[in] – if true retrieve active, otherwise get staged configs.

  • timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

Returns:

a string representing the active or staged config

virtual void set_config_param(const std::string &key, const std::string &value, int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Set the value of a specfic configuration on the sensor, the changed configuration is not active until the sensor is restarted.

Parameters:
  • key[in] – name of the config to change.

  • value[in] – the new value to set for the selected configuration.

  • timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

virtual std::string active_config_params(int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Retrieves the active configuration on the sensor.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

Returns:

json string of active configuration parameters set on the sensor

virtual std::string staged_config_params(int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Retrieves the staged configuration on the sensor.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

Returns:

json string of staged configuration parameters set on the sensor

virtual void set_udp_dest_auto(int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Enables automatic assignment of udp destination ports.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

virtual std::string beam_intrinsics(int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Retrieves beam intrinsics of the sensor.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

Returns:

json string of beam_intrinsics retrieved from sensor

virtual std::string imu_intrinsics(int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Retrieves imu intrinsics of the sensor.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

Returns:

json string of imu_intrinsics received from sensor

virtual std::string lidar_intrinsics(int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Retrieves lidar intrinsics of the sensor.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

Returns:

json string of lidar_intrinsics retrieved from sensor

virtual std::string lidar_data_format(int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Retrieves lidar data format.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

Returns:

json string of lidar_data_format received from sensor

virtual std::string calibration_status(int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Gets the calibaration status of the sensor.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

Returns:

json string ofcalibration status received from sensor

virtual void reinitialize(int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Reinitializes the sensor applying all staged configurations.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

virtual void restart(int timeout_sec = LONG_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Restarts the sensor applying the persisted configuration.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

virtual void save_config_params(int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Persist active configuration parameters to the sensor.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

virtual std::string get_user_data(int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Gets the user data stored on the sensor.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if this endpoint is not supported on the FW, if an HTTP error occurs, or if timeout occurs.

Returns:

user data retrieved from sensor

virtual UserDataAndPolicy get_user_data_and_policy(int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Gets the user data stored on the sensor and the retention policy.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if this endpoint is not supported on the FW, if an HTTP error occurs, or if timeout occurs.

Returns:

user data and policy setting retrieved from the sensor

virtual void set_user_data(const std::string &data, bool keep_on_config_delete = true, int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Sets the user data stored on the sensor.

Parameters:
  • data[in] – Value of userdata to set on the sensor.

  • keep_on_config_delete[in] – If true, keep the userdata when configuration is deleted from the sensor

  • timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if this endpoint is not supported on the FW, if an HTTP error occurs, or if timeout occurs.

virtual std::string network(int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Gets sensor IP address information.

Parameters:

timeout_sec[in] – The timeout to use in seconds for the version request, this argument is optional.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

Returns:

a JSON string containing sensor IP address information.

virtual std::string auto_detected_udp_dest(int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS, nonstd::optional<std::string> original_destination = {}) const = 0

Gets the automatic destination address as detected by the sensor.

Parameters:
  • timeout_sec[in] – The timeout to use in seconds for the version request, this argument is optional.

  • original_destination[in] – Destination to restore to the sensor after. Otherwise pulled from the sensor.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

Returns:

autodetected address

virtual void set_static_ip(const std::string &ip_address, int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Set’s the sensor’s static IP address and subnet mask.

Parameters:
  • ip_address[in] – The static IP to set on the sensor in CIDR form

  • timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if this endpoint is not supported on the FW, if an HTTP error occurs, or if timeout occurs.

virtual void set_static_ip(const std::string &ip_address, const std::string &gateway_address, int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Set’s the sensor’s static IP address, subnet mask and gateway address.

Parameters:
  • ip_address[in] – The static IP to set on the sensor in CIDR form.

  • gateway_address[in] – The gateway IP to set on the sensor.

  • timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if this endpoint is not supported on the FW, if an HTTP error occurs, or if timeout occurs.

virtual void delete_static_ip(int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Deletes any static IP address stored on the sensor.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if this endpoint is not supported on the FW, if an HTTP error occurs, or if timeout occurs.

virtual void delete_user_data(int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Deletes the user data stored on the sensor.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if this endpoint is not supported on the FW, if an HTTP error occurs, or if timeout occurs.

virtual std::vector<uint8_t> diagnostics_dump(int timeout_sec = LONG_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Downloads diagnostics data in zip format from the sensor.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if an HTTP error occurs, or if timeout occurs.

Returns:

diagnostics dump file contents

virtual std::vector<uint8_t> get_zone_monitor_config_zip(bool staged = false, int timeout_sec = LONG_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Downloads zone monitor config in zip format from the sensor.

Parameters:
  • staged[in] – if true, downloads from staged config instead of active

  • timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

Returns:

zone monitor config zip archive as a binary blob

virtual void set_zone_monitor_config_zip(const std::vector<uint8_t> &zip_archive, int timeout_sec = LONG_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Sets a zip of zone monitor config to the sensor.

Parameters:
  • zip_archive[in] – blob of zip archive to send to sensor

  • timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

virtual void delete_zone_monitor_staged_config(int timeout_sec = LONG_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Deletes the staged zone monitor configuration on the sensor.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if this endpoint is not supported on the FW, if an HTTP error occurs, or if timeout occurs.

virtual std::vector<uint8_t> get_zone_monitor_live_ids(int timeout_sec = LONG_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Get the live zones for a sensor.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if this endpoint is not supported on the FW, if an HTTP error occurs, or if timeout occurs.

Returns:

A vector ids of the active zones.

virtual void set_zone_monitor_live_ids(const std::vector<uint8_t> &zone_ids, int timeout_sec = LONG_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Sets the live zones for a sensor.

(All zones whose ids are not present in the vector will be made not live.)

Parameters:
  • zone_ids[in] – A vector of the zones to set to live.

  • timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if this endpoint is not supported on the FW, if an HTTP error occurs, or if timeout occurs.

virtual void apply_zone_monitor_staged_config_to_active(int timeout_sec = LONG_HTTP_REQUEST_TIMEOUT_SECONDS) const = 0

Applies the staged zone monitor configuration to active on the sensor.

Parameters:

timeout_sec[in] – The timeout for the request in seconds.

Throws:

std::runtime_error – if this endpoint is not supported on the FW, if an HTTP error occurs, or if timeout occurs.

Public Static Functions

static std::string firmware_version_string(const std::string &hostname, int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS)

Retrieves sensor firmware version information as a string.

Parameters:
  • hostname[in] – hostname of the sensor to communicate with.

  • timeout_sec[in] – The timeout to use in seconds for the version request, this argument is optional.

Throws:

std::runtime_error – if an HTTP error occurs, or if timeout occurs.

Returns:

firmware version string from sensor

static ouster::sdk::core::Version firmware_version(const std::string &hostname, int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS)

Retrieves sensor firmware version information.

Parameters:
  • hostname[in] – hostname of the sensor to communicate with.

  • timeout_sec[in] – The timeout to use in seconds for the version request, this argument is optional.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

Returns:

parsed firmware version from sensor

static std::unique_ptr<SensorHttp> create(const std::string &hostname, int timeout_sec = SHORT_HTTP_REQUEST_TIMEOUT_SECONDS)

Creates an instance of the SensorHttp interface.

Parameters:
  • hostname[in] – hostname of the sensor to communicate with.

  • timeout_sec[in] – The timeout to use in seconds for the version request, this argument is optional.

Throws:

std::runtime_error – if an HTTP error occurs or if timeout occurs.

Returns:

a version specific implementation of the SensorHTTP instance