Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add azimuth window config support #366

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ouster_client/include/ouster/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ std::shared_ptr<client> init_client(const std::string& hostname = "",
* @param hostname hostname or ip of the sensor
* @param udp_dest_host hostname or ip where the sensor should send data
* or "" for automatic detection of destination
* @param azimuth_window azimuth window the sensor will send back the 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
Expand All @@ -54,7 +55,8 @@ std::shared_ptr<client> init_client(const std::string& hostname,
lidar_mode mode = MODE_UNSPEC,
timestamp_mode ts_mode = TIME_FROM_UNSPEC,
int lidar_port = 0, int imu_port = 0,
int timeout_sec = 60);
int timeout_sec = 60,
AzimuthWindow azimuth_window = {0, 360000});

/**
* Block for up to timeout_sec until either data is ready or an error occurs.
Expand Down
8 changes: 8 additions & 0 deletions ouster_client/include/ouster/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@ std::string to_string(NMEABaudRate rate);
*/
optional<NMEABaudRate> nmea_baud_rate_of_string(const std::string& s);

/**
* Get azimuth window from string.
*
* @param string
* @return azimuth window corresponding to the string, or 0 on error
*/
optional<AzimuthWindow> azimuth_window_of_string(const std::string& s);

/**
* Get string representation of an Azimuth Window
*
Expand Down
10 changes: 9 additions & 1 deletion ouster_client/src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,8 @@ std::shared_ptr<client> init_client(const std::string& hostname,
const std::string& udp_dest_host,
lidar_mode mode, timestamp_mode ts_mode,
int lidar_port, int imu_port,
int timeout_sec) {
int timeout_sec,
AzimuthWindow azimuth_window) {
auto cli = init_client(hostname, lidar_port, imu_port);
if (!cli) return std::shared_ptr<client>();

Expand Down Expand Up @@ -518,6 +519,13 @@ std::shared_ptr<client> init_client(const std::string& hostname,
success &= res == "set_config_param";
}

// Setup Azimuth Window
success &= do_tcp_cmd(
sock_fd,
{"set_config_param", "azimuth_window", to_string(azimuth_window)},
res);
success &= res == "set_config_param";

// wake up from STANDBY, if necessary
success &=
do_tcp_cmd(sock_fd, {"set_config_param", "auto_start_flag", "1"}, res);
Expand Down
7 changes: 7 additions & 0 deletions ouster_client/src/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,13 @@ optional<NMEABaudRate> nmea_baud_rate_of_string(const std::string& s) {
return rlookup(impl::nmea_baud_rate_strings, s.c_str());
}

optional<AzimuthWindow> azimuth_window_of_string(const std::string& s)
{
AzimuthWindow p;
int res = sscanf(s.c_str(),"[%i,%i]",&p.first,&p.second);
return res == 2 ? make_optional<AzimuthWindow>(p) : nullopt;
}

std::string to_string(AzimuthWindow azimuth_window) {
std::stringstream ss;
ss << "[" << azimuth_window.first << ", " << azimuth_window.second << "]";
Expand Down