1 #ifndef _CHRONOPTICS_TOF_GIGE_INTERFACE_HPP_
2 #define _CHRONOPTICS_TOF_GIGE_INTERFACE_HPP_
4 #include <chronoptics/tof/gige_interface.h>
6 #include <chronoptics/tof/camera_config.hpp>
7 #include <chronoptics/tof/calibration.hpp>
8 #include <chronoptics/tof/data.hpp>
10 namespace chronoptics {
15 enum class DepthStreamType {
24 class DiscoveryMessage :
public detail::Base<tof_discovery_message, tof_discovery_message_delete> {
34 const char*
ip()
const {
35 return tof_discovery_message_ip(this->ptr_, TOF_ERROR_HANDLER{});
42 return tof_discovery_message_serial(this->ptr_, TOF_ERROR_HANDLER{});
49 class PersistentIp :
public detail::Base<tof_persistent_ip, tof_persistent_ip_delete> {
62 PersistentIp(StringView ip, StringView netmask, StringView gateway,
bool enabled) {
63 this->ptr_ = tof_persistent_ip_new(ip, netmask, gateway, enabled, TOF_ERROR_HANDLER{});
70 return tof_persistent_ip_get_ip(this->ptr_, TOF_ERROR_HANDLER{});
77 return tof_persistent_ip_set_ip(this->ptr_, ip, TOF_ERROR_HANDLER{});
84 return tof_persistent_ip_get_netmask(this->ptr_, TOF_ERROR_HANDLER{});
91 return tof_persistent_ip_set_netmask(this->ptr_, netmask, TOF_ERROR_HANDLER{});
98 return tof_persistent_ip_get_gateway(this->ptr_, TOF_ERROR_HANDLER{});
105 return tof_persistent_ip_set_gateway(this->ptr_, gateway, TOF_ERROR_HANDLER{});
112 return tof_persistent_ip_get_enabled(this->ptr_, TOF_ERROR_HANDLER{});
119 return tof_persistent_ip_set_enabled(this->ptr_, enabled, TOF_ERROR_HANDLER{});
126 class GigeInterface :
public detail::Base<tof_gige_interface, tof_gige_interface_delete> {
138 this->ptr_ = tof_gige_interface_new(port, TOF_ERROR_HANDLER{});
145 size_t size = tof_gige_interface_discover(this->ptr_,
nullptr, 0, TOF_ERROR_HANDLER{});
146 std::vector<DiscoveryMessage> vec;
148 for (
size_t i = 0; i < size; i++)
149 vec.emplace_back(
static_cast<tof_discovery_message_t
>(
nullptr));
150 auto data =
reinterpret_cast<tof_discovery_message_t*
>(vec.data());
151 size = tof_gige_interface_discover(this->ptr_, data, vec.size(), TOF_ERROR_HANDLER{});
159 DiscoveryMessage new_discovery_message(
static_cast<tof_discovery_message_t
>(
nullptr));
160 auto ptr =
reinterpret_cast<tof_discovery_message_t*
>(&new_discovery_message);
161 *ptr = tof_gige_interface_discover_one(this->ptr_, TOF_ERROR_HANDLER{});
162 return new_discovery_message;
171 DiscoveryMessage new_discovery_message(
static_cast<tof_discovery_message_t
>(
nullptr));
172 auto ptr =
reinterpret_cast<tof_discovery_message_t*
>(&new_discovery_message);
173 *ptr = tof_gige_interface_find(this->ptr_, serial, TOF_ERROR_HANDLER{});
174 return new_discovery_message;
181 return tof_gige_interface_connect(this->ptr_, *
reinterpret_cast<const tof_discovery_message_t*
>(&message), TOF_ERROR_HANDLER{});
187 return tof_gige_interface_disconnect(this->ptr_, TOF_ERROR_HANDLER{});
194 return tof_gige_interface_is_connected(this->ptr_, TOF_ERROR_HANDLER{});
201 return tof_gige_interface_get_stream_packet_size(this->ptr_, TOF_ERROR_HANDLER{});
208 return tof_gige_interface_set_stream_packet_size(this->ptr_, packet_size, TOF_ERROR_HANDLER{});
216 return tof_gige_interface_test_stream_packet_size(this->ptr_, port, TOF_ERROR_HANDLER{});
224 return tof_gige_interface_get_delay(this->ptr_, TOF_ERROR_HANDLER{});
232 return tof_gige_interface_set_delay(this->ptr_, delay, TOF_ERROR_HANDLER{});
240 CameraConfig new_camera_config(
static_cast<tof_camera_config_t
>(
nullptr));
241 auto ptr =
reinterpret_cast<tof_camera_config_t*
>(&new_camera_config);
242 *ptr = tof_gige_interface_download_configuration(this->ptr_, port, TOF_ERROR_HANDLER{});
243 return new_camera_config;
251 Calibration new_calibration(
static_cast<tof_calibration_t
>(
nullptr));
252 auto ptr =
reinterpret_cast<tof_calibration_t*
>(&new_calibration);
253 *ptr = tof_gige_interface_download_calibration(this->ptr_, port, TOF_ERROR_HANDLER{});
254 return new_calibration;
262 return tof_gige_interface_upload_configuration(this->ptr_, *
reinterpret_cast<const tof_camera_config_t*
>(&config), port, TOF_ERROR_HANDLER{});
270 return tof_gige_interface_depth_stream_capable(this->ptr_,
static_cast<tof_depth_stream_type
>(stream), TOF_ERROR_HANDLER{});
278 return tof_gige_interface_start_depth_stream(this->ptr_,
static_cast<tof_depth_stream_type
>(stream), port, TOF_ERROR_HANDLER{});
284 return tof_gige_interface_stop_depth_stream(this->ptr_, TOF_ERROR_HANDLER{});
291 return tof_gige_interface_has_depth_data(this->ptr_, TOF_ERROR_HANDLER{});
298 Data new_data(
static_cast<tof_data_t
>(
nullptr));
299 auto ptr =
reinterpret_cast<tof_data_t*
>(&new_data);
300 *ptr = tof_gige_interface_get_depth_data(this->ptr_, TOF_ERROR_HANDLER{});
308 return tof_gige_interface_image_stream_capable(this->ptr_, TOF_ERROR_HANDLER{});
315 return tof_gige_interface_start_image_stream(this->ptr_, port, TOF_ERROR_HANDLER{});
321 return tof_gige_interface_stop_image_stream(this->ptr_, TOF_ERROR_HANDLER{});
328 return tof_gige_interface_has_image_data(this->ptr_, TOF_ERROR_HANDLER{});
335 Data new_data(
static_cast<tof_data_t
>(
nullptr));
336 auto ptr =
reinterpret_cast<tof_data_t*
>(&new_data);
337 *ptr = tof_gige_interface_get_image_data(this->ptr_, TOF_ERROR_HANDLER{});
349 Data new_data(
static_cast<tof_data_t
>(
nullptr));
350 auto ptr =
reinterpret_cast<tof_data_t*
>(&new_data);
351 *ptr = tof_gige_interface_get_image_data_into_pointer(this->ptr_, pointer, capacity, user_pointer_destructed_cb_handler, &callback, TOF_ERROR_HANDLER{});
364 Data new_data(
static_cast<tof_data_t
>(
nullptr));
365 auto ptr =
reinterpret_cast<tof_data_t*
>(&new_data);
366 *ptr = tof_gige_interface_get_image_data_into_pointer(this->ptr_, pointer, capacity, callback, callback_user_data, TOF_ERROR_HANDLER{});
374 return tof_gige_interface_persistent_ip_capable(this->ptr_, TOF_ERROR_HANDLER{});
381 PersistentIp new_persistent_ip(
static_cast<tof_persistent_ip_t
>(
nullptr));
382 auto ptr =
reinterpret_cast<tof_persistent_ip_t*
>(&new_persistent_ip);
383 *ptr = tof_gige_interface_get_persistent_ip(this->ptr_, TOF_ERROR_HANDLER{});
384 return new_persistent_ip;
392 return tof_gige_interface_set_persistent_ip(this->ptr_, *
reinterpret_cast<const tof_persistent_ip_t*
>(&persistent_ip), TOF_ERROR_HANDLER{});
399 return tof_gige_interface_get_user_pointer_capacity(this->ptr_, TOF_ERROR_HANDLER{});
406 return tof_gige_interface_set_user_pointer_capacity(this->ptr_, capacity, TOF_ERROR_HANDLER{});
418 return tof_gige_interface_add_depth_user_pointer(this->ptr_, pointer, capacity, user_pointer_destructed_cb_handler, &callback, TOF_ERROR_HANDLER{});
430 void add_depth_user_pointer(uint8_t* pointer,
size_t capacity, tof_user_pointer_destructed_t callback,
void* callback_user_data) {
431 return tof_gige_interface_add_depth_user_pointer(this->ptr_, pointer, capacity, callback, callback_user_data, TOF_ERROR_HANDLER{});
438 return tof_gige_interface_version(this->ptr_, TOF_ERROR_HANDLER{});
This class contains all the calibration information.
This class allows you to view/edit the camera settings.
This is the class that contains depth or image data.
A gige discovery message containing camera information.
const char * ip() const
Get the camera's ip address.
const char * serial() const
Get the camera's serial.
DiscoveryMessage(tof_discovery_message_t ptr=nullptr)
Construct from pointer.
Connect to a camera directly using the gige interface.
DiscoveryMessage discover_one()
Returns a message of the first camera that responded.
bool depth_stream_capable(DepthStreamType stream) const
Check whether this camera is capable of streaming the specified type.
std::vector< DiscoveryMessage > discover()
Detect all the cameras on the network.
CameraConfig download_configuration(uint16_t port=0)
Download camera configuration from the camera.
void disconnect()
Disconnect from the camera.
void set_stream_packet_size(uint16_t packet_size)
Set stream packet size.
void start_image_stream(uint16_t port=0)
Start image stream.
void stop_depth_stream()
Stop the depth stream.
GigeInterface(tof_gige_interface_t ptr)
Construct from pointer.
const char * version()
Get the tof library version running on the camera.
void add_depth_user_pointer(uint8_t *pointer, size_t capacity, tof_user_pointer_destructed_t callback, void *callback_user_data)
Add a pointer that will be filled with depth data.
GigeInterface(uint16_t port=0)
Create an instance of the gige interface.
bool image_stream_capable() const
Check whether camera supports an image stream.
void connect(const DiscoveryMessage &message)
Connect to the camera and gain exclusive access.
Data get_image_data()
Get image frame.
bool persistent_ip_capable() const
Get whether the camera is persistent ip capable.
Calibration download_calibration(uint16_t port=0)
Download calibration from the camera.
uint32_t get_delay() const
Get delay between network packets.
size_t get_user_pointer_capacity() const
Get the capacity for amount of user pointers that can be registered.
Data get_depth_data()
Get a depth frame.
void start_depth_stream(DepthStreamType stream, uint16_t port=0)
Start the depth stream.
bool has_depth_data() const
Returns true if a depth frame is available.
uint16_t get_stream_packet_size() const
Get stream packet size.
bool test_stream_packet_size(uint16_t port=0)
Test whether using the set packet size works.
void set_user_pointer_capacity(size_t capacity)
Set the capacity for amount of user pointers that can be registered.
void set_persistent_ip(const PersistentIp &persistent_ip)
Set the persistent ip settings.
void add_depth_user_pointer(uint8_t *pointer, size_t capacity, user_pointer_destructed_fn &callback)
Add a pointer that will be filled with depth data.
Data get_image_data_into_pointer(uint8_t *pointer, size_t capacity, tof_user_pointer_destructed_t callback, void *callback_user_data)
Get the image frame into the supplied pointer.
void upload_configuration(const CameraConfig &config, uint16_t port=0)
Upload camera configuration to the camera.
void set_delay(uint32_t delay)
Set delay between network packets.
PersistentIp get_persistent_ip() const
Get the current persistent ip settings.
bool has_image_data() const
Check whether image frame is available.
void stop_image_stream()
Stop image stream.
DiscoveryMessage find(StringView serial)
Detect a specific camera on the network, will throw an error if it can't find the camera.
bool is_connected() const
Check whether a connection is still maintained with the camera.
Data get_image_data_into_pointer(uint8_t *pointer, size_t capacity, user_pointer_destructed_fn &callback)
Get the image frame into the supplied pointer.
A persistent ip data structure.
void set_gateway(StringView gateway)
Set the gateway.
bool get_enabled() const
Get if persistent ip is enabled.
void set_enabled(bool enabled)
Set if persistent ip is enabled.
void set_netmask(StringView netmask)
Set the netmask.
const char * get_ip() const
Get the IP address.
const char * get_netmask() const
Get the netmask.
PersistentIp(tof_persistent_ip_t ptr=nullptr)
Construct from pointer.
void set_ip(StringView ip)
Set the IP address.
PersistentIp(StringView ip, StringView netmask, StringView gateway, bool enabled)
Create persistent ip.
const char * get_gateway() const
Get the gateway.