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

Support setting start angle and direction #16

Open
wants to merge 1 commit 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
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,17 @@ class HttpCommandInterface

//! Request TCP handle
//! @param start_angle Set start angle for scans in the range [0,3600000] (1/10000°)
//! @param max_points Set maximum points per scan (receive partial scans to reduce data rate)
//! @returns A valid HandleInfo on success, an empty boost::optional<HandleInfo> container otherwise
boost::optional<HandleInfo> requestHandleTCP(int start_angle=-1800000);
boost::optional<HandleInfo> requestHandleTCP(int start_angle=-1800000, int max_points=0);

//! Request UDP handle
//! @param port Set UDP port where scanner data should be sent to
//! @param hostname Optional: Set hostname/IP where scanner data should be sent to, local IP is determined automatically if not specified
//! @param start_angle Optional: Set start angle for scans in the range [0,3600000] (1/10000°), defaults to -1800000
//! @param max_points Optional: Set maximum points per scan (receive partial scans to reduce data rate)
//! @returns A valid HandleInfo on success, an empty boost::optional<HandleInfo> container otherwise
boost::optional<HandleInfo> requestHandleUDP(int port, std::string hostname = std::string(""), int start_angle=-1800000);
boost::optional<HandleInfo> requestHandleUDP(int port, std::string hostname = std::string(""), int start_angle=-1800000, int max_points=0);

//! Release handle
bool releaseHandle( const std::string& handle );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ class R2000Driver

//! Start capturing laserdata: Requests a handle and begin retrieving data from the scanner
//! @returns True in case of success, False otherwise
bool startCapturingTCP();
bool startCapturingTCP(int start_angle=-1800000, int max_points=0);

//! Start capturing laserdata: Requests a handle and begin retrieving data from the scanner
//! @returns True in case of success, False otherwise
bool startCapturingUDP();
bool startCapturingUDP(int start_angle=-1800000, int max_points=0);

//! Stop capturing laserdata: Release handle and stop retrieving data from the scanner
//! @returns True in case of success, False otherwise
Expand Down
8 changes: 6 additions & 2 deletions pepperl_fuchs_r2000/src/driver/http_command_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,14 @@ std::vector< std::string > HttpCommandInterface::getParameterList()
}

//-----------------------------------------------------------------------------
boost::optional<HandleInfo> HttpCommandInterface::requestHandleTCP(int start_angle)
boost::optional<HandleInfo> HttpCommandInterface::requestHandleTCP(int start_angle, int max_points)
{
// Prepare HTTP request
std::map< std::string, std::string > params;
params["packet_type"] = "C";
params["start_angle"] = std::to_string(start_angle);
if( max_points > 0 )
params["max_num_points_scan"] = std::to_string(max_points);

// Request handle via HTTP/JSON request/response
if( !sendHttpCommand("request_handle_tcp", params) || !checkErrorCode() )
Expand All @@ -306,7 +308,7 @@ boost::optional<HandleInfo> HttpCommandInterface::requestHandleTCP(int start_ang
}

//-----------------------------------------------------------------------------
boost::optional<HandleInfo> HttpCommandInterface::requestHandleUDP(int port, std::string hostname, int start_angle)
boost::optional<HandleInfo> HttpCommandInterface::requestHandleUDP(int port, std::string hostname, int start_angle, int max_points)
{
// Prepare HTTP request
if( hostname == "" )
Expand All @@ -316,6 +318,8 @@ boost::optional<HandleInfo> HttpCommandInterface::requestHandleUDP(int port, std
params["start_angle"] = std::to_string(start_angle);
params["port"] = std::to_string(port);
params["address"] = hostname;
if( max_points > 0 )
params["max_num_points_scan"] = std::to_string(max_points);

// Request handle via HTTP/JSON request/response
if( !sendHttpCommand("request_handle_udp", params) || !checkErrorCode() )
Expand Down
8 changes: 4 additions & 4 deletions pepperl_fuchs_r2000/src/driver/r2000_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ R2000Driver::~R2000Driver()
}

//-----------------------------------------------------------------------------
bool R2000Driver::startCapturingTCP()
bool R2000Driver::startCapturingTCP(int start_angle, int max_points)
{
if( !checkConnection() )
return false;

handle_info_ = command_interface_->requestHandleTCP();
handle_info_ = command_interface_->requestHandleTCP(start_angle, max_points);
if( !handle_info_ )
return false;

Expand All @@ -94,7 +94,7 @@ bool R2000Driver::startCapturingTCP()
}

//-----------------------------------------------------------------------------
bool R2000Driver::startCapturingUDP()
bool R2000Driver::startCapturingUDP(int start_angle, int max_points)
{
if( !checkConnection() )
return false;
Expand All @@ -104,7 +104,7 @@ bool R2000Driver::startCapturingUDP()
return false;
int udp_port = data_receiver_->getUDPPort();

handle_info_ = command_interface_->requestHandleUDP(udp_port);
handle_info_ = command_interface_->requestHandleUDP(udp_port, "", start_angle, max_points);
if( !handle_info_ || !command_interface_->startScanOutput((*handle_info_).handle) )
return false;

Expand Down