mirror of
https://github.com/westonrobot/ugv_sdk
synced 2023-04-08 06:32:14 +08:00
removed tracer robot class, added rc state func for scout
This commit is contained in:
@@ -88,7 +88,7 @@ add_library(${PROJECT_NAME}
|
||||
########################
|
||||
## public interface to access robot
|
||||
src/mobile_robot/scout_robot.cpp
|
||||
src/mobile_robot/tracer_robot.cpp
|
||||
# src/mobile_robot/tracer_robot.cpp
|
||||
########################
|
||||
## protocol v2 support
|
||||
src/protocol_v2/agilex_msg_parser_v2.c
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# demo
|
||||
add_subdirectory(scout_demo)
|
||||
add_subdirectory(tracer_demo)
|
||||
|
||||
# add_executable(app_hunter_demo hunter_demo/hunter_demo.cpp)
|
||||
# target_link_libraries(app_hunter_demo ugv_sdk)
|
||||
|
||||
|
||||
@@ -37,6 +37,9 @@ struct ScoutInterface {
|
||||
|
||||
// get robot state
|
||||
virtual ScoutState GetRobotState() = 0;
|
||||
virtual RcStateMessage GetRcState(){
|
||||
// TODO
|
||||
};
|
||||
};
|
||||
} // namespace westonrobot
|
||||
|
||||
|
||||
@@ -52,20 +52,32 @@ class ScoutBase : public AgilexBase<Parser>, public ScoutInterface {
|
||||
return scout_state_;
|
||||
}
|
||||
|
||||
RcStateMessage GetRcState() override {}
|
||||
|
||||
void ResetRobotState() override {
|
||||
// TODO
|
||||
std::lock_guard<std::mutex> guard(rc_state_mutex_);
|
||||
}
|
||||
|
||||
private:
|
||||
ScoutState scout_state_;
|
||||
RcStateMessage rc_state_;
|
||||
std::mutex rc_state_mutex_;
|
||||
|
||||
void ParseCANFrame(can_frame *rx_frame) override {
|
||||
AgxMessage status_msg;
|
||||
if (AgilexBase<Parser>::parser_.DecodeMessage(rx_frame, &status_msg)) {
|
||||
UpdateScoutState(status_msg, scout_state_);
|
||||
if (status_msg.type == AgxMsgRcState)
|
||||
UpdateRcState(status_msg);
|
||||
else
|
||||
UpdateScoutState(status_msg, scout_state_);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateRcState(const AgxMessage &status_msg) {
|
||||
std::lock_guard<std::mutex> guard(rc_state_mutex_);
|
||||
rc_state_ = status_msg.body.rc_state_msg;
|
||||
}
|
||||
|
||||
void UpdateScoutState(const AgxMessage &status_msg, ScoutState &state) {
|
||||
std::lock_guard<std::mutex> guard(AgilexBase<Parser>::state_mutex_);
|
||||
switch (status_msg.type) {
|
||||
@@ -104,10 +116,6 @@ class ScoutBase : public AgilexBase<Parser>, public ScoutInterface {
|
||||
status_msg.body.v1_actuator_state_msg;
|
||||
break;
|
||||
}
|
||||
// case AgxMsgRcState: {
|
||||
// state.rc_state = status_msg.body.rc_state_msg;
|
||||
// break;
|
||||
// }
|
||||
/* sensor feedback */
|
||||
// case AgxMsgOdometry: {
|
||||
// // std::cout << "Odometer msg feedback received" << std::endl;
|
||||
|
||||
@@ -10,39 +10,10 @@
|
||||
#ifndef TRACER_ROBOT_HPP
|
||||
#define TRACER_ROBOT_HPP
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "ugv_sdk/details/interface/robot_interface.hpp"
|
||||
#include "ugv_sdk/details/interface/tracer_interface.hpp"
|
||||
|
||||
// #include "ugv_sdk/details/robot_base/tracer_base.hpp"
|
||||
#include "ugv_sdk/details/robot_base/tracer_base.hpp"
|
||||
|
||||
namespace westonrobot {
|
||||
// using TracerRobot = TracerBaseV2();
|
||||
class TracerRobot : public RobotInterface, public TracerInterface {
|
||||
public:
|
||||
TracerRobot();
|
||||
~TracerRobot();
|
||||
|
||||
void Connect(std::string can_name) override;
|
||||
void Connect(std::string uart_name, uint32_t baudrate) override;
|
||||
|
||||
void EnableCommandedMode() override;
|
||||
|
||||
void SetMotionCommand(double linear_vel, double angular_vel) override;
|
||||
void SetLightCommand(LightMode f_mode, uint8_t f_value) override;
|
||||
void DisableLightControl() override;
|
||||
|
||||
void ResetRobotState() override;
|
||||
|
||||
ProtocolVersion GetProtocolVersion() override;
|
||||
|
||||
// get robot state
|
||||
TracerState GetRobotState() override;
|
||||
|
||||
private:
|
||||
RobotInterface* robot_;
|
||||
};
|
||||
using TracerRobot = TracerBaseV2;
|
||||
} // namespace westonrobot
|
||||
|
||||
#endif /* TRACER_ROBOT_HPP */
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* tracer_robot.cpp
|
||||
*
|
||||
* Created on: Jul 13, 2021 22:13
|
||||
* Description:
|
||||
*
|
||||
* Copyright (c) 2021 Weston Robot Pte. Ltd.
|
||||
*/
|
||||
|
||||
#include "ugv_sdk/mobile_robot/tracer_robot.hpp"
|
||||
#include "ugv_sdk/details/robot_base/tracer_base.hpp"
|
||||
|
||||
namespace westonrobot {
|
||||
TracerRobot::TracerRobot() {
|
||||
robot_ = new TracerBaseV2();
|
||||
}
|
||||
|
||||
TracerRobot::~TracerRobot() {
|
||||
if (robot_) delete robot_;
|
||||
}
|
||||
|
||||
void TracerRobot::EnableCommandedMode() { robot_->EnableCommandedMode(); }
|
||||
|
||||
void TracerRobot::Connect(std::string can_name) { robot_->Connect(can_name); }
|
||||
|
||||
void TracerRobot::Connect(std::string uart_name, uint32_t baudrate) {
|
||||
robot_->Connect(uart_name, baudrate);
|
||||
}
|
||||
|
||||
void TracerRobot::ResetRobotState() { robot_->ResetRobotState(); }
|
||||
|
||||
ProtocolVersion TracerRobot::GetProtocolVersion() {
|
||||
return robot_->GetProtocolVersion();
|
||||
}
|
||||
|
||||
void TracerRobot::SetMotionCommand(double linear_vel, double angular_vel) {
|
||||
auto tracer = dynamic_cast<TracerInterface*>(robot_);
|
||||
tracer->SetMotionCommand(linear_vel, angular_vel);
|
||||
}
|
||||
|
||||
void TracerRobot::DisableLightControl() { robot_->DisableLightControl(); }
|
||||
|
||||
void TracerRobot::SetLightCommand(LightMode f_mode, uint8_t f_value) {
|
||||
auto tracer = dynamic_cast<TracerInterface*>(robot_);
|
||||
tracer->SetLightCommand(f_mode, f_value);
|
||||
}
|
||||
|
||||
TracerState TracerRobot::GetRobotState() {
|
||||
auto tracer = dynamic_cast<TracerInterface*>(robot_);
|
||||
return tracer->GetRobotState();
|
||||
}
|
||||
} // namespace westonrobot
|
||||
Reference in New Issue
Block a user