mirror of
https://github.com/westonrobot/ugv_sdk
synced 2023-04-08 06:32:14 +08:00
fixed hunter demo print issue
This commit is contained in:
@@ -13,34 +13,36 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "ugv_sdk/mobile_robot/hunter_robot.hpp"
|
#include "ugv_sdk/mobile_robot/hunter_robot.hpp"
|
||||||
|
#include "ugv_sdk/utilities/protocol_detector.hpp"
|
||||||
|
|
||||||
using namespace westonrobot;
|
using namespace westonrobot;
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
std::string protocol_version;
|
|
||||||
std::string device_name;
|
std::string device_name;
|
||||||
|
|
||||||
if (argc == 3) {
|
if (argc == 2) {
|
||||||
protocol_version = {argv[1]};
|
device_name = {argv[1]};
|
||||||
device_name = {argv[2]};
|
std::cout << "Selected interface " << device_name << std::endl;
|
||||||
std::cout << "Use protocol " << protocol_version << " on interface "
|
|
||||||
<< device_name << std::endl;
|
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Usage: app_hunter_demo <protocol-version> <interface>"
|
std::cout << "Usage: app_hunter_demo <interface>" << std::endl
|
||||||
<< std::endl
|
<< "Example 1: ./app_hunter_demo can0" << std::endl;
|
||||||
<< "Example 1: ./app_hunter_demo v1 can0" << std::endl;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<HunterRobot> hunter;
|
std::unique_ptr<HunterRobot> hunter;
|
||||||
if (protocol_version == "v1") {
|
|
||||||
|
ProtocolDectctor detector;
|
||||||
|
detector.Connect(device_name);
|
||||||
|
auto proto = detector.DetectProtocolVersion(5);
|
||||||
|
|
||||||
|
if (proto == ProtocolVersion::AGX_V1) {
|
||||||
hunter =
|
hunter =
|
||||||
std::unique_ptr<HunterRobot>(new HunterRobot(ProtocolVersion::AGX_V1));
|
std::unique_ptr<HunterRobot>(new HunterRobot(ProtocolVersion::AGX_V1));
|
||||||
} else if (protocol_version == "v2") {
|
} else if (proto == ProtocolVersion::AGX_V2) {
|
||||||
hunter =
|
hunter =
|
||||||
std::unique_ptr<HunterRobot>(new HunterRobot(ProtocolVersion::AGX_V2));
|
std::unique_ptr<HunterRobot>(new HunterRobot(ProtocolVersion::AGX_V2));
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Error: invalid protocol version string" << std::endl;
|
std::cout << "Detected protocol: UNKONWN" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +62,7 @@ int main(int argc, char **argv) {
|
|||||||
while (true) {
|
while (true) {
|
||||||
// motion control
|
// motion control
|
||||||
std::cout << "Motor: 1.0, 0" << std::endl;
|
std::cout << "Motor: 1.0, 0" << std::endl;
|
||||||
hunter->SetMotionCommand(1.0, 0.0);
|
// hunter->SetMotionCommand(1.0, 0.0);
|
||||||
|
|
||||||
// get robot state
|
// get robot state
|
||||||
auto state = hunter->GetRobotState();
|
auto state = hunter->GetRobotState();
|
||||||
@@ -75,7 +77,7 @@ int main(int argc, char **argv) {
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "velocity (linear, angular): "
|
std::cout << "velocity (linear, angular): "
|
||||||
<< state.motion_state.linear_velocity << ", "
|
<< state.motion_state.linear_velocity << ", "
|
||||||
<< state.motion_state.angular_velocity << std::endl;
|
<< state.motion_state.steering_angle << std::endl;
|
||||||
|
|
||||||
auto actuator = hunter->GetActuatorState();
|
auto actuator = hunter->GetActuatorState();
|
||||||
if (hunter->GetParserProtocolVersion() == ProtocolVersion::AGX_V1) {
|
if (hunter->GetParserProtocolVersion() == ProtocolVersion::AGX_V1) {
|
||||||
|
|||||||
33001
docs/protocol_v2/HUNTER2.0用户手册_210528.pdf
Normal file
33001
docs/protocol_v2/HUNTER2.0用户手册_210528.pdf
Normal file
File diff suppressed because one or more lines are too long
@@ -43,13 +43,18 @@ ProtocolVersion ProtocolDectctor::DetectProtocolVersion(uint32_t timeout_sec) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void ProtocolDectctor::ParseCANFrame(can_frame *rx_frame) {
|
void ProtocolDectctor::ParseCANFrame(can_frame *rx_frame) {
|
||||||
// state feedback frame with id 0x151 is unique to V1 protocol
|
switch (rx_frame->can_id) {
|
||||||
if (rx_frame->can_id == 0x151) {
|
// state feedback frame with id 0x151 is unique to V1 protocol
|
||||||
msg_v1_detected_ = true;
|
case 0x151: {
|
||||||
}
|
msg_v1_detected_ = true;
|
||||||
// rc state frame with id 0x241 is unique to V2 protocol
|
break;
|
||||||
else if (rx_frame->can_id == 0x241) {
|
}
|
||||||
msg_v2_detected_ = true;
|
// rc state frame with id 0x241 is unique to V2 protocol
|
||||||
|
case 0x221:
|
||||||
|
case 0x241: {
|
||||||
|
msg_v2_detected_ = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace westonrobot
|
} // namespace westonrobot
|
||||||
Reference in New Issue
Block a user