mirror of
https://github.com/westonrobot/ugv_sdk
synced 2023-04-08 06:32:14 +08:00
update tracer interface
This commit is contained in:
@@ -15,18 +15,17 @@
|
||||
#include "ugv_sdk/details/interface/agilex_message.h"
|
||||
|
||||
namespace westonrobot {
|
||||
struct TracerState {
|
||||
// system state
|
||||
struct TracerCoreState {
|
||||
SystemStateMessage system_state;
|
||||
MotionStateMessage motion_state;
|
||||
LightStateMessage light_state;
|
||||
RcStateMessage rc_state;
|
||||
};
|
||||
|
||||
struct TracerActuatorState {
|
||||
// actuator state
|
||||
// - for v2 robots only
|
||||
ActuatorHSStateMessage actuator_hs_state[4];
|
||||
ActuatorLSStateMessage actuator_ls_state[4];
|
||||
// - for v1 robots only
|
||||
ActuatorStateMessageV1 actuator_state[4];
|
||||
ActuatorHSStateMessage actuator_hs_state[2];
|
||||
ActuatorLSStateMessage actuator_ls_state[2];
|
||||
};
|
||||
|
||||
struct TracerInterface {
|
||||
@@ -36,7 +35,8 @@ struct TracerInterface {
|
||||
virtual void SetLightCommand(LightMode f_mode, uint8_t f_value) = 0;
|
||||
|
||||
// get robot state
|
||||
virtual TracerState GetRobotState() = 0;
|
||||
virtual TracerCoreState GetRobotState() = 0;
|
||||
virtual TracerActuatorState GetActuatorState() = 0;
|
||||
};
|
||||
} // namespace westonrobot
|
||||
|
||||
|
||||
@@ -29,10 +29,9 @@ class TracerBaseV2 : public AgilexBase<ProtocolV2Parser>,
|
||||
|
||||
// set up connection
|
||||
void Connect(std::string can_name) override {
|
||||
AgilexBase<ProtocolV2Parser>::ConnectPort(
|
||||
can_name,
|
||||
std::bind(&TracerBaseV2::ParseCANFrame, this, std::placeholders::_1));
|
||||
AgilexBase<ProtocolV2Parser>::Connect(can_name);
|
||||
}
|
||||
|
||||
void Connect(std::string uart_name, uint32_t baudrate) override {
|
||||
// TODO
|
||||
}
|
||||
@@ -49,9 +48,26 @@ class TracerBaseV2 : public AgilexBase<ProtocolV2Parser>,
|
||||
}
|
||||
|
||||
// get robot state
|
||||
TracerState GetRobotState() override {
|
||||
// std::lock_guard<std::mutex>
|
||||
// guard(AgilexBase<ProtocolV2Parser>::state_mutex_); return tracer_state_;
|
||||
TracerCoreState GetRobotState() override {
|
||||
auto state = AgilexBase<ProtocolV2Parser>::GetRobotCoreStateMsgGroup();
|
||||
|
||||
TracerCoreState tracer_state;
|
||||
tracer_state.system_state = state.system_state;
|
||||
tracer_state.motion_state = state.motion_state;
|
||||
tracer_state.light_state = state.light_state;
|
||||
tracer_state.rc_state = state.rc_state;
|
||||
return tracer_state;
|
||||
}
|
||||
|
||||
TracerActuatorState GetActuatorState() override {
|
||||
auto actuator = AgilexBase<ProtocolV2Parser>::GetActuatorStateMsgGroup();
|
||||
|
||||
TracerActuatorState tracer_actuator;
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
tracer_actuator.actuator_hs_state[i] = actuator.actuator_hs_state[i];
|
||||
tracer_actuator.actuator_ls_state[i] = actuator.actuator_ls_state[i];
|
||||
}
|
||||
return tracer_actuator;
|
||||
}
|
||||
|
||||
void ResetRobotState() override {
|
||||
|
||||
Reference in New Issue
Block a user