feat: add proto config for camera&hand&micophone

This commit is contained in:
linbo 2026-01-21 16:30:13 +08:00
parent 6a060ead1d
commit 4085835277
62 changed files with 510 additions and 163 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@
/log
/third_party/osqp/
/third_party/OsqpEigen/
/output

View File

@ -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=$<TARGET_FILE:gRPC::grpc_cpp_plugin>"
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)

View File

@ -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
}

View File

@ -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
}

View File

@ -0,0 +1,6 @@
ffmpeg_microphones {
id: "mic1"
channels: 2
sampleRate: 44100
volume: 100
}

View File

@ -0,0 +1,3 @@
ffmpeg_speakers {
id: "spk1"
}

View File

@ -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 <class T>

View File

@ -1,3 +1,7 @@
#pragma once
#include "gflags/gflags.h"
DECLARE_string(pinocchio_qp_ik_solver_config_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);

View File

@ -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");
"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");

View File

@ -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

View File

@ -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
)

View File

@ -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
)

View File

@ -25,6 +25,8 @@ namespace cmvr::device {
template <typename DeviceType>
std::shared_ptr<DeviceType> create(const XmlNode& cfg);
template <typename DeviceType, typename ConfigType>
std::shared_ptr<DeviceType> createFromConfig(const ConfigType& cfg);
private:
std::shared_ptr<AbstractAGV> create_agv_(const XmlNode& cfg);
std::shared_ptr<AbstractBattery> create_battery_(const XmlNode& cfg);
@ -35,7 +37,6 @@ namespace cmvr::device {
std::shared_ptr<AbstractRobot> create_robot_(const XmlNode& cfg);
std::shared_ptr<AbstractSpeaker> create_speaker_(const XmlNode& cfg);
std::shared_ptr<AbstractBiohead> create_biohead_(const XmlNode& cfg);
};
}

View File

