Skip to content

Commit

Permalink
Added support to access GigEVision cameras via IP address. This resolves
Browse files Browse the repository at this point in the history
  • Loading branch information
boitumeloruf committed Nov 12, 2024
1 parent 7b85c92 commit ab19317
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ It currently implements the gigabit ethernet and USB3 protocols used by industri

**Acknowledgement**: This software was developed as part of the project [ROBDEKON – Robotic Systems for Decontamination in Hazardous Environments](https://robdekon.de/), funded by the Federal Ministry of Education and Research (BMBF) under the German Federal Government’s Research for Civil Security program.

*camera_aravis for ROS 1 can be found here: https://github.com/FraunhoferIOSB/camera_aravis*

------------------------

### Continuous Integration:
Expand Down Expand Up @@ -37,6 +39,7 @@ It currently implements the gigabit ethernet and USB3 protocols used by industri
- [How to manually trigger calculation of white balance ratios](#how-to-manually-trigger-calculation-of-white-balance-ratios)
- [How to dynamically change camera parameters](#how-to-dynamically-change-camera-parameters)
- [How to publish camera diagnostics / status](#how-to-publish-camera-diagnostics--status)
- [How to access GigEVision camera using the IP address](#how-to-access-gigevision-camera-using-the-ip-address)
- [Known Issues](#known-issues)

------------------------
Expand All @@ -53,7 +56,7 @@ The configuration of the camera driver is divided into a driver-specific and Gen

#### Driver-specific Parameters

- `guid`: Serial number of the camera that is to be opened. GUIDs of available cameras can be discovered with [`camera_finder`](#finding-available-cameras) node.
- `guid`: Serial number or IP address *(GigEVision Cameras only)* of the camera that is to be opened. GUIDs and IP addresses of available cameras can be discovered with [`camera_finder`](#finding-available-cameras) node.
- Type: String
- Default: ""
- Optional. If omitted a random camera is picked from the list of connected cameras and will be opened.
Expand Down Expand Up @@ -403,6 +406,11 @@ additionally specify a list of ```Selectors```. Each entry in this list should a
For each feature a key-value pair is constructed and published in the ```data``` field of the
message stated above. If a feature as a list of selectors, one key-value pair is constructed for each Feature-Selector pair.

### How to access GigEVision camera using the IP address

GigEVision cameras can also be accessed using their IP address instead of their serial number simply by passing the address to the launch parameter [`guid`](#driver-specific-parameters).
GUIDs and IP addresses of available cameras can be discovered with [`camera_finder`](#finding-available-cameras) node.

## Known Issues

- **Permanent acquisition and publication of image data prior to Jazzy Jalisco:**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ class CameraAravisNodeBase : public rclcpp::Node
//--- FUNCTION DECLARATION ---//

protected:
/**
* @brief Check if given string is an IP Adress.
*/
static bool isIpAddress(const std::string& str);

/**
* @brief Construct GUID string of given camera, using vendor name, model name and
* device serial number.
Expand Down
20 changes: 20 additions & 0 deletions camera_aravis2/src/camera_aravis_node_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "camera_aravis2/camera_aravis_node_base.h"

// Std
#include <regex>
#include <string>
#include <type_traits>

// camera_aravis2
Expand Down Expand Up @@ -57,6 +59,7 @@ CameraAravisNodeBase::~CameraAravisNodeBase()
if (p_camera_)
g_object_unref(p_camera_);

arv_shutdown();
RCLCPP_INFO(logger_, "Node has shut down.");
}

Expand Down Expand Up @@ -84,9 +87,11 @@ bool CameraAravisNodeBase::isInitialized() const
RCLCPP_INFO(logger_, "Attached cameras (Num. Interfaces: %d | Num. Devices: %d):",
n_interfaces, n_devices);
for (uint i = 0; i < n_devices; i++)
{
RCLCPP_INFO(logger_, " Device %d: %s (%s)", i,
arv_get_device_id(i),
arv_get_device_address(i));
}

return true;
}
Expand Down Expand Up @@ -667,6 +672,21 @@ bool CameraAravisNodeBase::executeCommand(const std::string& feature_name) const
return is_successful;
}

//==================================================================================================
bool CameraAravisNodeBase::isIpAddress(const std::string& str)
{
//--- Regular expression for an IPv4 address
//--- 25[0-5] allows values between 250-255
//--- 2[0-4][0-9] allows values between 200-249
//--- [01]?[0-9][0-9] allows values between 0-199
//--- this is repeated three times with a succeeding .
//--- (\b ... \b) ensures that the whole expression is considered
std::regex ipv4Regex(
R"((\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b)");

return std::regex_match(str, ipv4Regex);
}

//==================================================================================================
std::string CameraAravisNodeBase::constructCameraGuidStr(ArvCamera* p_cam)
{
Expand Down
6 changes: 5 additions & 1 deletion camera_aravis2/src/camera_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,8 @@ void CameraDriver::spawnCameraStreams()
std::string camera_guid_str = CameraAravisNodeBase::constructCameraGuidStr(p_camera_);
RCLCPP_INFO(logger_, "Done initializing.");
RCLCPP_INFO(logger_, " Camera: %s", camera_guid_str.c_str());
if (arv_camera_is_gv_device(p_camera_) && CameraAravisNodeBase::isIpAddress(guid_))
RCLCPP_INFO(logger_, " IP: %s", guid_.c_str());
RCLCPP_INFO(logger_, " Num. Streams: (%i / %i)",
num_opened_streams, static_cast<int>(streams_.size()));

Expand Down Expand Up @@ -1874,10 +1876,12 @@ void CameraDriver::printCameraConfiguration() const
rclcpp::ParameterValue tmp_param_value;
std::vector<std::pair<std::string, rclcpp::ParameterValue>> tmp_param_values;

std::string camera_guid_str = CameraAravisNodeBase::constructCameraGuidStr(p_camera_);

RCLCPP_INFO(logger_, "======================================");
RCLCPP_INFO(logger_, "Camera Configuration:");
RCLCPP_INFO(logger_, "--------------------------------------");
RCLCPP_INFO(logger_, " GUID: %s", guid_.c_str());
RCLCPP_INFO(logger_, " GUID: %s", camera_guid_str.c_str());
if (is_verbose_enable_)
{
RCLCPP_INFO(logger_, " Type: %s",
Expand Down

0 comments on commit ab19317

Please sign in to comment.