forked from ouster-lidar/ouster-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update for fw 1.14-beta.10. See changelog for details
- Loading branch information
Showing
49 changed files
with
5,509 additions
and
3,384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,23 @@ | ||
# OS1 Example Client | ||
# Example Sensor Client | ||
|
||
## Contents | ||
* `ouster_client/` contains a simple C++ client for the OS1 sensor that | ||
prints lidar data to the terminal | ||
* `ouster_client/` contains a simple C++ client application that prints lidar | ||
data to the terminal | ||
* can be built both with and without ROS. See the instructions in | ||
[ouster_ros/](../ouster_ros/README.md) for building in a ROS environment | ||
|
||
## Building the Sample Client | ||
* The sample client requires a compiler supporting C++11 or newer and | ||
CMake | ||
* Build with `cd /path/to/ouster_example/ouster_client && mkdir build | ||
&& cd build && cmake .. && make` where `/path/to/ouster_example` is where you've cloned the repository | ||
* The sample client requires a compiler supporting C++11 or newer and CMake | ||
* Build with `cd /path/to/ouster_example/ouster_client && mkdir build && cd | ||
build && cmake .. && make` where `/path/to/ouster_example` is where you've | ||
cloned the repository | ||
|
||
## Running the Sample Client | ||
* Make sure the OS1 is connected to the network and has obtained a | ||
DHCP lease. See section 3.1 in the accompanying | ||
* Make sure the sensor is connected to the network and has obtained a DHCP | ||
lease. See section 3.1 in the accompanying | ||
[software user guide](https://www.ouster.io/downloads) for more details | ||
* An executable called `ouster_client_example` is generated in the build | ||
* An executable called `ouster_client_example` is generated in the build | ||
directory on success | ||
* Run `./ouster_client_example <os1_hostname> <udp_data_dest_ip>` where | ||
`<os1_hostname>` is the hostname or IP address of the OS1 sensor, | ||
and `<udp_data_dest_ip>` is the IP to which the sensor should send | ||
lidar data | ||
* Run `./ouster_client_example <sensor_hostname> <udp_data_dest_ip>` where | ||
`<sensor_hostname>` is the hostname or IP address of the sensor, and | ||
`<udp_data_dest_ip>` is the IP to which the sensor should send lidar data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/** | ||
* @file | ||
* @brief sample sensor client | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <memory> | ||
#include <string> | ||
|
||
#include "ouster/types.h" | ||
#include "ouster/version.h" | ||
|
||
namespace ouster { | ||
namespace sensor { | ||
|
||
struct client; | ||
|
||
enum client_state { | ||
TIMEOUT = 0, | ||
CLIENT_ERROR = 1, | ||
LIDAR_DATA = 2, | ||
IMU_DATA = 4, | ||
EXIT = 8 | ||
}; | ||
|
||
/** | ||
* Minimum supported version | ||
*/ | ||
const util::version min_version = {1, 12, 0}; | ||
|
||
/** | ||
* Listen for sensor data on the specified ports; do not configure the sensor | ||
* @param lidar_port port on which the sensor will send lidar data | ||
* @param imu_port port on which the sensor will send imu data | ||
* @return pointer owning the resources associated with the connection | ||
*/ | ||
std::shared_ptr<client> init_client(const std::string& hostname = "", | ||
int lidar_port = 7502, int imu_port = 7503); | ||
|
||
/** | ||
* Connect to and configure the sensor and start listening for data | ||
* @param hostname hostname or ip of the sensor | ||
* @param udp_dest_host hostname or ip where the sensor should send data | ||
* @param lidar_port port on which the sensor will send lidar data | ||
* @param imu_port port on which the sensor will send imu data | ||
* @param timeout_sec how long to wait for the sensor to initialize | ||
* @return pointer owning the resources associated with the connection | ||
*/ | ||
std::shared_ptr<client> init_client(const std::string& hostname, | ||
const std::string& udp_dest_host, | ||
lidar_mode mode = MODE_UNSPEC, | ||
timestamp_mode ts_mode = TIME_FROM_UNSPEC, | ||
int lidar_port = 0, int imu_port = 0, | ||
int timeout_sec = 30); | ||
|
||
/** | ||
* Block for up to timeout_sec until either data is ready or an error occurs | ||
* NOTE: will return immediately if LIDAR_DATA or IMU_DATA are set and not | ||
* cleared by read_lidar_data() and read_imu_data() before the next call | ||
* @param cli client returned by init_client associated with the connection | ||
* @param timeout_sec seconds to block while waiting for data | ||
* @return client_state s where (s & ERROR) is true if an error occured, (s & | ||
* LIDAR_DATA) is true if lidar data is ready to read, and (s & IMU_DATA) is | ||
* true if imu data is ready to read | ||
*/ | ||
client_state poll_client(const client& cli, int timeout_sec = 1); | ||
|
||
/** | ||
* Read lidar data from the sensor. Will not block | ||
* @param cli client returned by init_client associated with the connection | ||
* @param buf buffer to which to write lidar data. Must be at least | ||
* lidar_packet_bytes + 1 bytes | ||
* @return true if a lidar packet was successfully read | ||
*/ | ||
bool read_lidar_packet(const client& cli, uint8_t* buf, | ||
const packet_format& pf); | ||
|
||
/** | ||
* Read imu data from the sensor. Will not block | ||
* @param cli client returned by init_client associated with the connection | ||
* @param buf buffer to which to write imu data. Must be at least | ||
* imu_packet_bytes + 1 bytes | ||
* @return true if an imu packet was successfully read | ||
*/ | ||
bool read_imu_packet(const client& cli, uint8_t* buf, const packet_format& pf); | ||
|
||
/** | ||
* Get metadata text blob from the sensor. Attempt to fetch from the network if | ||
* not already populated | ||
* @param cli client returned by init_client associated with the connection | ||
* @param timeout_sec how long to wait for the sensor to initialize | ||
* @return a text blob of metadata parseable into a sensor_info struct | ||
*/ | ||
std::string get_metadata(client& cli, int timeout_sec = 30); | ||
|
||
} // namespace sensor | ||
} // namespace ouster |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.