-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
279be5f
commit 539949f
Showing
27 changed files
with
1,493 additions
and
618 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* @file | ||
* @copyright Copyright (C) 2024, Blickfeld GmbH | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "qb2/point_cloud_reader.h" | ||
|
||
#include "qb2_driver_status.h" | ||
#include "qb2_ros2_type.h" | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
|
||
namespace blickfeld { | ||
namespace ros_interop { | ||
namespace qb2 { | ||
|
||
class PointCloudGetter : public PointCloudReader { | ||
public: | ||
using PointCloudReader::PointCloudReader; | ||
|
||
/** | ||
* @brief Read the Frame object from Qb2 | ||
* | ||
* @return std::pair<CommunicationState, Qb2Frame> The state of communication and the new optional frame object | ||
*/ | ||
std::pair<CommunicationState, std::optional<Qb2Frame>> readFrame() final; | ||
}; | ||
} // namespace qb2 | ||
} // namespace ros_interop | ||
} // namespace blickfeld |
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,54 @@ | ||
/** | ||
* @file | ||
* @copyright Copyright (C) 2024, Blickfeld GmbH | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "qb2_driver_status.h" | ||
#include "qb2_ros2_type.h" | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include <memory> | ||
#include <optional> | ||
#include <utility> | ||
|
||
namespace blickfeld { | ||
namespace ros_interop { | ||
namespace qb2 { | ||
|
||
class PointCloudReader { | ||
public: | ||
PointCloudReader(rclcpp::Node::SharedPtr node, const Qb2Info& qb2); | ||
|
||
virtual ~PointCloudReader(); | ||
|
||
/** | ||
* @brief Read the Frame object from Qb2 | ||
* | ||
* @return std::pair<CommunicationState, Qb2Frame> The state of communication and the new optional frame object | ||
*/ | ||
virtual std::pair<CommunicationState, std::optional<Qb2Frame>> readFrame() = 0; | ||
|
||
/** | ||
* @brief Try to cancel the running getter | ||
* | ||
*/ | ||
virtual void cancel(); | ||
|
||
protected: | ||
rclcpp::Node::SharedPtr node_; | ||
|
||
/// Device info that we want to connect to | ||
Qb2Info qb2_; | ||
|
||
/// Connection channel to the Qb2 gRPC server | ||
std::shared_ptr<grpc::Channel> qb2_channel_; | ||
|
||
/// The gRPC client context for Qb2 | ||
std::unique_ptr<grpc::ClientContext> point_cloud_context_ = nullptr; | ||
}; | ||
} // namespace qb2 | ||
} // namespace ros_interop | ||
} // namespace blickfeld |
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,66 @@ | ||
/** | ||
* @file | ||
* @copyright Copyright (C) 2024, Blickfeld GmbH | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "qb2/point_cloud_reader.h" | ||
|
||
#include "qb2_driver_status.h" | ||
#include "qb2_ros2_type.h" | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
|
||
namespace blickfeld { | ||
namespace ros_interop { | ||
namespace qb2 { | ||
|
||
class PointCloudStreamer : public PointCloudReader { | ||
public: | ||
using PointCloudReader::PointCloudReader; | ||
|
||
/** | ||
* @brief Read the Frame object from Qb2 | ||
* | ||
* @return std::pair<CommunicationState, Qb2Frame> The state of communication and the new optional frame object | ||
*/ | ||
std::pair<CommunicationState, std::optional<Qb2Frame>> readFrame() final; | ||
|
||
private: | ||
|
||
/** | ||
* @brief Read the Frame object from Qb2. | ||
* The method doesn't cleanup the internal state after connection issues | ||
* | ||
* @return std::pair<CommunicationState, Qb2Frame> The state of communication and the new optional frame object | ||
*/ | ||
std::pair<CommunicationState, std::optional<Qb2Frame>> tryReadFrame(); | ||
|
||
/** | ||
* @brief Attempts to open a point cloud stream if the qb2_channel is connected | ||
* | ||
* @return The state of communication with Qb2, if successful it should return | ||
* CommunicationState::SUCCESS_OPEN_STREAM | ||
*/ | ||
CommunicationState openPointCloudStream(); | ||
|
||
/** | ||
* @brief Checks if the stream is open | ||
* | ||
* @return true | ||
* @return false | ||
*/ | ||
bool isStreamingPointCloud() const; | ||
|
||
/** | ||
* @brief disconnects from the server and cleans up all internal connection state | ||
*/ | ||
void disconnect(); | ||
|
||
/// Unique pointers for Qb2 streams | ||
std::unique_ptr<grpc::ClientReader<Qb2PointCloudStreamResponse>> point_cloud_stream_ = nullptr; | ||
}; | ||
} // namespace qb2 | ||
} // namespace ros_interop | ||
} // namespace blickfeld |
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,87 @@ | ||
/** | ||
* @file | ||
* @copyright Copyright (C) 2024, Blickfeld GmbH | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "qb2_driver_status.h" | ||
#include "qb2_ros2_type.h" | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include <optional> | ||
|
||
namespace blickfeld { | ||
namespace ros_interop { | ||
namespace qb2 { | ||
|
||
class ScanPatternWatcher { | ||
public: | ||
ScanPatternWatcher(rclcpp::Node::SharedPtr node, const Qb2Info& qb2); | ||
|
||
~ScanPatternWatcher(); | ||
|
||
/** | ||
* @brief Watches the scan pattern changes on the Qb2 | ||
* | ||
* @return std::pair<CommunicationState, std::optional<Qb2ScanPattern>> The state of communication and the optional | ||
* new scan pattern object | ||
*/ | ||
std::pair<CommunicationState, std::optional<Qb2ScanPattern>> watchScanPattern(); | ||
|
||
/** | ||
* @brief Try to cancel the running watch stream | ||
* | ||
*/ | ||
void cancel(); | ||
|
||
|
||
private: | ||
/** | ||
* @brief tries opening a scan patter watch stream and returns a response of the stream. | ||
* The method doesn't cleanup the internal state after connection issues | ||
* | ||
* @return std::pair<CommunicationState, std::optional<Qb2ScanPattern>> The state of communication and the optional | ||
* new scan pattern object | ||
*/ | ||
std::pair<CommunicationState, std::optional<Qb2ScanPattern>> tryWatchScanPattern(); | ||
|
||
/** | ||
* @brief Attempts to open a scan pattern watch if the qb2_channel is connected | ||
* | ||
* @return The state of communication with Qb2, if successful it should return | ||
* CommunicationState::SUCCESS_OPEN_STREAM | ||
*/ | ||
CommunicationState openScanPatternWatch(); | ||
|
||
/** | ||
* @brief disconnects from the server and cleans up all internal connection state | ||
*/ | ||
void disconnect(); | ||
|
||
/** | ||
* @brief Checks if the watch stream is open | ||
* | ||
* @return true | ||
* @return false | ||
*/ | ||
bool isWatchingScanPattern() const; | ||
|
||
rclcpp::Node::SharedPtr node_; | ||
|
||
/// Device info that we want to connect to | ||
Qb2Info qb2_; | ||
|
||
/// Connection channel to the Qb2 gRPC server | ||
std::shared_ptr<grpc::Channel> qb2_channel_; | ||
|
||
/// The gRPC client context for Qb2 streams | ||
std::unique_ptr<grpc::ClientContext> scan_pattern_watch_context_ = nullptr; | ||
|
||
/// Unique pointers for Qb2 streams | ||
std::unique_ptr<grpc::ClientReader<Qb2ScanPatternWatchResponse>> scan_pattern_watch_ = nullptr; | ||
}; | ||
} // namespace qb2 | ||
} // namespace ros_interop | ||
} // namespace blickfeld |
Oops, something went wrong.