Skip to content
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ add_library(${PROJECT_NAME} SHARED
"src/${PROJECT_NAME}/config/grpc/config.cpp"
"src/${PROJECT_NAME}/config/grpc/call_data_get_capture_setting.cpp"
"src/${PROJECT_NAME}/config/grpc/call_data_get_image.cpp"
"src/${PROJECT_NAME}/config/grpc/call_data_load_config.cpp"
"src/${PROJECT_NAME}/config/grpc/call_data_save_capture_setting.cpp"
"src/${PROJECT_NAME}/config/grpc/call_data_set_capture_setting.cpp"
"src/${PROJECT_NAME}/config/grpc/call_data_record_image.cpp"
Expand Down
6 changes: 3 additions & 3 deletions include/shisen_cpp/camera/provider/image_provider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
#ifndef SHISEN_CPP__CAMERA__PROVIDER__IMAGE_PROVIDER_HPP_
#define SHISEN_CPP__CAMERA__PROVIDER__IMAGE_PROVIDER_HPP_

#include <cv_bridge/cv_bridge.hpp>
#include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include <sensor_msgs/msg/image.hpp>
#include <shisen_cpp/utility.hpp>
#include <std_msgs/msg/header.hpp>

#include <cv_bridge/cv_bridge.hpp>
#include <memory>
#include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include <string>

namespace shisen_cpp::camera
Expand Down
46 changes: 46 additions & 0 deletions include/shisen_cpp/config/grpc/call_data_load_config.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) 2024 ICHIRO ITS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#ifndef SHISEN_CPP__CONFIG__GRPC__CALL_DATA_LOAD_CONFIG_HPP__
#define SHISEN_CPP__CONFIG__GRPC__CALL_DATA_LOAD_CONFIG_HPP__

#include <shisen_cpp/camera/node/camera_node.hpp>
#include <shisen_cpp/config/grpc/call_data.hpp>
#include <shisen_cpp/utility.hpp>

namespace shisen_cpp
{
class CallDataLoadConfig
: CallData<shisen_interfaces::proto::Empty, shisen_interfaces::proto::Empty>
{
public:
CallDataLoadConfig(
shisen_interfaces::proto::Config::AsyncService * service, grpc::ServerCompletionQueue * cq,
const std::string & path, const std::shared_ptr<camera::CameraNode>& camera_node);

protected:
void AddNextToCompletionQueue() override;
void WaitForRequest() override;
void HandleRequest() override;
std::shared_ptr<camera::CameraNode> camera_node_;
};
} // namespace shisen_cpp

#endif // SHISEN_CPP__CONFIG__GRPC__CALL_DATA_LOAD_CONFIG_HPP__
6 changes: 3 additions & 3 deletions include/shisen_cpp/viewer/consumer/image_consumer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
#ifndef SHISEN_CPP__VIEWER__CONSUMER__IMAGE_CONSUMER_HPP_
#define SHISEN_CPP__VIEWER__CONSUMER__IMAGE_CONSUMER_HPP_

#include <cv_bridge/cv_bridge.hpp>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <sensor_msgs/msg/image.hpp>
#include <shisen_cpp/utility.hpp>

#include <cv_bridge/cv_bridge.hpp>
#include <memory>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <string>

namespace shisen_cpp::viewer
Expand Down
3 changes: 2 additions & 1 deletion src/shisen_cpp/config/grpc/call_data_get_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#include <opencv2/opencv.hpp>
#include <rclcpp/rclcpp.hpp>
#include <shisen_cpp/config/grpc/call_data_get_image.hpp>
#include <shisen_interfaces/shisen.grpc.pb.h>
#include <shisen_interfaces/shisen.pb.h>

#include <opencv2/opencv.hpp>

namespace shisen_cpp
{
CallDataGetImage::CallDataGetImage(
Expand Down
59 changes: 59 additions & 0 deletions src/shisen_cpp/config/grpc/call_data_load_config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) 2024 ICHIRO ITS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#include <rclcpp/rclcpp.hpp>
#include <shisen_cpp/config/grpc/call_data_load_config.hpp>
#include <shisen_cpp/config/utils/config.hpp>
#include <shisen_interfaces/shisen.grpc.pb.h>
#include <shisen_interfaces/shisen.pb.h>

namespace shisen_cpp
{
CallDataLoadConfig::CallDataLoadConfig(
shisen_interfaces::proto::Config::AsyncService * service, grpc::ServerCompletionQueue * cq,
const std::string & path, const std::shared_ptr<camera::CameraNode>& camera_node)
: CallData(service, cq, path), camera_node_(camera_node)
{
Proceed();
}

void CallDataLoadConfig::AddNextToCompletionQueue()
{
new CallDataLoadConfig(service_, cq_, path_, camera_node_);
}

void CallDataLoadConfig::WaitForRequest()
{
service_->RequestLoadConfig(&ctx_, &request_, &responder_, cq_, cq_, this);
}

void CallDataLoadConfig::HandleRequest()
{
try {
camera_node_->load_configuration(path_);

RCLCPP_INFO(
rclcpp::get_logger("Load config"), "config has been loaded!"
);
} catch (nlohmann::json::exception e) {
RCLCPP_ERROR(rclcpp::get_logger("Load config"), e.what());
}
}
} // namespace shisen_cpp
2 changes: 2 additions & 0 deletions src/shisen_cpp/config/grpc/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <shisen_cpp/config/grpc/call_data_base.hpp>
#include <shisen_cpp/config/grpc/call_data_get_capture_setting.hpp>
#include <shisen_cpp/config/grpc/call_data_get_image.hpp>
#include <shisen_cpp/config/grpc/call_data_load_config.hpp>
#include <shisen_cpp/config/grpc/call_data_save_capture_setting.hpp>
#include <shisen_cpp/config/grpc/call_data_set_capture_setting.hpp>
#include <shisen_cpp/config/grpc/call_data_record_image.hpp>
Expand Down Expand Up @@ -73,6 +74,7 @@ void ConfigGrpc::Run(const std::string & path, std::shared_ptr<camera::CameraNod
new CallDataSaveCaptureSetting(&service_, cq_.get(), path);
new CallDataSetCaptureSetting(&service_, cq_.get(), path, camera_node);
new CallDataGetImage(&service_, cq_.get(), path, camera_node);
new CallDataLoadConfig(&service_, cq_.get(), path, camera_node);
new CallDataRecordImage(&service_, cq_.get(), path, camera_node);
void * tag; // uniquely identifies a request.
bool ok = true;
Expand Down