@ -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<AbstractSpeaker> DeviceFactory::create_speaker_(const XmlNode& c
return nullptr;
}
}
template std::shared_ptr<AbstractCamera> DeviceFactory::createFromConfig<AbstractCamera>(const config::UVCCameraConfig& cfg);
template std::shared_ptr<AbstractCamera> DeviceFactory::createFromConfig<AbstractCamera>(const config::RealSenseCameraConfig& cfg);
template std::shared_ptr<AbstractDexHand> DeviceFactory::createFromConfig<AbstractDexHand>(const config::RH56DFTPDexHandConfig& cfg);
template std::shared_ptr<AbstractMicrophone> DeviceFactory::createFromConfig<AbstractMicrophone>(const config::FFMpegMicroPhoneConfig& cfg);
template std::shared_ptr<AbstractSpeaker> DeviceFactory::createFromConfig<AbstractSpeaker>(const config::FFMpegSpeakerConfig& cfg);
template <typename DeviceType, typename ConfigType>
std::shared_ptr<DeviceType> DeviceFactory::createFromConfig(const ConfigType& cfg)
{
try {
if constexpr (std::is_same_v<DeviceType, AbstractCamera>)
{
if constexpr (std::is_same_v<ConfigType, config::UVCCameraConfig>)
{
return std::make_shared<UVCCamera>(cfg);
}
else if constexpr (std::is_same_v<ConfigType, config::RealSenseCameraConfig>)
{
return std::make_shared<RealsenseCamera>(cfg);
}
else
{
LOG(ERROR) << "[DeviceFactory]: Unsupported camera device type ";
throw runtime_error("[DeviceFactory]: Unsupported camera device type");
}
}
else if constexpr (std::is_same_v<DeviceType, AbstractDexHand>)
{
if constexpr (std::is_same_v<ConfigType, config::RH56DFTPDexHandConfig>)
{
return std::make_shared<RH56DFTPDexhand>(cfg);
}
else
{
LOG(ERROR) << "[DeviceFactory]: Unsupported dexhand device type ";
throw runtime_error("[DeviceFactory]: Unsupported dexhand device type");
}
}
else if constexpr (std::is_same_v<DeviceType, AbstractMicrophone>)
{
if constexpr (std::is_same_v<ConfigType, config::FFMpegMicroPhoneConfig>)
{
return std::make_shared<ffmpegMicroPhone>(cfg);
}
else
{
LOG(ERROR) << "[DeviceFactory]: Unsupported microphone device type ";
throw runtime_error("[DeviceFactory]: Unsupported microphone device type");
}
}
else if constexpr (std::is_same_v<DeviceType, AbstractSpeaker>)
{
if constexpr (std::is_same_v<ConfigType, config::FFMpegSpeakerConfig>)
{
return std::make_shared<ffmpegSpeaker>(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;
}
}

View File

@ -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<AbstractMonitor> 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<AbstractCamera>(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<AbstractCamera,config::UVCCameraConfig>(cam);
devices_[id] = device;
std::get<std::shared_ptr<AbstractCamera>>(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<AbstractCamera,config::RealSenseCameraConfig>(cam);
devices_[id] = device;
std::get<std::shared_ptr<AbstractCamera>>(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<AbstractDexHand>(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<AbstractDexHand,config::RH56DFTPDexHandConfig>(dexhand);
devices_[id] = device;
std::get<std::shared_ptr<AbstractDexHand>>(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<std::shared_ptr<AbstractRobot>>(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<AbstractMicrophone>(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<AbstractMicrophone,config::FFMpegMicroPhoneConfig>(mic);
devices_[id] = device;
std::get<std::shared_ptr<AbstractMicrophone>>(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<AbstractSpeaker>(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<AbstractSpeaker,config::FFMpegSpeakerConfig>(speaker);
devices_[id] = device;
std::get<std::shared_ptr<AbstractSpeaker>>(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");

View File

@ -18,6 +18,7 @@
namespace cmvr::device {
class AbstractDevice {
public:
AbstractDevice() = default;
explicit AbstractDevice(const XmlNode& config) {cfg_ = config;}
virtual ~AbstractDevice() = default;

View File

@ -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)

View File

@ -5,6 +5,7 @@
#include <opencv2/opencv.hpp>
#include "../abstract_device.h"
#include <Eigen/Core>
#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;

View File

@ -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

View File

@ -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_;
};
}

View File

@ -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();

View File

@ -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_;
};
}

View File

@ -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())

View File

@ -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
)

View File

@ -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;

View File

@ -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)
target_link_libraries(rh56dftp_dexhand PRIVATE cmvr_es::hardware -lmodbus)
install(TARGETS rh56dftp_dexhand LIBRARY DESTINATION lib)

View File

@ -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<ModbusController> controller_;
config::RH56DFTPDexHandConfig dexhandCfg_;
};
}

View File

@ -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() {
}

View File

@ -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;

View File

@ -7,4 +7,6 @@ add_library(cmvr_es::device::ffmpeg_microphone ALIAS ffmpeg_microphone)
target_link_libraries(ffmpeg_microphone PRIVATE
avfilter
avdevice
)
)
install(TARGETS ffmpeg_microphone LIBRARY DESTINATION lib)

View File

@ -7,10 +7,10 @@
#include <mutex>
#include <queue>
#include <condition_variable>
#include "../../abstract_microphone.h"
#include "microphone/abstract_microphone.h"
#include <boost/lockfree/spsc_queue.hpp>
#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<std::thread> audio_thread_;
std::mutex mtx_;
config::FFMpegMicroPhoneConfig config_;
};
}

View File

@ -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();
}

View File

@ -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
)

View File

@ -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
)
protobuf
glog
)
install(TARGETS ti5motor LIBRARY DESTINATION lib)

View File

@ -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
)

View File

@ -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

View File

@ -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;

View File

@ -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)
target_link_libraries(ffmpeg_speaker PRIVATE -lpulse-simple -lpulse)
install(TARGETS ffmpeg_speaker LIBRARY DESTINATION lib)

View File

@ -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<int64_t> audio_pts_{0};
std::chrono::time_point<std::chrono::steady_clock> playback_start_time_;
config::FFMpegSpeakerConfig config_;
};
}

View File

@ -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<std::mutex> lock(mtx_);

View File

@ -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)

View File

@ -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){

View File

@ -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)
add_library(cmvr_es::monitor::disk_monitor ALIAS disk_monitor)
install(TARGETS disk_monitor LIBRARY DESTINATION lib)

View File

@ -10,4 +10,6 @@ target_link_libraries(monitor_manager PRIVATE
cmvr_es::monitor::disk_monitor
)
add_library(cmvr_es::monitor_manager ALIAS monitor_manager)
add_library(cmvr_es::monitor_manager ALIAS monitor_manager)
install(TARGETS monitor_manager LIBRARY DESTINATION lib)

View File

@ -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
)

View File

@ -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}
)

View File

@ -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)

View File

@ -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)

Binary file not shown.

View File

@ -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
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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;
}
repeated UVCCameraConfig uvc_cameras = 1;
repeated RealSenseCameraConfig realsense_cameras = 2;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -0,0 +1,10 @@
syntax = "proto3";
package cmvr.config;
message FFMpegSpeakerConfig{
string id = 1;
}
message SpeakerConfig{
repeated FFMpegSpeakerConfig ffmpeg_speakers = 1;
}