update
This commit is contained in:
parent
1f94a92947
commit
f47a93c21f
@ -32,47 +32,47 @@
|
|||||||
<!-- <LeftArm id="left_arm" devtype="ti5Robot" />-->
|
<!-- <LeftArm id="left_arm" devtype="ti5Robot" />-->
|
||||||
<!-- <RightArm />-->
|
<!-- <RightArm />-->
|
||||||
<!-- <Neck/>-->
|
<!-- <Neck/>-->
|
||||||
<Humanoid id="hc01" dof="14"
|
<!-- <Humanoid id="hc01" dof="14"-->
|
||||||
urdf="/home/lgv/cmvr/cmvr-es/config/robot_description/hc_description/dual_arm.urdf"
|
<!-- urdf="/home/tankaitao/cmvr-lgv/cmvr-es/config/robot_description/hc_description/dual_arm.urdf"-->
|
||||||
baseLink="PELVIS_S"
|
<!-- baseLink="PELVIS_S"-->
|
||||||
jointNames="L_SHOULDER_P,L_SHOULDER_R,L_SHOULDER_Y,L_ELBOW_R,L_WRIST_P,L_WRIST_Y,L_WRIST_R,R_SHOULDER_P,R_SHOULDER_R,R_SHOULDER_Y,R_ELBOW_R,R_WRIST_P,R_WRIST_Y,R_WRIST_R"
|
<!-- jointNames="L_SHOULDER_P,L_SHOULDER_R,L_SHOULDER_Y,L_ELBOW_R,L_WRIST_P,L_WRIST_Y,L_WRIST_R,R_SHOULDER_P,R_SHOULDER_R,R_SHOULDER_Y,R_ELBOW_R,R_WRIST_P,R_WRIST_Y,R_WRIST_R"-->
|
||||||
linkNames="PELVIS_S,L_SHOULDER_P_S,L_SHOULDER_R_S,L_SHOULDER_Y_S,L_ELBOW_R_S,L_WRIST_P_S,L_WRIST_Y_S,L_WRIST_R_S,R_SHOULDER_P_S,R_SHOULDER_R_S,R_SHOULDER_Y_S,R_ELBOW_R_S,R_WRIST_P_S,R_WRIST_Y_S,R_WRIST_R_S,R_FINGER_TIP,R_CAM"
|
<!-- linkNames="PELVIS_S,L_SHOULDER_P_S,L_SHOULDER_R_S,L_SHOULDER_Y_S,L_ELBOW_R_S,L_WRIST_P_S,L_WRIST_Y_S,L_WRIST_R_S,R_SHOULDER_P_S,R_SHOULDER_R_S,R_SHOULDER_Y_S,R_ELBOW_R_S,R_WRIST_P_S,R_WRIST_Y_S,R_WRIST_R_S,R_FINGER_TIP,R_CAM"-->
|
||||||
bufferSize="50"
|
<!-- bufferSize="50"-->
|
||||||
verbose="false">
|
<!-- verbose="false">-->
|
||||||
<CanManger id="" devId="">
|
<!-- <CanManger id="" devId="">-->
|
||||||
<LeftArmCan id = " " devId = " " channelId ="0" enable="true" toolFrame="L_FINGER_TIP">
|
<!-- <LeftArmCan id = " " devId = " " channelId ="0" enable="false" toolFrame="L_FINGER_TIP">-->
|
||||||
<Motor id="23" jointName="L_SHOULDER_P" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>
|
<!-- <Motor id="23" jointName="L_SHOULDER_P" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>-->
|
||||||
<Motor id="24" jointName="L_SHOULDER_R" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>
|
<!-- <Motor id="24" jointName="L_SHOULDER_R" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>-->
|
||||||
<Motor id="25" jointName="L_SHOULDER_Y" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>
|
<!-- <Motor id="25" jointName="L_SHOULDER_Y" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>-->
|
||||||
<Motor id="26" jointName="L_ELBOW_R" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>
|
<!-- <Motor id="26" jointName="L_ELBOW_R" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>-->
|
||||||
<Motor id="27" jointName="L_WRIST_P" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>
|
<!-- <Motor id="27" jointName="L_WRIST_P" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>-->
|
||||||
<Motor id="28" jointName="L_WRIST_Y" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>
|
<!-- <Motor id="28" jointName="L_WRIST_Y" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>-->
|
||||||
<Motor id="1" jointName="L_WRIST_R" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>
|
<!-- <Motor id="1" jointName="L_WRIST_R" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>-->
|
||||||
</LeftArmCan>
|
<!-- </LeftArmCan>-->
|
||||||
<RightArmCan id = " " devId = " " channelId ="1" enable="true" toolFrame="R_FINGER_TIP">
|
<!-- <RightArmCan id = " " devId = " " channelId ="1" enable="false" toolFrame="R_FINGER_TIP">-->
|
||||||
<Motor id="16" jointName="R_SHOULDER_P" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>
|
<!-- <Motor id="16" jointName="R_SHOULDER_P" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>-->
|
||||||
<Motor id="17" jointName="R_SHOULDER_R" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>
|
<!-- <Motor id="17" jointName="R_SHOULDER_R" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>-->
|
||||||
<Motor id="18" jointName="R_SHOULDER_Y" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>
|
<!-- <Motor id="18" jointName="R_SHOULDER_Y" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>-->
|
||||||
<Motor id="19" jointName="R_ELBOW_R" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>
|
<!-- <Motor id="19" jointName="R_ELBOW_R" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>-->
|
||||||
<Motor id="20" jointName="R_WRIST_P" limitQLb="-3.14" limitQUb="3.14" limitQd="3.0"/>
|
<!-- <Motor id="20" jointName="R_WRIST_P" limitQLb="-3.14" limitQUb="3.14" limitQd="3.0"/>-->
|
||||||
<Motor id="21" jointName="R_WRIST_Y" limitQLb="-1.102" limitQUb="1.02" limitQd="3.0"/>
|
<!-- <Motor id="21" jointName="R_WRIST_Y" limitQLb="-1.102" limitQUb="1.02" limitQd="3.0"/>-->
|
||||||
<Motor id="22" jointName="R_WRIST_R" limitQLb="-0.293" limitQUb="1.57079" limitQd="3.0"/>
|
<!-- <Motor id="22" jointName="R_WRIST_R" limitQLb="-0.293" limitQUb="1.57079" limitQd="3.0"/>-->
|
||||||
</RightArmCan>
|
<!-- </RightArmCan>-->
|
||||||
<HeadCan id = " " devId = " " channelId ="2" enable="false">
|
<!-- <HeadCan id = " " devId = " " channelId ="2" enable="false">-->
|
||||||
<Motor id="32" jointName="HEAD_Y" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>
|
<!-- <Motor id="32" jointName="HEAD_Y" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>-->
|
||||||
<Motor id="30" jointName="HEAD_P" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>
|
<!-- <Motor id="30" jointName="HEAD_P" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>-->
|
||||||
<Motor id="31" jointName="HEAD_R" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>
|
<!-- <Motor id="31" jointName="HEAD_R" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>-->
|
||||||
</HeadCan>
|
<!-- </HeadCan>-->
|
||||||
<WaistCan id = " " devId = " " channelId ="3" enable="false">
|
<!-- <WaistCan id = " " devId = " " channelId ="3" enable="false">-->
|
||||||
<Motor id="14" jointName="WAIST_Y" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>
|
<!-- <Motor id="14" jointName="WAIST_Y" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>-->
|
||||||
<Motor id="15" jointName="WAIST_P" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>
|
<!-- <Motor id="15" jointName="WAIST_P" limitQLb="3.14" limitQUb="3.14" limitQd="3.0"/>-->
|
||||||
</WaistCan>
|
<!-- </WaistCan>-->
|
||||||
</CanManger>
|
<!-- </CanManger>-->
|
||||||
|
|
||||||
</Humanoid>
|
<!-- </Humanoid>-->
|
||||||
<AuboRobot id="hc02" ip="127.0.0.1" port="30004" username="aubo" password="123456">
|
<!-- <AuboRobot id="hc02" ip="127.0.0.1" port="30004" username="aubo" password="123456">-->
|
||||||
|
|
||||||
</AuboRobot>
|
<!-- </AuboRobot>-->
|
||||||
</Robot>
|
</Robot>
|
||||||
|
|
||||||
<BioHead>
|
<BioHead>
|
||||||
|
|||||||
@ -196,7 +196,7 @@ message SpeakStop {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 表情控制 - 高兴
|
// 表情控制 - 微笑
|
||||||
message Happy {
|
message Happy {
|
||||||
message Request {
|
message Request {
|
||||||
CommandHeader.Request header = 1; // 通用命令头
|
CommandHeader.Request header = 1; // 通用命令头
|
||||||
@ -220,7 +220,7 @@ message Surprise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//表情控制-疲惫
|
||||||
message ExpressionTired {
|
message ExpressionTired {
|
||||||
message Request {
|
message Request {
|
||||||
CommandHeader.Request header = 1;
|
CommandHeader.Request header = 1;
|
||||||
@ -231,4 +231,40 @@ message ExpressionTired {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//表情控制-愤怒
|
||||||
|
message ExpressionAngry {
|
||||||
|
message Request {
|
||||||
|
CommandHeader.Request header = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Feedback {
|
||||||
|
CommandHeader.Feedback header = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//表情控制-悲伤
|
||||||
|
message ExpressionSadness {
|
||||||
|
message Request {
|
||||||
|
CommandHeader.Request header = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Feedback {
|
||||||
|
CommandHeader.Feedback header = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//表情控制-打哈欠
|
||||||
|
message ExpressionYawn {
|
||||||
|
message Request {
|
||||||
|
CommandHeader.Request header = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Feedback {
|
||||||
|
CommandHeader.Feedback header = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,17 @@ service BioHeadService {
|
|||||||
|
|
||||||
rpc ExpressionTired(ExpressionTired.Request) returns (ExpressionTired.Feedback){};
|
rpc ExpressionTired(ExpressionTired.Request) returns (ExpressionTired.Feedback){};
|
||||||
|
|
||||||
|
rpc ExpressionAngry(ExpressionAngry.Request) returns (ExpressionAngry.Feedback){};
|
||||||
|
|
||||||
|
rpc ExpressionSadness(ExpressionSadness.Request) returns (ExpressionSadness.Feedback){};
|
||||||
|
|
||||||
|
rpc ExpressionYawn(ExpressionYawn.Request) returns (ExpressionYawn.Feedback){};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -68,9 +68,12 @@ namespace cmvr::device {
|
|||||||
virtual void speakstart(){};
|
virtual void speakstart(){};
|
||||||
virtual void speakstop(){};
|
virtual void speakstop(){};
|
||||||
|
|
||||||
virtual void expressionHappy() {}; // 高兴
|
virtual void expressionHappy() {};
|
||||||
virtual void expressionSurprised() {}; // 惊讶
|
virtual void expressionSurprised() {};
|
||||||
virtual void expressionTired() {}; // 困倦(疲惫)
|
virtual void expressionTired() {};
|
||||||
|
virtual void expressionAngry() {};
|
||||||
|
virtual void expressionSadness() {};
|
||||||
|
virtual void expressionYawn() {};
|
||||||
|
|
||||||
FacialExpressionState expression_state_;
|
FacialExpressionState expression_state_;
|
||||||
std::atomic<bool> emergency_stop_requested = false;
|
std::atomic<bool> emergency_stop_requested = false;
|
||||||
|
|||||||
@ -32,6 +32,9 @@ namespace cmvr::device {
|
|||||||
void expressionHappy()override;
|
void expressionHappy()override;
|
||||||
void expressionSurprised()override;
|
void expressionSurprised()override;
|
||||||
void expressionTired()override;
|
void expressionTired()override;
|
||||||
|
void expressionAngry() override;
|
||||||
|
void expressionSadness()override;
|
||||||
|
void expressionYawn()override;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -610,6 +610,36 @@ void BioHeadRobot::expressionHappy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
serial_->sendRawServoData(raw_data);
|
serial_->sendRawServoData(raw_data);
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||||
|
|
||||||
|
// 设备64角度(10通道)
|
||||||
|
const std::vector<double> device_64_neutral = {90, 90, 90, 90, 90, 90, 90, 90, 90, 90};
|
||||||
|
// 设备65角度(10通道)
|
||||||
|
const std::vector<double> device_65_neutral = {90, 90, 90, 90, 90, 90, 90, 90, 90, 90};
|
||||||
|
|
||||||
|
std::vector<uint8_t> raw_data_neutral;
|
||||||
|
|
||||||
|
// 下发设备64的10个通道(0~9)
|
||||||
|
for (int ch = 0; ch < 10; ++ch) {
|
||||||
|
uint8_t angle = static_cast<uint8_t>(std::round(device_64_neutral[ch]));
|
||||||
|
raw_data_neutral.push_back(64); // 地址
|
||||||
|
raw_data_neutral.push_back(ch); // 通道号
|
||||||
|
raw_data_neutral.push_back(angle); // 角度
|
||||||
|
raw_data_neutral.push_back(step_ms & 0xFF); // 低字节
|
||||||
|
raw_data_neutral.push_back((step_ms >> 8) & 0xFF); // 高字节
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下发设备65的10个通道(0~9)
|
||||||
|
for (int ch = 0; ch < 10; ++ch) {
|
||||||
|
uint8_t angle = static_cast<uint8_t>(std::round(device_65_neutral[ch]));
|
||||||
|
raw_data_neutral.push_back(65); // 地址
|
||||||
|
raw_data_neutral.push_back(ch); // 通道号
|
||||||
|
raw_data_neutral.push_back(angle); // 角度
|
||||||
|
raw_data_neutral.push_back(step_ms & 0xFF); // 低字节
|
||||||
|
raw_data_neutral.push_back((step_ms >> 8) & 0xFF); // 高字节
|
||||||
|
}
|
||||||
|
|
||||||
|
serial_->sendRawServoData(raw_data_neutral);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -708,7 +738,194 @@ void BioHeadRobot::expressionTired() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BioHeadRobot::expressionAngry() {
|
||||||
|
const int step_ms = 200;
|
||||||
|
|
||||||
|
// 设备64角度(10通道)
|
||||||
|
const std::vector<double> device_64_angles = {90, 90, 90, 90, 40, 120, 125, 50, 90, 90};
|
||||||
|
// 设备65角度(10通道)
|
||||||
|
const std::vector<double> device_65_angles = {90, 85, 95, 100, 90, 105, 80, 110, 85, 95};
|
||||||
|
|
||||||
|
std::vector<uint8_t> raw_data;
|
||||||
|
|
||||||
|
// 下发设备64的10个通道(0~9)
|
||||||
|
for (int ch = 0; ch < 10; ++ch) {
|
||||||
|
uint8_t angle = static_cast<uint8_t>(std::round(device_64_angles[ch]));
|
||||||
|
raw_data.push_back(64); // 地址
|
||||||
|
raw_data.push_back(ch); // 通道号
|
||||||
|
raw_data.push_back(angle); // 角度
|
||||||
|
raw_data.push_back(step_ms & 0xFF); // 低字节
|
||||||
|
raw_data.push_back((step_ms >> 8) & 0xFF); // 高字节
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下发设备65的10个通道(0~9)
|
||||||
|
for (int ch = 0; ch < 10; ++ch) {
|
||||||
|
uint8_t angle = static_cast<uint8_t>(std::round(device_65_angles[ch]));
|
||||||
|
raw_data.push_back(65); // 地址
|
||||||
|
raw_data.push_back(ch); // 通道号
|
||||||
|
raw_data.push_back(angle); // 角度
|
||||||
|
raw_data.push_back(step_ms & 0xFF); // 低字节
|
||||||
|
raw_data.push_back((step_ms >> 8) & 0xFF); // 高字节
|
||||||
|
}
|
||||||
|
|
||||||
|
serial_->sendRawServoData(raw_data);
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||||
|
|
||||||
|
// 设备64角度(10通道)
|
||||||
|
const std::vector<double> device_64_neutral = {90, 90, 90, 90, 90, 90, 90, 90, 90, 90};
|
||||||
|
// 设备65角度(10通道)
|
||||||
|
const std::vector<double> device_65_neutral = {90, 90, 90, 90, 90, 90, 90, 90, 90, 90};
|
||||||
|
|
||||||
|
std::vector<uint8_t> raw_data_neutral;
|
||||||
|
|
||||||
|
// 下发设备64的10个通道(0~9)
|
||||||
|
for (int ch = 0; ch < 10; ++ch) {
|
||||||
|
uint8_t angle = static_cast<uint8_t>(std::round(device_64_neutral[ch]));
|
||||||
|
raw_data_neutral.push_back(64); // 地址
|
||||||
|
raw_data_neutral.push_back(ch); // 通道号
|
||||||
|
raw_data_neutral.push_back(angle); // 角度
|
||||||
|
raw_data_neutral.push_back(step_ms & 0xFF); // 低字节
|
||||||
|
raw_data_neutral.push_back((step_ms >> 8) & 0xFF); // 高字节
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下发设备65的10个通道(0~9)
|
||||||
|
for (int ch = 0; ch < 10; ++ch) {
|
||||||
|
uint8_t angle = static_cast<uint8_t>(std::round(device_65_neutral[ch]));
|
||||||
|
raw_data_neutral.push_back(65); // 地址
|
||||||
|
raw_data_neutral.push_back(ch); // 通道号
|
||||||
|
raw_data_neutral.push_back(angle); // 角度
|
||||||
|
raw_data_neutral.push_back(step_ms & 0xFF); // 低字节
|
||||||
|
raw_data_neutral.push_back((step_ms >> 8) & 0xFF); // 高字节
|
||||||
|
}
|
||||||
|
|
||||||
|
serial_->sendRawServoData(raw_data_neutral);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BioHeadRobot::expressionSadness() {
|
||||||
|
const int step_ms = 200;
|
||||||
|
|
||||||
|
// 设备64角度(10通道)
|
||||||
|
const std::vector<double> device_64_angles = {90, 90, 90, 90, 40, 120, 125, 50, 90, 90};
|
||||||
|
// 设备65角度(10通道)
|
||||||
|
const std::vector<double> device_65_angles = {90, 85, 95, 100, 90, 105, 80, 110, 85, 95};
|
||||||
|
|
||||||
|
std::vector<uint8_t> raw_data;
|
||||||
|
|
||||||
|
// 下发设备64的10个通道(0~9)
|
||||||
|
for (int ch = 0; ch < 10; ++ch) {
|
||||||
|
uint8_t angle = static_cast<uint8_t>(std::round(device_64_angles[ch]));
|
||||||
|
raw_data.push_back(64); // 地址
|
||||||
|
raw_data.push_back(ch); // 通道号
|
||||||
|
raw_data.push_back(angle); // 角度
|
||||||
|
raw_data.push_back(step_ms & 0xFF); // 低字节
|
||||||
|
raw_data.push_back((step_ms >> 8) & 0xFF); // 高字节
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下发设备65的10个通道(0~9)
|
||||||
|
for (int ch = 0; ch < 10; ++ch) {
|
||||||
|
uint8_t angle = static_cast<uint8_t>(std::round(device_65_angles[ch]));
|
||||||
|
raw_data.push_back(65); // 地址
|
||||||
|
raw_data.push_back(ch); // 通道号
|
||||||
|
raw_data.push_back(angle); // 角度
|
||||||
|
raw_data.push_back(step_ms & 0xFF); // 低字节
|
||||||
|
raw_data.push_back((step_ms >> 8) & 0xFF); // 高字节
|
||||||
|
}
|
||||||
|
|
||||||
|
serial_->sendRawServoData(raw_data);
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||||
|
|
||||||
|
// 设备64角度(10通道)
|
||||||
|
const std::vector<double> device_64_neutral = {90, 90, 90, 90, 90, 90, 90, 90, 90, 90};
|
||||||
|
// 设备65角度(10通道)
|
||||||
|
const std::vector<double> device_65_neutral = {90, 90, 90, 90, 90, 90, 90, 90, 90, 90};
|
||||||
|
|
||||||
|
std::vector<uint8_t> raw_data_neutral;
|
||||||
|
|
||||||
|
// 下发设备64的10个通道(0~9)
|
||||||
|
for (int ch = 0; ch < 10; ++ch) {
|
||||||
|
uint8_t angle = static_cast<uint8_t>(std::round(device_64_neutral[ch]));
|
||||||
|
raw_data_neutral.push_back(64); // 地址
|
||||||
|
raw_data_neutral.push_back(ch); // 通道号
|
||||||
|
raw_data_neutral.push_back(angle); // 角度
|
||||||
|
raw_data_neutral.push_back(step_ms & 0xFF); // 低字节
|
||||||
|
raw_data_neutral.push_back((step_ms >> 8) & 0xFF); // 高字节
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下发设备65的10个通道(0~9)
|
||||||
|
for (int ch = 0; ch < 10; ++ch) {
|
||||||
|
uint8_t angle = static_cast<uint8_t>(std::round(device_65_neutral[ch]));
|
||||||
|
raw_data_neutral.push_back(65); // 地址
|
||||||
|
raw_data_neutral.push_back(ch); // 通道号
|
||||||
|
raw_data_neutral.push_back(angle); // 角度
|
||||||
|
raw_data_neutral.push_back(step_ms & 0xFF); // 低字节
|
||||||
|
raw_data_neutral.push_back((step_ms >> 8) & 0xFF); // 高字节
|
||||||
|
}
|
||||||
|
|
||||||
|
serial_->sendRawServoData(raw_data_neutral);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BioHeadRobot::expressionYawn() {
|
||||||
|
const int step_ms = 200;
|
||||||
|
|
||||||
|
// 设备64角度(10通道)
|
||||||
|
const std::vector<double> device_64_angles = {90, 90, 90, 90, 40, 120, 125, 50, 90, 90};
|
||||||
|
// 设备65角度(10通道)
|
||||||
|
const std::vector<double> device_65_angles = {90, 85, 95, 100, 90, 105, 80, 110, 85, 95};
|
||||||
|
|
||||||
|
std::vector<uint8_t> raw_data;
|
||||||
|
|
||||||
|
// 下发设备64的10个通道(0~9)
|
||||||
|
for (int ch = 0; ch < 10; ++ch) {
|
||||||
|
uint8_t angle = static_cast<uint8_t>(std::round(device_64_angles[ch]));
|
||||||
|
raw_data.push_back(64); // 地址
|
||||||
|
raw_data.push_back(ch); // 通道号
|
||||||
|
raw_data.push_back(angle); // 角度
|
||||||
|
raw_data.push_back(step_ms & 0xFF); // 低字节
|
||||||
|
raw_data.push_back((step_ms >> 8) & 0xFF); // 高字节
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下发设备65的10个通道(0~9)
|
||||||
|
for (int ch = 0; ch < 10; ++ch) {
|
||||||
|
uint8_t angle = static_cast<uint8_t>(std::round(device_65_angles[ch]));
|
||||||
|
raw_data.push_back(65); // 地址
|
||||||
|
raw_data.push_back(ch); // 通道号
|
||||||
|
raw_data.push_back(angle); // 角度
|
||||||
|
raw_data.push_back(step_ms & 0xFF); // 低字节
|
||||||
|
raw_data.push_back((step_ms >> 8) & 0xFF); // 高字节
|
||||||
|
}
|
||||||
|
|
||||||
|
serial_->sendRawServoData(raw_data);
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||||
|
|
||||||
|
// 设备64角度(10通道)
|
||||||
|
const std::vector<double> device_64_neutral = {90, 90, 90, 90, 90, 90, 90, 90, 90, 90};
|
||||||
|
// 设备65角度(10通道)
|
||||||
|
const std::vector<double> device_65_neutral = {90, 90, 90, 90, 90, 90, 90, 90, 90, 90};
|
||||||
|
|
||||||
|
std::vector<uint8_t> raw_data_neutral;
|
||||||
|
|
||||||
|
// 下发设备64的10个通道(0~9)
|
||||||
|
for (int ch = 0; ch < 10; ++ch) {
|
||||||
|
uint8_t angle = static_cast<uint8_t>(std::round(device_64_neutral[ch]));
|
||||||
|
raw_data_neutral.push_back(64); // 地址
|
||||||
|
raw_data_neutral.push_back(ch); // 通道号
|
||||||
|
raw_data_neutral.push_back(angle); // 角度
|
||||||
|
raw_data_neutral.push_back(step_ms & 0xFF); // 低字节
|
||||||
|
raw_data_neutral.push_back((step_ms >> 8) & 0xFF); // 高字节
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下发设备65的10个通道(0~9)
|
||||||
|
for (int ch = 0; ch < 10; ++ch) {
|
||||||
|
uint8_t angle = static_cast<uint8_t>(std::round(device_65_neutral[ch]));
|
||||||
|
raw_data_neutral.push_back(65); // 地址
|
||||||
|
raw_data_neutral.push_back(ch); // 通道号
|
||||||
|
raw_data_neutral.push_back(angle); // 角度
|
||||||
|
raw_data_neutral.push_back(step_ms & 0xFF); // 低字节
|
||||||
|
raw_data_neutral.push_back((step_ms >> 8) & 0xFF); // 高字节
|
||||||
|
}
|
||||||
|
|
||||||
|
serial_->sendRawServoData(raw_data_neutral);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -36,6 +36,11 @@ namespace cmvr::service
|
|||||||
|
|
||||||
grpc::Status ExpressionTired(grpc::ServerContext* context, const cmvr::api::ExpressionTired_Request* request, cmvr::api::ExpressionTired_Feedback* response) override;
|
grpc::Status ExpressionTired(grpc::ServerContext* context, const cmvr::api::ExpressionTired_Request* request, cmvr::api::ExpressionTired_Feedback* response) override;
|
||||||
|
|
||||||
|
grpc::Status ExpressionAngry(grpc::ServerContext* context, const cmvr::api::ExpressionAngry_Request* request, cmvr::api::ExpressionAngry_Feedback* response) override;
|
||||||
|
|
||||||
|
grpc::Status ExpressionSadness(grpc::ServerContext* context, const cmvr::api::ExpressionSadness_Request* request, cmvr::api::ExpressionSadness_Feedback* response) override;
|
||||||
|
|
||||||
|
grpc::Status ExpressionYawn(grpc::ServerContext* context, const cmvr::api::ExpressionYawn_Request* request, cmvr::api::ExpressionYawn_Feedback* response) override;
|
||||||
private:
|
private:
|
||||||
device::DeviceManager& dmgr_;
|
device::DeviceManager& dmgr_;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -350,3 +350,77 @@ grpc::Status gRPCMBioHeadServiceImpl::ExpressionTired(grpc::ServerContext* conte
|
|||||||
return grpc::Status::OK;
|
return grpc::Status::OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
grpc::Status gRPCMBioHeadServiceImpl::ExpressionAngry(grpc::ServerContext* context, const cmvr::api::ExpressionAngry_Request* request, cmvr::api::ExpressionAngry_Feedback* response)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
string dev_id = request->header().device_id();
|
||||||
|
auto robot = dmgr_.getDevice<AbstractBiohead>(dev_id);
|
||||||
|
if (!robot) {
|
||||||
|
throw runtime_error("Biohead device not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
robot->expressionAngry(); // 停止执行
|
||||||
|
|
||||||
|
response->mutable_header()->set_success(true);
|
||||||
|
setCurrentTimestamp(response->mutable_header()->mutable_timestamp());
|
||||||
|
return grpc::Status::OK;
|
||||||
|
}
|
||||||
|
catch (const exception& e) {
|
||||||
|
response->mutable_header()->set_success(false);
|
||||||
|
response->mutable_header()->set_error_message(e.what());
|
||||||
|
setCurrentTimestamp(response->mutable_header()->mutable_timestamp());
|
||||||
|
return grpc::Status::OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
grpc::Status gRPCMBioHeadServiceImpl::ExpressionSadness(grpc::ServerContext* context, const cmvr::api::ExpressionSadness_Request* request, cmvr::api::ExpressionSadness_Feedback* response)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
string dev_id = request->header().device_id();
|
||||||
|
auto robot = dmgr_.getDevice<AbstractBiohead>(dev_id);
|
||||||
|
if (!robot) {
|
||||||
|
throw runtime_error("Biohead device not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
robot->expressionAngry(); // 停止执行
|
||||||
|
|
||||||
|
response->mutable_header()->set_success(true);
|
||||||
|
setCurrentTimestamp(response->mutable_header()->mutable_timestamp());
|
||||||
|
return grpc::Status::OK;
|
||||||
|
}
|
||||||
|
catch (const exception& e) {
|
||||||
|
response->mutable_header()->set_success(false);
|
||||||
|
response->mutable_header()->set_error_message(e.what());
|
||||||
|
setCurrentTimestamp(response->mutable_header()->mutable_timestamp());
|
||||||
|
return grpc::Status::OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
grpc::Status gRPCMBioHeadServiceImpl::ExpressionYawn(grpc::ServerContext* context, const cmvr::api::ExpressionYawn_Request* request, cmvr::api::ExpressionYawn_Feedback* response)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
string dev_id = request->header().device_id();
|
||||||
|
auto robot = dmgr_.getDevice<AbstractBiohead>(dev_id);
|
||||||
|
if (!robot) {
|
||||||
|
throw runtime_error("Biohead device not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
robot->expressionYawn(); // 停止执行
|
||||||
|
|
||||||
|
response->mutable_header()->set_success(true);
|
||||||
|
setCurrentTimestamp(response->mutable_header()->mutable_timestamp());
|
||||||
|
return grpc::Status::OK;
|
||||||
|
}
|
||||||
|
catch (const exception& e) {
|
||||||
|
response->mutable_header()->set_success(false);
|
||||||
|
response->mutable_header()->set_error_message(e.what());
|
||||||
|
setCurrentTimestamp(response->mutable_header()->mutable_timestamp());
|
||||||
|
return grpc::Status::OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user