diff --git a/.gitignore b/.gitignore index 82dbe5fa..48482deb 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /log /third_party/osqp/ /third_party/OsqpEigen/ +/output \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index d9772ffd..036831ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,7 @@ protobuf_generate( TARGET proto-objects LANGUAGE grpc GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc - PLUGIN "protoc-gen-grpc=${PROJECT_SOURCE_DIR}/dependency/${ARCH}/third_party/grpc/v1.76.0/bin/grpc_cpp_plugin" + PLUGIN "protoc-gen-grpc=$" IMPORT_DIRS ${PROTO_IMPORT_DIR} PROTOC_OUT_DIR ${PROTO_BINARY_DIR} USAGE_REQUIREMENT PRIVATE @@ -115,6 +115,7 @@ target_link_libraries(cmvr_es PRIVATE cmvr_es::ik_solver cmvr_es::planner cmvr_es::device::humanoid_robot + cmvr_es::common ) install(TARGETS cmvr_es RUNTIME DESTINATION bin) diff --git a/cmvr-es/common/config/camera_config/camera_config.pb.txt b/cmvr-es/common/config/camera_config/camera_config.pb.txt index 5b7f4382..a33b8bc2 100644 --- a/cmvr-es/common/config/camera_config/camera_config.pb.txt +++ b/cmvr-es/common/config/camera_config/camera_config.pb.txt @@ -1,6 +1,25 @@ -id: "cam1" -usb: "/dev/video6" -width: 640 -height: 480 -fps: 30 -codec: "H265" +realsense_cameras { + id: "cam2" + serialNumber: "123456789012" + width: 1280 + height: 720 + fps: 30 + codec: "H265" + camera_mode: CAMERA_MODE_VIDEO + stream_mode: STREAM_MODE_RGBD + align_mode: ALIGN_MODE_COLOR + buffer_size: 30 + sync: true +} + +uvc_cameras { + id: "cam1" + usb: "/dev/video0" + width: 640 + height: 480 + fps: 30 + codec: "H265" + camera_mode: CAMERA_MODE_PHOTO + stream_mode: STREAM_MODE_RGB + buffer_size: 30 +} diff --git a/cmvr-es/common/config/dexhand_config/dexhand_config.pb.txt b/cmvr-es/common/config/dexhand_config/dexhand_config.pb.txt new file mode 100644 index 00000000..3ca234bd --- /dev/null +++ b/cmvr-es/common/config/dexhand_config/dexhand_config.pb.txt @@ -0,0 +1,11 @@ +rh56dftp_dexhands { + id: "hand1" + ip: "192.168.1.213" + port: 6000 +} + +rh56dftp_dexhands { + id: "hand2" + ip: "192.168.1.214" + port: 6000 +} \ No newline at end of file diff --git a/cmvr-es/common/config/microphone_conifg/microphone_config.pb.txt b/cmvr-es/common/config/microphone_conifg/microphone_config.pb.txt new file mode 100644 index 00000000..237e4033 --- /dev/null +++ b/cmvr-es/common/config/microphone_conifg/microphone_config.pb.txt @@ -0,0 +1,6 @@ +ffmpeg_microphones { + id: "mic1" + channels: 2 + sampleRate: 44100 + volume: 100 +} \ No newline at end of file diff --git a/cmvr-es/common/config/speaker_config/speaker_config.pb.txt b/cmvr-es/common/config/speaker_config/speaker_config.pb.txt new file mode 100644 index 00000000..6f7abc1a --- /dev/null +++ b/cmvr-es/common/config/speaker_config/speaker_config.pb.txt @@ -0,0 +1,3 @@ +ffmpeg_speakers { + id: "spk1" +} \ No newline at end of file diff --git a/cmvr-es/common/utils/config_helper/include/config_helper.h b/cmvr-es/common/utils/config_helper/include/config_helper.h index 47a8c61e..6f575d4c 100644 --- a/cmvr-es/common/utils/config_helper/include/config_helper.h +++ b/cmvr-es/common/utils/config_helper/include/config_helper.h @@ -5,6 +5,10 @@ #include "common/utils/config_helper/include/config_setting.h" #include "common/utils/io/proto_message_utils.h" #include "cmvr/config/pinocchio_qp_ik_solver_config.pb.h" +#include "cmvr/config/camera_config/camera_config.pb.h" +#include "cmvr/config/dexhand_config/dexhand_config.pb.h" +#include "cmvr/config/microphone_config/microphone_config.pb.h" +#include "cmvr/config/speaker_config/speaker_conifg.pb.h" #define GET_CONFIG(file, para) \ ([&]() -> bool { \ @@ -47,6 +51,26 @@ namespace cmvr return SET_CONFIG(config, pinocchio_qp_ik_solver_config_file); } + static bool getCamerasConfig(config::CameraConfig& config) + { + return GET_CONFIG(camera_config_file, config); + } + + static bool getDexHandsConfig(config::DexHandConfig& config) + { + return GET_CONFIG(dexhand_config_file, config); + } + + static bool getMicroPhonesConfig(config::MicroPhoneConfig& config) + { + return GET_CONFIG(microphone_config_file, config); + } + + static bool getSpeakersConfig(config::SpeakerConfig& config) + { + return GET_CONFIG(speaker_config_file, config); + } + private: // Make macros able to call these (macros call ::cmvr::ConfigHelper::xxx) template diff --git a/cmvr-es/common/utils/config_helper/include/config_setting.h b/cmvr-es/common/utils/config_helper/include/config_setting.h index 4b5f1a84..25080311 100644 --- a/cmvr-es/common/utils/config_helper/include/config_setting.h +++ b/cmvr-es/common/utils/config_helper/include/config_setting.h @@ -1,3 +1,7 @@ #pragma once #include "gflags/gflags.h" -DECLARE_string(pinocchio_qp_ik_solver_config_file); \ No newline at end of file +DECLARE_string(pinocchio_qp_ik_solver_config_file); +DECLARE_string(camera_config_file); +DECLARE_string(dexhand_config_file); +DECLARE_string(microphone_config_file); +DECLARE_string(speaker_config_file); \ No newline at end of file diff --git a/cmvr-es/common/utils/config_helper/src/config_setting.cpp b/cmvr-es/common/utils/config_helper/src/config_setting.cpp index 69f29208..0d3e514e 100644 --- a/cmvr-es/common/utils/config_helper/src/config_setting.cpp +++ b/cmvr-es/common/utils/config_helper/src/config_setting.cpp @@ -13,4 +13,21 @@ static std::string basePath() DEFINE_string(pinocchio_qp_ik_solver_config_file, basePath() + "ik_solver_config/pinocchio_qp_ik_solver_config.pb.txt", - "The configuration file for pinocchio qp ik solver"); \ No newline at end of file + "The configuration file for pinocchio qp ik solver"); + +DEFINE_string(camera_config_file, + basePath() + "camera_config/camera_config.pb.txt", + "The configuration file for cameras"); + +DEFINE_string(dexhand_config_file, + basePath() + "dexhand_config/dexhand_config.pb.txt", + "The configuration file for dexhands"); + +DEFINE_string(microphone_config_file, + basePath() + "microphone_config/microphone_config.pb.txt", + "The configuration file for microphone"); + +DEFINE_string(speaker_config_file, + basePath() + "speaker_config/speaker_config.pb.txt", + "The configuration file for speaker"); + diff --git a/cmvr-es/controller/CMakeLists.txt b/cmvr-es/controller/CMakeLists.txt index df6ae774..a80a810e 100644 --- a/cmvr-es/controller/CMakeLists.txt +++ b/cmvr-es/controller/CMakeLists.txt @@ -1,6 +1,3 @@ -#find_package(protobuf REQUIRED) - - file(GLOB SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp ) @@ -11,7 +8,7 @@ add_library(controller SHARED ${SRC}) target_include_directories(controller PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(controller PUBLIC - protobuf::libprotobuf + protobuf cmvr_es::device::humanoid_robot gtest gtest_main diff --git a/cmvr-es/data_center/CMakeLists.txt b/cmvr-es/data_center/CMakeLists.txt index f5fe7e12..5f3112d7 100644 --- a/cmvr-es/data_center/CMakeLists.txt +++ b/cmvr-es/data_center/CMakeLists.txt @@ -1,5 +1,3 @@ -#find_package(protobuf REQUIRED) - add_library(data_center STATIC src/data_center.cpp src/motors_info.cpp @@ -13,6 +11,6 @@ target_link_libraries(data_center PRIVATE cmvr_es::utils cmvr_es::device::canbus cmvr_es::device::ti5motor - protobuf::libprotobuf - glog + protobuf + glog ) diff --git a/cmvr-es/device_manager/CMakeLists.txt b/cmvr-es/device_manager/CMakeLists.txt index 233f2f78..e53622b7 100644 --- a/cmvr-es/device_manager/CMakeLists.txt +++ b/cmvr-es/device_manager/CMakeLists.txt @@ -1,5 +1,3 @@ -find_package(osqp REQUIRED) - add_library(device_manager STATIC src/device_factory.cpp src/device_manager.cpp @@ -16,7 +14,7 @@ target_link_libraries(device_manager PRIVATE cmvr_es::device::realsense_camera cmvr_es::device::rh56dftp_dexhand cmvr::device::head_esp32 - osqp::osqp + osqp cmvr_es::device::humanoid_robot # cmvr_es::device::aubo_robot ) diff --git a/cmvr-es/device_manager/include/device_factory.h b/cmvr-es/device_manager/include/device_factory.h index e398bd54..1fcce739 100644 --- a/cmvr-es/device_manager/include/device_factory.h +++ b/cmvr-es/device_manager/include/device_factory.h @@ -25,6 +25,8 @@ namespace cmvr::device { template std::shared_ptr create(const XmlNode& cfg); + template + std::shared_ptr createFromConfig(const ConfigType& cfg); private: std::shared_ptr create_agv_(const XmlNode& cfg); std::shared_ptr create_battery_(const XmlNode& cfg); @@ -35,7 +37,6 @@ namespace cmvr::device { std::shared_ptr create_robot_(const XmlNode& cfg); std::shared_ptr create_speaker_(const XmlNode& cfg); std::shared_ptr create_biohead_(const XmlNode& cfg); - }; } diff --git a/cmvr-es/device_manager/src/device_factory.cpp b/cmvr-es/device_manager/src/device_factory.cpp index c2c5c842..9f27705d 100644 --- a/cmvr-es/device_manager/src/device_factory.cpp +++ b/cmvr-es/device_manager/src/device_factory.cpp @@ -12,6 +12,7 @@ #include "devices/dexhand/rh56dftp_dexhand/include/rh56dftp_dexhand.h" #include "devices/robot/humanoid_robot/include/humanoid_robot.h" //#include "robot/ti5_robot/ti5_robot.h" +#include "cmvr/api/system_command.pb.h" #include "data_center/include/motors_info.h" //#include "devices/robot/aubo_robot/include/aubo_robot.h" using namespace std; @@ -172,3 +173,75 @@ std::shared_ptr DeviceFactory::create_speaker_(const XmlNode& c return nullptr; } } + +template std::shared_ptr DeviceFactory::createFromConfig(const config::UVCCameraConfig& cfg); +template std::shared_ptr DeviceFactory::createFromConfig(const config::RealSenseCameraConfig& cfg); +template std::shared_ptr DeviceFactory::createFromConfig(const config::RH56DFTPDexHandConfig& cfg); +template std::shared_ptr DeviceFactory::createFromConfig(const config::FFMpegMicroPhoneConfig& cfg); +template std::shared_ptr DeviceFactory::createFromConfig(const config::FFMpegSpeakerConfig& cfg); +template +std::shared_ptr DeviceFactory::createFromConfig(const ConfigType& cfg) +{ + try { + if constexpr (std::is_same_v) + { + if constexpr (std::is_same_v) + { + return std::make_shared(cfg); + } + else if constexpr (std::is_same_v) + { + return std::make_shared(cfg); + } + else + { + LOG(ERROR) << "[DeviceFactory]: Unsupported camera device type "; + throw runtime_error("[DeviceFactory]: Unsupported camera device type"); + } + } + else if constexpr (std::is_same_v) + { + if constexpr (std::is_same_v) + { + return std::make_shared(cfg); + } + else + { + LOG(ERROR) << "[DeviceFactory]: Unsupported dexhand device type "; + throw runtime_error("[DeviceFactory]: Unsupported dexhand device type"); + } + } + else if constexpr (std::is_same_v) + { + if constexpr (std::is_same_v) + { + return std::make_shared(cfg); + } + else + { + LOG(ERROR) << "[DeviceFactory]: Unsupported microphone device type "; + throw runtime_error("[DeviceFactory]: Unsupported microphone device type"); + } + } + else if constexpr (std::is_same_v) + { + if constexpr (std::is_same_v) + { + return std::make_shared(cfg); + } + else + { + LOG(ERROR) << "[DeviceFactory]: Unsupported microphone device type "; + throw runtime_error("[DeviceFactory]: Unsupported microphone device type"); + } + } + else { + LOG(ERROR) << "[DeviceFactory]: Unsupported device type"; + throw runtime_error("[DeviceFactory]: Unsupported device type"); + } + } + catch (const exception &e) { + return nullptr; + } +} + diff --git a/cmvr-es/device_manager/src/device_manager.cpp b/cmvr-es/device_manager/src/device_manager.cpp index 41f11282..fc9d35f8 100644 --- a/cmvr-es/device_manager/src/device_manager.cpp +++ b/cmvr-es/device_manager/src/device_manager.cpp @@ -4,6 +4,7 @@ #include "../include/device_manager.h" +#include "common/utils/config_helper/include/config_helper.h" using namespace std; using namespace cmvr::device; using namespace cmvr::device; @@ -196,10 +197,6 @@ void DeviceManager::getSystemStatus(SystemStatus& status) const { } } -// std::shared_ptr DeviceManager::getMonitor(const std::string& id) { -// return monitors_.at(id); -// } - void DeviceManager::init_devices_() { try{ auto dmgr_node = cfg_.getChild("Devices"); @@ -235,36 +232,47 @@ void DeviceManager::init_devices_() { LOG(INFO) << "[DeviceManager]: Init AGV " << id << " Success"; } - auto camera_node = dmgr_node.getChild("Camera"); - for (auto &node: camera_node.getChildren()){ - string id = node.getAttrString("id"); + config::CameraConfig camera_config; + ConfigHelper::getCamerasConfig(camera_config); + + for (int i = 0; i < camera_config.uvc_cameras().size(); i++) { + auto cam = camera_config.uvc_cameras(i); + auto id = cam.id(); if (devices_.count(id)) { LOG(ERROR) << "[DeviceManager]: Duplicate Camera Device ID" << id; throw runtime_error("[DeviceManager]: Duplicate Camera Device ID" + id); } - auto device = dev_factory_->create(node); - if (device == nullptr) { - throw std::runtime_error("[DeviceManager]: Factory returned nullptr for device ID: " + id); - } + std::cout << "UVCCamera[" << i << "]: " << id << std::endl; + auto device = dev_factory_->createFromConfig(cam); + devices_[id] = device; + std::get>(devices_[id])->init(); + } + for (int i = 0; i < camera_config.realsense_cameras().size(); i++) { + auto cam = camera_config.realsense_cameras(i); + auto id = cam.id(); + if (devices_.count(id)) { + LOG(ERROR) << "[DeviceManager]: Duplicate Camera Device ID" << id; + throw runtime_error("[DeviceManager]: Duplicate Camera Device ID" + id); + } + std::cout << "UVCCamera[" << i << "]: " << id << std::endl; + auto device = dev_factory_->createFromConfig(cam); devices_[id] = device; std::get>(devices_[id])->init(); - LOG(INFO) << "[DeviceManager]: Init Camera " << id << " Success"; } - auto dexhand_node = dmgr_node.getChild("DexHand"); - for (auto &node: dexhand_node.getChildren()){ - string id = node.getAttrString("id"); + config::DexHandConfig dexhand_cfg; + ConfigHelper::getDexHandsConfig(dexhand_cfg); + for (int i = 0; i < dexhand_cfg.rh56dftp_dexhands().size(); i++) { + auto dexhand = dexhand_cfg.rh56dftp_dexhands(i); + auto id = dexhand.id(); if (devices_.count(id)) { LOG(ERROR) << "[DeviceManager]: Duplicate DexHand Device ID" << id; throw runtime_error("[DeviceManager]: Duplicate DexHand Device ID" + id); } - auto device = dev_factory_->create(node); - if (device == nullptr) { - throw std::runtime_error("[DeviceManager]: Factory returned nullptr for device ID: " + id); - } + std::cout << "DexHand[" << i << "]: " << id << std::endl; + auto device = dev_factory_->createFromConfig(dexhand); devices_[id] = device; std::get>(devices_[id])->init(); - LOG(INFO) << "[DeviceManager]: Init DexHand " << id << " Success"; } auto robot_node = dmgr_node.getChild("Robot"); @@ -282,37 +290,38 @@ void DeviceManager::init_devices_() { std::get>(devices_[id])->init(); LOG(INFO) << "[DeviceManager]: Init Robot " << id << " Success"; } - auto microphone_node = dmgr_node.getChild("Microphone"); - for (auto &node: microphone_node.getChildren()){ - string id = node.getAttrString("id"); - if (devices_.count(id)) - { - LOG(ERROR) << "[DeviceManager]: Duplicate Microphone Device ID" << id; - throw runtime_error("[DeviceManager]: Duplicate Microphone Device ID" + id); - } - auto device = dev_factory_->create(node); - if (device == nullptr) { - throw std::runtime_error("[DeviceManager]: Factory returned nullptr for device ID: " + id); + + config::MicroPhoneConfig micro_phone_config; + ConfigHelper::getMicroPhonesConfig(micro_phone_config); + for (int i = 0; i < micro_phone_config.ffmpeg_microphones().size(); i++) { + auto mic = micro_phone_config.ffmpeg_microphones(i); + auto id = mic.id(); + if (devices_.count(id)) { + LOG(ERROR) << "[DeviceManager]: Duplicate MicroPhone Device ID" << id; + throw runtime_error("[DeviceManager]: Duplicate MicroPhone Device ID" + id); } + std::cout << "DexHand[" << i << "]: " << id << std::endl; + auto device = dev_factory_->createFromConfig(mic); devices_[id] = device; std::get>(devices_[id])->init(); - LOG(INFO) << "[DeviceManager]: Init Microphone " << id << " Success"; } - auto speaker_node = dmgr_node.getChild("Speaker"); - for (auto &node: speaker_node.getChildren()){ - string id = node.getAttrString("id"); + + config::SpeakerConfig speaker_config; + ConfigHelper::getSpeakersConfig(speaker_config); + for (int i = 0; i < speaker_config.ffmpeg_speakers().size(); i++) { + auto speaker = speaker_config.ffmpeg_speakers(i); + auto id = speaker.id(); if (devices_.count(id)) { - LOG(ERROR) << "[DeviceManager]: Duplicate AbstractSpeaker Device ID" << id; - throw runtime_error("[DeviceManager]: Duplicate AbstractSpeaker Device ID" + id); - } - auto device = dev_factory_->create(node); - if (device == nullptr) { - throw std::runtime_error("[DeviceManager]: Factory returned nullptr for device ID: " + id); + LOG(ERROR) << "[DeviceManager]: Duplicate Speaker Device ID" << id; + throw runtime_error("[DeviceManager]: Duplicate Speaker Device ID" + id); } + std::cout << "DexHand[" << i << "]: " << id << std::endl; + auto device = dev_factory_->createFromConfig(speaker); devices_[id] = device; std::get>(devices_[id])->init(); - LOG(INFO) << "[DeviceManager]: Init Speaker " << id << " Success"; } + + auto biohead_node = dmgr_node.getChild("BioHead"); for (auto &node: biohead_node.getChildren()){ string id = node.getAttrString("id"); diff --git a/cmvr-es/devices/abstract_device.h b/cmvr-es/devices/abstract_device.h index b2904513..eff73bcd 100644 --- a/cmvr-es/devices/abstract_device.h +++ b/cmvr-es/devices/abstract_device.h @@ -18,6 +18,7 @@ namespace cmvr::device { class AbstractDevice { public: + AbstractDevice() = default; explicit AbstractDevice(const XmlNode& config) {cfg_ = config;} virtual ~AbstractDevice() = default; diff --git a/cmvr-es/devices/biohead/biohead_esp32/CMakeLists.txt b/cmvr-es/devices/biohead/biohead_esp32/CMakeLists.txt index 1e661167..61740c7a 100644 --- a/cmvr-es/devices/biohead/biohead_esp32/CMakeLists.txt +++ b/cmvr-es/devices/biohead/biohead_esp32/CMakeLists.txt @@ -7,6 +7,8 @@ target_include_directories(head_esp32 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) # 创建命名空间化的 ALIAS(建议使用项目命名空间) add_library(cmvr::device::head_esp32 ALIAS head_esp32) +install(TARGETS head_esp32 LIBRARY DESTINATION lib) + diff --git a/cmvr-es/devices/camera/abstract_camera.h b/cmvr-es/devices/camera/abstract_camera.h index ee47cdb4..dd1ceec1 100644 --- a/cmvr-es/devices/camera/abstract_camera.h +++ b/cmvr-es/devices/camera/abstract_camera.h @@ -5,6 +5,7 @@ #include #include "../abstract_device.h" #include +#include "cmvr/config/camera_config/camera_config.pb.h" namespace cmvr::device { struct Rs2Intrinsics @@ -44,6 +45,7 @@ namespace cmvr::device { PAUSED }; public: + AbstractCamera() = default; explicit AbstractCamera(const XmlNode &cfg): AbstractDevice(cfg) {} ~AbstractCamera() override = default; diff --git a/cmvr-es/devices/camera/realsense_camera/CMakeLists.txt b/cmvr-es/devices/camera/realsense_camera/CMakeLists.txt index f4bd2f37..f5fd8ba9 100644 --- a/cmvr-es/devices/camera/realsense_camera/CMakeLists.txt +++ b/cmvr-es/devices/camera/realsense_camera/CMakeLists.txt @@ -4,20 +4,13 @@ target_include_directories(realsense_camera PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) add_library(cmvr_es::device::realsense_camera ALIAS realsense_camera) # ✅ 命名空间别名 OK -# 查找 librealsense2 -find_package(realsense2 REQUIRED) # 链接 librealsense2 -target_link_libraries(realsense_camera PRIVATE realsense2::realsense2) - +target_link_libraries(realsense_camera PRIVATE realsense2) +install(TARGETS realsense_camera LIBRARY DESTINATION lib) # -------------------------------------------------------- # Unit test # -------------------------------------------------------- -find_package(glog REQUIRED) -find_package(protobuf REQUIRED) -find_package(PkgConfig REQUIRED) -find_package(fcl REQUIRED) -find_package(OpenCV REQUIRED) include_directories( ${CMAKE_SOURCE_DIR}/third_party/gtest/1.17.0/include @@ -37,8 +30,9 @@ target_link_libraries(realsense_camera_test PRIVATE cmvr_es::device::realsense_camera cmvr_es::device_manager - protobuf::libprotobuf - glog::glog + cmvr_es::common + protobuf + glog gtest gtest_main pthread diff --git a/cmvr-es/devices/camera/realsense_camera/include/realsense_camera.h b/cmvr-es/devices/camera/realsense_camera/include/realsense_camera.h index f38b3587..7fce04b7 100644 --- a/cmvr-es/devices/camera/realsense_camera/include/realsense_camera.h +++ b/cmvr-es/devices/camera/realsense_camera/include/realsense_camera.h @@ -16,6 +16,7 @@ namespace cmvr::device{ class RealsenseCamera final : public AbstractCamera { public: explicit RealsenseCamera(const XmlNode& config); + RealsenseCamera(const config::RealSenseCameraConfig& cam); ~RealsenseCamera() override; void init() override; @@ -112,6 +113,8 @@ namespace cmvr::device{ rs2_extrinsics Ec2d_; // rgb -> 深度 的外参 rs2_extrinsics Ed2c_; // rgb <- 深度 的外参 + + config::RealSenseCameraConfig camera_; }; } diff --git a/cmvr-es/devices/camera/realsense_camera/src/realsense_camera.cpp b/cmvr-es/devices/camera/realsense_camera/src/realsense_camera.cpp index 7d50dfd1..fbd7574a 100644 --- a/cmvr-es/devices/camera/realsense_camera/src/realsense_camera.cpp +++ b/cmvr-es/devices/camera/realsense_camera/src/realsense_camera.cpp @@ -121,6 +121,50 @@ RealsenseCamera::RealsenseCamera(const XmlNode& config) : AbstractCamera(config) } } +RealsenseCamera::RealsenseCamera(const config::RealSenseCameraConfig& camera):camera_(camera) +{ + serial_ = camera_.serialnumber(); + if (serial_.empty()){ + LOG(ERROR) << "[UVCCamera] (UVCCamera): empty device serial number"; + throw runtime_error("[UVCCamera] (UVCCamera): empty device serial number"); + } + fps_ = camera_.fps(); + width_ = camera_.width(); + height_ = camera_.height(); + buffer_size_ = camera_.buffer_size(); + + state_.fps = fps_; + state_.width = width_; + state_.height = height_; + auto camera_mode = camera_.camera_mode(); + if (camera_mode == config::CAMERA_MODE_PHOTO) { + mode_ = PHOTO_MODE; + } + else if (camera_mode == config::CAMERA_MODE_VIDEO){ + mode_ = VIDEO_MODE; + } + else { + LOG(ERROR) << "[UVCCamera] (UVCCamera): invalid argument mode"; + throw runtime_error("invalid argument mode"); + } + + auto stream_mode = camera_.stream_mode(); + if (stream_mode == config::STREAM_MODE_RGB) + { + stream_mode_ = RGBD_MODE; + } + else if (stream_mode == config::STREAM_MODE_RGBD) + { + stream_mode_ = COLOR_MODE; + } + else if (stream_mode == config::STREAM_MODE_DEPTH) + { + stream_mode_ = DEPTH_MODE; + } + + codec_ = camera_.codec(); +} + RealsenseCamera::~RealsenseCamera() { // 停止采集线程,释放资源 stop(); diff --git a/cmvr-es/devices/camera/uvc_camera/include/uvc_camera.h b/cmvr-es/devices/camera/uvc_camera/include/uvc_camera.h index 31153d74..9c5cd4a0 100644 --- a/cmvr-es/devices/camera/uvc_camera/include/uvc_camera.h +++ b/cmvr-es/devices/camera/uvc_camera/include/uvc_camera.h @@ -5,14 +5,14 @@ #ifndef CMVR_ES_UVC_CAMERA_H #define CMVR_ES_UVC_CAMERA_H -#include "../../../../utils/base/include/ring_buffer.h" -#include "../../abstract_camera.h" +#include "utils/base/include/ring_buffer.h" +#include "camera/abstract_camera.h" //使用ffmpeg来编码保存视频文件 #define USE_FFMPEG_ENCODER 1 #if USE_FFMPEG_ENCODER -#include "../../../speaker/ffmpeg_speaker/include/ffmpeg_ptr.h" +#include "speaker/ffmpeg_speaker/include/ffmpeg_ptr.h" #endif namespace cmvr::device { @@ -70,6 +70,7 @@ namespace cmvr::device { class UVCCamera final : public AbstractCamera { public: explicit UVCCamera(const XmlNode& config); + UVCCamera(const cmvr::config::UVCCameraConfig& camera); ~UVCCamera() override; void init() override; @@ -138,6 +139,9 @@ namespace cmvr::device { bool is_streaming_running = false; bool is_recording_running = false; int stream_count_ = 0; + + config::UVCCameraConfig camera_; + }; } diff --git a/cmvr-es/devices/camera/uvc_camera/src/uvc_camera.cpp b/cmvr-es/devices/camera/uvc_camera/src/uvc_camera.cpp index 8bf600e3..fe7f2c97 100644 --- a/cmvr-es/devices/camera/uvc_camera/src/uvc_camera.cpp +++ b/cmvr-es/devices/camera/uvc_camera/src/uvc_camera.cpp @@ -44,7 +44,35 @@ UVCCamera::UVCCamera(const XmlNode& config) : AbstractCamera(config) { throw runtime_error(e.what()); } } +UVCCamera::UVCCamera(const config::UVCCameraConfig& camera):camera_(camera) +{ + serial_ = camera_.usb(); + if (serial_.empty()){ + LOG(ERROR) << "[UVCCamera] (UVCCamera): empty device serial number"; + throw runtime_error("[UVCCamera] (UVCCamera): empty device serial number"); + } + fps_ = camera_.fps(); + width_ = camera_.width(); + height_ = camera_.height(); + buffer_size_ = camera_.buffer_size(); + state_.fps = fps_; + state_.width = width_; + state_.height = height_; + auto mode = camera_.camera_mode(); + if (mode == config::CAMERA_MODE_PHOTO) { + mode_ = PHOTO_MODE; + } + else if (mode == config::CAMERA_MODE_VIDEO){ + mode_ = VIDEO_MODE; + } + else { + LOG(ERROR) << "[UVCCamera] (UVCCamera): invalid argument mode"; + throw runtime_error("invalid argument mode"); + } + + codec_ = camera_.codec(); +} UVCCamera::~UVCCamera() { stop(); if (stream_thread_ && stream_thread_->joinable()) diff --git a/cmvr-es/devices/canbus/CMakeLists.txt b/cmvr-es/devices/canbus/CMakeLists.txt index 304bb3b4..76b2a460 100644 --- a/cmvr-es/devices/canbus/CMakeLists.txt +++ b/cmvr-es/devices/canbus/CMakeLists.txt @@ -1,7 +1,3 @@ -find_package(glog REQUIRED) -find_package(protobuf REQUIRED) - - add_library(canbus SHARED ${CMAKE_CURRENT_SOURCE_DIR}/can_client/socket/socket_can_client_raw.cc # ${CMAKE_CURRENT_SOURCE_DIR}/can_client/pcan/pcan_client.cc @@ -14,13 +10,10 @@ add_library(cmvr_es::device::canbus ALIAS canbus) target_link_libraries(canbus PRIVATE cmvr_es::proto - glog::glog -# protobuf::libprotobuf - -## proto-objects -## PUBLIC pcanbasic + glog ) +install(TARGETS canbus LIBRARY DESTINATION lib) # -------------------------------------------------------- # Unit test # -------------------------------------------------------- @@ -35,7 +28,7 @@ target_link_libraries(socket_can_client_raw_test gtest gtest_main pthread - glog::glog + glog cmvr_es::proto ) @@ -51,7 +44,7 @@ target_link_libraries(protocol_data_test gtest gtest_main pthread - glog::glog + glog cmvr_es::proto ) @@ -66,7 +59,7 @@ target_link_libraries(message_manager_test gtest gtest_main pthread - glog::glog + glog cmvr_es::proto ) @@ -82,7 +75,7 @@ target_link_libraries(can_sender_test gtest gtest_main pthread - glog::glog + glog cmvr_es::proto ) @@ -97,7 +90,7 @@ target_link_libraries(can_receiver_test gtest gtest_main pthread - glog::glog + glog cmvr_es::proto ) diff --git a/cmvr-es/devices/dexhand/abstract_dexhand.h b/cmvr-es/devices/dexhand/abstract_dexhand.h index 430d717f..803b322b 100644 --- a/cmvr-es/devices/dexhand/abstract_dexhand.h +++ b/cmvr-es/devices/dexhand/abstract_dexhand.h @@ -6,8 +6,8 @@ #define CMVR_ES_ABSTRACT_DEXHAND_H #pragma once -#include "../abstract_device.h" - +#include "devices/abstract_device.h" +#include "cmvr/config/dexhand_config/dexhand_config.pb.h" namespace cmvr::device{ // 单个触觉点数据(16位无符号整数) using TactilePoint = uint16_t; @@ -205,6 +205,7 @@ namespace cmvr::device{ }; class AbstractDexHand: public AbstractDevice{ public: + AbstractDexHand() = default; explicit AbstractDexHand(const XmlNode& cfg): AbstractDevice(cfg) {} ~AbstractDexHand() override = default; diff --git a/cmvr-es/devices/dexhand/rh56dftp_dexhand/CMakeLists.txt b/cmvr-es/devices/dexhand/rh56dftp_dexhand/CMakeLists.txt index 8b39c62a..adc2ce00 100644 --- a/cmvr-es/devices/dexhand/rh56dftp_dexhand/CMakeLists.txt +++ b/cmvr-es/devices/dexhand/rh56dftp_dexhand/CMakeLists.txt @@ -4,4 +4,6 @@ target_include_directories(rh56dftp_dexhand PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) add_library(cmvr_es::device::rh56dftp_dexhand ALIAS rh56dftp_dexhand) -target_link_libraries(rh56dftp_dexhand PRIVATE cmvr_es::hardware -lmodbus) \ No newline at end of file +target_link_libraries(rh56dftp_dexhand PRIVATE cmvr_es::hardware -lmodbus) + +install(TARGETS rh56dftp_dexhand LIBRARY DESTINATION lib) \ No newline at end of file diff --git a/cmvr-es/devices/dexhand/rh56dftp_dexhand/include/rh56dftp_dexhand.h b/cmvr-es/devices/dexhand/rh56dftp_dexhand/include/rh56dftp_dexhand.h index ccaccf55..43a59ddb 100644 --- a/cmvr-es/devices/dexhand/rh56dftp_dexhand/include/rh56dftp_dexhand.h +++ b/cmvr-es/devices/dexhand/rh56dftp_dexhand/include/rh56dftp_dexhand.h @@ -43,6 +43,7 @@ namespace cmvr::device { class RH56DFTPDexhand final : public AbstractDexHand{ public: explicit RH56DFTPDexhand(const XmlNode& cfg); + RH56DFTPDexhand(const config::RH56DFTPDexHandConfig& cfg); ~RH56DFTPDexhand() override; void init() override; @@ -70,6 +71,8 @@ namespace cmvr::device { std::string ip_address_; int port_; std::shared_ptr controller_; + + config::RH56DFTPDexHandConfig dexhandCfg_; }; } diff --git a/cmvr-es/devices/dexhand/rh56dftp_dexhand/src/rh56dftp_dexhand.cpp b/cmvr-es/devices/dexhand/rh56dftp_dexhand/src/rh56dftp_dexhand.cpp index 06d04730..764ee0c6 100644 --- a/cmvr-es/devices/dexhand/rh56dftp_dexhand/src/rh56dftp_dexhand.cpp +++ b/cmvr-es/devices/dexhand/rh56dftp_dexhand/src/rh56dftp_dexhand.cpp @@ -219,6 +219,22 @@ RH56DFTPDexhand::RH56DFTPDexhand(const XmlNode& cfg):AbstractDexHand(cfg) { } } + +RH56DFTPDexhand::RH56DFTPDexhand(const config::RH56DFTPDexHandConfig& cfg):dexhandCfg_(cfg) +{ + try { + id_ = dexhandCfg_.id(); + ip_address_ = dexhandCfg_.ip(); + port_ = dexhandCfg_.port(); + hand_tactile_sensors_.init(); + } + catch (const exception& e) { + LOG(ERROR) << "[RH56DFTPDexhand] ([RH56DFTPDexhand]): Failed to parse XML: " << e.what(); + } + +} + + RH56DFTPDexhand::~RH56DFTPDexhand() { } diff --git a/cmvr-es/devices/microphone/abstract_microphone.h b/cmvr-es/devices/microphone/abstract_microphone.h index 4e8e0159..fbdca1af 100644 --- a/cmvr-es/devices/microphone/abstract_microphone.h +++ b/cmvr-es/devices/microphone/abstract_microphone.h @@ -6,11 +6,12 @@ #define CMVR_ES_ABSTRACT_MICROPHONE_H #pragma once -#include "../abstract_device.h" - +#include "devices/abstract_device.h" +#include "cmvr/config/microphone_config/microphone_config.pb.h" namespace cmvr::device{ class AbstractMicrophone: public AbstractDevice { public: + AbstractMicrophone() = default; explicit AbstractMicrophone(const XmlNode &config): AbstractDevice(config) {} ~AbstractMicrophone() override = default; diff --git a/cmvr-es/devices/microphone/ffmpeg_microphone/CMakeLists.txt b/cmvr-es/devices/microphone/ffmpeg_microphone/CMakeLists.txt index 774224b6..87825571 100644 --- a/cmvr-es/devices/microphone/ffmpeg_microphone/CMakeLists.txt +++ b/cmvr-es/devices/microphone/ffmpeg_microphone/CMakeLists.txt @@ -7,4 +7,6 @@ add_library(cmvr_es::device::ffmpeg_microphone ALIAS ffmpeg_microphone) target_link_libraries(ffmpeg_microphone PRIVATE avfilter avdevice -) \ No newline at end of file +) + +install(TARGETS ffmpeg_microphone LIBRARY DESTINATION lib) \ No newline at end of file diff --git a/cmvr-es/devices/microphone/ffmpeg_microphone/include/ffmpeg_microphone.h b/cmvr-es/devices/microphone/ffmpeg_microphone/include/ffmpeg_microphone.h index 563df568..1898d138 100644 --- a/cmvr-es/devices/microphone/ffmpeg_microphone/include/ffmpeg_microphone.h +++ b/cmvr-es/devices/microphone/ffmpeg_microphone/include/ffmpeg_microphone.h @@ -7,10 +7,10 @@ #include #include #include -#include "../../abstract_microphone.h" +#include "microphone/abstract_microphone.h" #include -#include "../../../../utils/base/include/os.h" -#include "../../../speaker/ffmpeg_speaker/include/ffmpeg_ptr.h" +#include "utils/base/include/os.h" +#include "speaker/ffmpeg_speaker/include/ffmpeg_ptr.h" namespace cmvr::device { @@ -24,6 +24,7 @@ namespace cmvr::device { }; public: explicit ffmpegMicroPhone(const XmlNode& cfg); + ffmpegMicroPhone(const config::FFMpegMicroPhoneConfig& cfg); ~ffmpegMicroPhone() override; void init() override; void start() override; @@ -81,6 +82,8 @@ namespace cmvr::device { std::shared_ptr audio_thread_; std::mutex mtx_; + + config::FFMpegMicroPhoneConfig config_; }; } diff --git a/cmvr-es/devices/microphone/ffmpeg_microphone/src/ffmpeg_microphone.cpp b/cmvr-es/devices/microphone/ffmpeg_microphone/src/ffmpeg_microphone.cpp index 0baf6236..a78beff7 100644 --- a/cmvr-es/devices/microphone/ffmpeg_microphone/src/ffmpeg_microphone.cpp +++ b/cmvr-es/devices/microphone/ffmpeg_microphone/src/ffmpeg_microphone.cpp @@ -25,6 +25,23 @@ ffmpegMicroPhone::ffmpegMicroPhone(const XmlNode& cfg) : AbstractMicrophone(cfg) } } +ffmpegMicroPhone::ffmpegMicroPhone(const config::FFMpegMicroPhoneConfig& cfg):input_fmt_ctx(nullptr), input_codec_ctx(nullptr), input_frame(nullptr), + output_fmt_ctx(nullptr), output_fmt(nullptr), audio_st(nullptr), + audio_codec_ctx(nullptr), audio_codec(nullptr), swr_ctx(nullptr), + audio_frame(nullptr), is_recording(false), is_paused(false), + sample_rate_(44100), channels_(2), config_(cfg) +{ + id_ = config_.id(); + input_device_ = cfg_.getAttrString("alsa"); + channels_ = config_.channels(); + sample_rate_ = config_.samplerate(); + state_.volume = config_.volume(); + state_.is_initialized = false; + state_.is_running = false; + state_.is_error = false; + state_.error_message= ""; +} + ffmpegMicroPhone::~ffmpegMicroPhone() { stop(); } diff --git a/cmvr-es/devices/motor/CMakeLists.txt b/cmvr-es/devices/motor/CMakeLists.txt index 962f269f..532924d2 100644 --- a/cmvr-es/devices/motor/CMakeLists.txt +++ b/cmvr-es/devices/motor/CMakeLists.txt @@ -1,8 +1,5 @@ add_subdirectory(ti5_motor) -find_package(glog REQUIRED) -find_package(protobuf REQUIRED) - # -------------------------------------------------------- # Unit test # -------------------------------------------------------- @@ -27,6 +24,6 @@ target_link_libraries(motor_manager_test gtest gtest_main pthread - glog::glog + glog cmvr_es::proto ) diff --git a/cmvr-es/devices/motor/ti5_motor/CMakeLists.txt b/cmvr-es/devices/motor/ti5_motor/CMakeLists.txt index af430810..12121294 100644 --- a/cmvr-es/devices/motor/ti5_motor/CMakeLists.txt +++ b/cmvr-es/devices/motor/ti5_motor/CMakeLists.txt @@ -1,7 +1,3 @@ -find_package(glog REQUIRED) -find_package(protobuf REQUIRED) - - add_library(ti5motor SHARED ${CMAKE_CURRENT_SOURCE_DIR}/canopen/protocol/ti5_motor_sdo_response.cpp ${CMAKE_CURRENT_SOURCE_DIR}/canopen/protocol/ti5_motor_tpdo1.cpp @@ -20,6 +16,8 @@ add_library(cmvr_es::device::ti5motor ALIAS ti5motor) target_link_libraries(ti5motor PRIVATE cmvr_es::device::canbus - protobuf::libprotobuf - glog::glog -) \ No newline at end of file + protobuf + glog +) + +install(TARGETS ti5motor LIBRARY DESTINATION lib) \ No newline at end of file diff --git a/cmvr-es/devices/robot/c701/CMakeLists.txt b/cmvr-es/devices/robot/c701/CMakeLists.txt index f0628752..eccc7569 100644 --- a/cmvr-es/devices/robot/c701/CMakeLists.txt +++ b/cmvr-es/devices/robot/c701/CMakeLists.txt @@ -1,7 +1,3 @@ -find_package(glog REQUIRED) -find_package(protobuf REQUIRED) - - add_library(c701 SHARED ${CMAKE_CURRENT_SOURCE_DIR}/motor/motor_controller.cpp ${CMAKE_CURRENT_SOURCE_DIR}/motor/protocol/ti5_motor_sdo_response.cpp @@ -17,8 +13,8 @@ add_library(cmvr_es::robot::c701 ALIAS c701) target_link_libraries(c701 PRIVATE cmvr_es::device::canbus - protobuf::libprotobuf - glog::glog + protobuf + glog ) @@ -47,7 +43,7 @@ target_link_libraries(motor_controller_test gtest gtest_main pthread - glog::glog + glog cmvr_es::proto ) diff --git a/cmvr-es/devices/robot/humanoid_robot/CMakeLists.txt b/cmvr-es/devices/robot/humanoid_robot/CMakeLists.txt index 3c43821b..e80f5d7e 100644 --- a/cmvr-es/devices/robot/humanoid_robot/CMakeLists.txt +++ b/cmvr-es/devices/robot/humanoid_robot/CMakeLists.txt @@ -29,6 +29,7 @@ add_executable(humanoid_robot_test target_link_libraries(humanoid_robot_test PRIVATE cmvr_es::device_manager + cmvr_es::common cmvr_es::data_center osqp cmvr_es::device::humanoid_robot diff --git a/cmvr-es/devices/speaker/abstract_speaker.h b/cmvr-es/devices/speaker/abstract_speaker.h index bfda05ae..a6737922 100644 --- a/cmvr-es/devices/speaker/abstract_speaker.h +++ b/cmvr-es/devices/speaker/abstract_speaker.h @@ -6,11 +6,12 @@ #define CMVR_ES_ABSTRACT_SPEAKER_H #pragma once -#include "../abstract_device.h" - +#include "devices/abstract_device.h" +#include "cmvr/config/speaker_config/speaker_conifg.pb.h" namespace cmvr::device{ class AbstractSpeaker: public AbstractDevice { public: + AbstractSpeaker() = default; explicit AbstractSpeaker(const XmlNode &config): AbstractDevice(config) {} ~AbstractSpeaker() override = default; diff --git a/cmvr-es/devices/speaker/ffmpeg_speaker/CMakeLists.txt b/cmvr-es/devices/speaker/ffmpeg_speaker/CMakeLists.txt index a9c7dd75..3e2ddac9 100644 --- a/cmvr-es/devices/speaker/ffmpeg_speaker/CMakeLists.txt +++ b/cmvr-es/devices/speaker/ffmpeg_speaker/CMakeLists.txt @@ -4,4 +4,6 @@ target_include_directories(ffmpeg_speaker PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) add_library(cmvr_es::device::ffmpeg_speaker ALIAS ffmpeg_speaker) -target_link_libraries(ffmpeg_speaker PRIVATE -lpulse-simple -lpulse) \ No newline at end of file +target_link_libraries(ffmpeg_speaker PRIVATE -lpulse-simple -lpulse) + +install(TARGETS ffmpeg_speaker LIBRARY DESTINATION lib) \ No newline at end of file diff --git a/cmvr-es/devices/speaker/ffmpeg_speaker/include/ffmpeg_speaker.h b/cmvr-es/devices/speaker/ffmpeg_speaker/include/ffmpeg_speaker.h index 703c1fd1..05b1f1bb 100644 --- a/cmvr-es/devices/speaker/ffmpeg_speaker/include/ffmpeg_speaker.h +++ b/cmvr-es/devices/speaker/ffmpeg_speaker/include/ffmpeg_speaker.h @@ -22,6 +22,7 @@ namespace cmvr::device { class ffmpegSpeaker final : public AbstractSpeaker { public: explicit ffmpegSpeaker(const XmlNode& cfg); + ffmpegSpeaker(const config::FFMpegSpeakerConfig& cfg); ~ffmpegSpeaker() override; void init() override; @@ -66,6 +67,8 @@ namespace cmvr::device { // 音频时钟同步 std::atomic audio_pts_{0}; std::chrono::time_point playback_start_time_; + + config::FFMpegSpeakerConfig config_; }; } diff --git a/cmvr-es/devices/speaker/ffmpeg_speaker/src/ffmpeg_speaker.cpp b/cmvr-es/devices/speaker/ffmpeg_speaker/src/ffmpeg_speaker.cpp index 1b9b0ed4..585a1277 100644 --- a/cmvr-es/devices/speaker/ffmpeg_speaker/src/ffmpeg_speaker.cpp +++ b/cmvr-es/devices/speaker/ffmpeg_speaker/src/ffmpeg_speaker.cpp @@ -26,6 +26,23 @@ ffmpegSpeaker::ffmpegSpeaker(const XmlNode& cfg) : AbstractSpeaker(cfg) { } } +ffmpegSpeaker::ffmpegSpeaker(const config::FFMpegSpeakerConfig& cfg):config_(cfg) +{ + state_.is_initialized = false; + state_.is_running = false; + state_.is_paused = false; + try { + id_ = config_.id(); + memset(&sample_spec_, 0, sizeof(sample_spec_)); + // state_.volume = config_.volume(); + } + catch (const exception& e) { + LOG(ERROR) << "[ffmpegSpeaker] ([ffmpegSpeaker]): Failed to parse XML: " << e.what(); + } +} + + + ffmpegSpeaker::~ffmpegSpeaker() { { std::lock_guard lock(mtx_); diff --git a/cmvr-es/hardware/CMakeLists.txt b/cmvr-es/hardware/CMakeLists.txt index 040e8804..04e2acbd 100644 --- a/cmvr-es/hardware/CMakeLists.txt +++ b/cmvr-es/hardware/CMakeLists.txt @@ -9,3 +9,5 @@ target_include_directories(hardware PUBLIC target_link_libraries(hardware PRIVATE glog) add_library(cmvr_es::hardware ALIAS hardware) + +install(TARGETS hardware LIBRARY DESTINATION lib) diff --git a/cmvr-es/main.cpp b/cmvr-es/main.cpp index 96f9877c..73f3ad91 100644 --- a/cmvr-es/main.cpp +++ b/cmvr-es/main.cpp @@ -83,7 +83,7 @@ int main(int argc, char* argv[]) { return 1; } std::string exe_dir = dirname(exe_path); - config_path = exe_dir + "/../config/cabin_robot.xml"; + config_path = exe_dir + "/config/cabin_robot.xml"; std::cout << "Using default config path: " << config_path << std::endl; } else if (argc == 2){ diff --git a/cmvr-es/monitor/diskmonitor/CMakeLists.txt b/cmvr-es/monitor/diskmonitor/CMakeLists.txt index d15a8fba..34c44ff8 100644 --- a/cmvr-es/monitor/diskmonitor/CMakeLists.txt +++ b/cmvr-es/monitor/diskmonitor/CMakeLists.txt @@ -4,4 +4,6 @@ target_include_directories(disk_monitor PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(disk_monitor PRIVATE cmvr_es::utils) -add_library(cmvr_es::monitor::disk_monitor ALIAS disk_monitor) \ No newline at end of file +add_library(cmvr_es::monitor::disk_monitor ALIAS disk_monitor) + +install(TARGETS disk_monitor LIBRARY DESTINATION lib) \ No newline at end of file diff --git a/cmvr-es/monitor_manager/CMakeLists.txt b/cmvr-es/monitor_manager/CMakeLists.txt index 822cdafc..fdff2289 100644 --- a/cmvr-es/monitor_manager/CMakeLists.txt +++ b/cmvr-es/monitor_manager/CMakeLists.txt @@ -10,4 +10,6 @@ target_link_libraries(monitor_manager PRIVATE cmvr_es::monitor::disk_monitor ) -add_library(cmvr_es::monitor_manager ALIAS monitor_manager) \ No newline at end of file +add_library(cmvr_es::monitor_manager ALIAS monitor_manager) + +install(TARGETS monitor_manager LIBRARY DESTINATION lib) \ No newline at end of file diff --git a/cmvr-es/planner/CMakeLists.txt b/cmvr-es/planner/CMakeLists.txt index 1f572fd0..3eb13754 100644 --- a/cmvr-es/planner/CMakeLists.txt +++ b/cmvr-es/planner/CMakeLists.txt @@ -1,10 +1,3 @@ -find_package(Eigen3 3.3 REQUIRED NO_MODULE) -find_package(osqp REQUIRED) -find_package(OsqpEigen REQUIRED) -find_package(PkgConfig REQUIRED) -find_package(fcl REQUIRED) -find_package(tinyxml2 REQUIRED) -find_package(toppra REQUIRED) add_library(planner STATIC joint_space_planner/src/joint_space_planner.cpp @@ -15,15 +8,14 @@ add_library(planner STATIC target_include_directories(planner PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(planner PUBLIC - Eigen3::Eigen - OsqpEigen::OsqpEigen - ${TINYXML2_LIBRARIES} + OsqpEigen + tinyxml2 fcl - toppra::toppra + toppra ) add_library(cmvr_es::planner ALIAS planner) - +install(TARGETS planner LIBRARY DESTINATION lib) # -------------------------------------------------------- @@ -47,12 +39,10 @@ target_link_libraries(joint_space_planner_test gtest_main pthread glog - cmvr_es::proto + cmvr_es::proto ccd fcl - ${OpenCV_LIBS} - Eigen3::Eigen - OsqpEigen::OsqpEigen + OsqpEigen ) diff --git a/cmvr-es/service/CMakeLists.txt b/cmvr-es/service/CMakeLists.txt index 4885fef4..ad63551a 100644 --- a/cmvr-es/service/CMakeLists.txt +++ b/cmvr-es/service/CMakeLists.txt @@ -21,15 +21,11 @@ target_link_libraries(service PRIVATE ) add_library(cmvr_es::service ALIAS service) - +install(TARGETS service LIBRARY DESTINATION lib) # -------------------------------------------------------- # Unit test # -------------------------------------------------------- -find_package(glog REQUIRED) -find_package(protobuf REQUIRED) -find_package(PkgConfig REQUIRED) -find_package(fcl REQUIRED) find_package(OpenCV REQUIRED) include_directories( @@ -55,7 +51,7 @@ target_link_libraries(grpc_humanoid_robot_client_test gtest gtest_main pthread - glog::glog + glog cmvr_es::proto ccd fcl @@ -78,11 +74,10 @@ target_link_libraries(grpc_hlc_client_test gtest gtest_main pthread - glog::glog + glog cmvr_es::proto ccd fcl cmvr_es::device_manager - ${OpenCV_LIBS} ) diff --git a/cmvr-es/simulate/mujoco/mujoco_viewer/CMakeLists.txt b/cmvr-es/simulate/mujoco/mujoco_viewer/CMakeLists.txt index ae2d36bc..832abe79 100644 --- a/cmvr-es/simulate/mujoco/mujoco_viewer/CMakeLists.txt +++ b/cmvr-es/simulate/mujoco/mujoco_viewer/CMakeLists.txt @@ -19,10 +19,11 @@ target_link_libraries(mujoco_viewer PUBLIC ) add_library(cmvr_es::mujoco_viewer ALIAS mujoco_viewer) +install(TARGETS mujoco_viewer LIBRARY DESTINATION lib) + # -------------------------------------------------------- # Unit test # -------------------------------------------------------- -find_package(glog REQUIRED) find_package(Python3 COMPONENTS Interpreter Development REQUIRED) find_package(Python3 COMPONENTS NumPy) diff --git a/cmvr-es/utils/CMakeLists.txt b/cmvr-es/utils/CMakeLists.txt index af5bb008..faec46ab 100644 --- a/cmvr-es/utils/CMakeLists.txt +++ b/cmvr-es/utils/CMakeLists.txt @@ -1,6 +1,3 @@ -find_package(Eigen3 3.3 REQUIRED NO_MODULE) -find_package(PkgConfig REQUIRED) - add_library(utils STATIC base/src/thread_pool.cpp base/src/timer.cpp @@ -19,7 +16,6 @@ add_library(utils STATIC target_include_directories(utils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(utils PRIVATE - Eigen3::Eigen osqp OsqpEigen fcl @@ -28,3 +24,4 @@ target_link_libraries(utils PRIVATE ) add_library(cmvr_es::utils ALIAS utils) +install(TARGETS utils LIBRARY DESTINATION lib) diff --git a/dependency/x86/third_party/grpc/v1.76.0/bin/grpc_cpp_plugin b/dependency/x86/third_party/grpc/v1.76.0/bin/grpc_cpp_plugin index df8b9486..3576236b 100755 Binary files a/dependency/x86/third_party/grpc/v1.76.0/bin/grpc_cpp_plugin and b/dependency/x86/third_party/grpc/v1.76.0/bin/grpc_cpp_plugin differ diff --git a/output/bin/cmvr_es b/output/bin/cmvr_es index 7019d1d4..dd4a6eaa 100755 Binary files a/output/bin/cmvr_es and b/output/bin/cmvr_es differ diff --git a/output/bin/config/camera_config/camera_config.pb.txt b/output/bin/config/camera_config/camera_config.pb.txt index 5b7f4382..a33b8bc2 100644 --- a/output/bin/config/camera_config/camera_config.pb.txt +++ b/output/bin/config/camera_config/camera_config.pb.txt @@ -1,6 +1,25 @@ -id: "cam1" -usb: "/dev/video6" -width: 640 -height: 480 -fps: 30 -codec: "H265" +realsense_cameras { + id: "cam2" + serialNumber: "123456789012" + width: 1280 + height: 720 + fps: 30 + codec: "H265" + camera_mode: CAMERA_MODE_VIDEO + stream_mode: STREAM_MODE_RGBD + align_mode: ALIGN_MODE_COLOR + buffer_size: 30 + sync: true +} + +uvc_cameras { + id: "cam1" + usb: "/dev/video0" + width: 640 + height: 480 + fps: 30 + codec: "H265" + camera_mode: CAMERA_MODE_PHOTO + stream_mode: STREAM_MODE_RGB + buffer_size: 30 +} diff --git a/output/bin/srs_ik_test b/output/bin/srs_ik_test index 33ce1762..e83ab4ac 100755 Binary files a/output/bin/srs_ik_test and b/output/bin/srs_ik_test differ diff --git a/output/lib/libcommon.so b/output/lib/libcommon.so index 66b24bdd..afa30830 100644 Binary files a/output/lib/libcommon.so and b/output/lib/libcommon.so differ diff --git a/output/lib/libhumanoid_robot.so b/output/lib/libhumanoid_robot.so index ada85a45..4faa12bc 100644 Binary files a/output/lib/libhumanoid_robot.so and b/output/lib/libhumanoid_robot.so differ diff --git a/output/lib/libik_solver.so b/output/lib/libik_solver.so index ffd24214..c579308e 100644 Binary files a/output/lib/libik_solver.so and b/output/lib/libik_solver.so differ diff --git a/output/lib/libproto.so b/output/lib/libproto.so index 48cdc557..4fcab5c5 100644 Binary files a/output/lib/libproto.so and b/output/lib/libproto.so differ diff --git a/output/lib/libuvc_camera.so b/output/lib/libuvc_camera.so index ee04dad1..3acad81b 100644 Binary files a/output/lib/libuvc_camera.so and b/output/lib/libuvc_camera.so differ diff --git a/protos/cmvr/config/camera_config/camera_config.proto b/protos/cmvr/config/camera_config/camera_config.proto index 7596bd14..b83fc083 100644 --- a/protos/cmvr/config/camera_config/camera_config.proto +++ b/protos/cmvr/config/camera_config/camera_config.proto @@ -11,6 +11,7 @@ enum CameraMode { enum StreamMode { STREAM_MODE_RGB = 0; STREAM_MODE_RGBD = 1; + STREAM_MODE_DEPTH = 2; } enum AlignMode { @@ -19,7 +20,7 @@ enum AlignMode { } // RealSense摄像头 -message RealSenseCamera { +message RealSenseCameraConfig { string id = 1; string serialNumber = 2; int32 width = 3; @@ -29,19 +30,26 @@ message RealSenseCamera { CameraMode camera_mode = 7; StreamMode stream_mode = 8; AlignMode align_mode = 9; + int32 buffer_size = 10; + bool sync = 11; } // UVC摄像头 -message UVCCamera { +message UVCCameraConfig { string id = 1; string usb = 2; // 或者叫 device_path int32 width = 3; int32 height = 4; int32 fps = 5; string codec = 6; + CameraMode camera_mode = 7; + StreamMode stream_mode = 8; + int32 buffer_size = 9; } // 主配置消息 - 统一管理所有摄像头 message CameraConfig { - repeated UVCCamera uvc_cameras = 1; -} \ No newline at end of file + repeated UVCCameraConfig uvc_cameras = 1; + repeated RealSenseCameraConfig realsense_cameras = 2; +} + diff --git a/protos/cmvr/config/camera_config/uvc_camera_config.proto b/protos/cmvr/config/camera_config/uvc_camera_config.proto deleted file mode 100644 index e69de29b..00000000 diff --git a/protos/cmvr/config/dexhand_config/dexhand_config.proto b/protos/cmvr/config/dexhand_config/dexhand_config.proto new file mode 100644 index 00000000..e6a69a5b --- /dev/null +++ b/protos/cmvr/config/dexhand_config/dexhand_config.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package cmvr.config; + +message RH56DFTPDexHandConfig{ + string id = 1; + string ip = 2; + int32 port = 3; + +} + + + +message DexHandConfig{ + repeated RH56DFTPDexHandConfig rh56dftp_dexhands = 1; +} \ No newline at end of file diff --git a/protos/cmvr/config/microphone_config/microphone_config.proto b/protos/cmvr/config/microphone_config/microphone_config.proto new file mode 100644 index 00000000..56cdac05 --- /dev/null +++ b/protos/cmvr/config/microphone_config/microphone_config.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package cmvr.config; + +message FFMpegMicroPhoneConfig{ + string id = 1; + int32 channels = 2; + int32 sampleRate = 3; + int32 volume = 4; +} + +message MicroPhoneConfig{ + repeated FFMpegMicroPhoneConfig ffmpeg_microphones = 1; +} \ No newline at end of file diff --git a/protos/cmvr/config/speaker_config/speaker_conifg.proto b/protos/cmvr/config/speaker_config/speaker_conifg.proto new file mode 100644 index 00000000..b3478494 --- /dev/null +++ b/protos/cmvr/config/speaker_config/speaker_conifg.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +package cmvr.config; + +message FFMpegSpeakerConfig{ + string id = 1; +} + +message SpeakerConfig{ + repeated FFMpegSpeakerConfig ffmpeg_speakers = 1; +} \ No newline at end of file