mirror of
https://github.com/westonrobot/ugv_sdk
synced 2023-04-08 06:32:14 +08:00
fixed scout_base decoding
This commit is contained in:
@@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* scout_base_v1.hpp
|
|
||||||
*
|
|
||||||
* Created on: Jul 08, 2021 22:47
|
|
||||||
* Description:
|
|
||||||
*
|
|
||||||
* Copyright (c) 2021 Ruixiang Du (rdu)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SCOUT_BASE_V1_HPP
|
|
||||||
#define SCOUT_BASE_V1_HPP
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <thread>
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
#include "ugv_sdk/interface/scout_interface.hpp"
|
|
||||||
|
|
||||||
#include "ugv_sdk/mobile_base/agilex_base.hpp"
|
|
||||||
#include "ugv_sdk/protocol_v1/scout_protocol_v1_parser.hpp"
|
|
||||||
|
|
||||||
namespace westonrobot {
|
|
||||||
class ScoutBaseV1 : public AgilexBase<ScoutProtocolV1Parser>,
|
|
||||||
public ScoutInterface {
|
|
||||||
public:
|
|
||||||
ScoutBaseV1() : AgilexBase<ScoutProtocolV1Parser>(){};
|
|
||||||
~ScoutBaseV1() = default;
|
|
||||||
|
|
||||||
// set up connection
|
|
||||||
void Connect(std::string can_name) override;
|
|
||||||
void Connect(std::string uart_name, uint32_t baudrate) override;
|
|
||||||
|
|
||||||
// robot control
|
|
||||||
void SetMotionCommand(double linear_vel, double angular_vel) override;
|
|
||||||
void SetLightCommand(LightMode f_mode, uint8_t f_value, LightMode r_mode,
|
|
||||||
uint8_t r_value) override;
|
|
||||||
|
|
||||||
// get robot state
|
|
||||||
ScoutState GetRobotState() override;
|
|
||||||
|
|
||||||
void ResetRobotState() override {}
|
|
||||||
|
|
||||||
private:
|
|
||||||
ScoutState scout_state_;
|
|
||||||
|
|
||||||
void ParseCANFrame(can_frame *rx_frame) override;
|
|
||||||
void UpdateScoutState(const AgxMessage &status_msg, ScoutState &state);
|
|
||||||
};
|
|
||||||
} // namespace westonrobot
|
|
||||||
|
|
||||||
#endif /* SCOUT_BASE_V1_HPP */
|
|
||||||
@@ -25,7 +25,6 @@
|
|||||||
#include "ugv_sdk/details/stopwatch.hpp"
|
#include "ugv_sdk/details/stopwatch.hpp"
|
||||||
#include "ugv_sdk/details/async_port/async_can.hpp"
|
#include "ugv_sdk/details/async_port/async_can.hpp"
|
||||||
#include "ugv_sdk/details/interface/robot_interface.hpp"
|
#include "ugv_sdk/details/interface/robot_interface.hpp"
|
||||||
#include "ugv_sdk/details/protocol_v2/agilex_msg_parser.h"
|
|
||||||
|
|
||||||
namespace westonrobot {
|
namespace westonrobot {
|
||||||
template <typename ParserType>
|
template <typename ParserType>
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class ScoutBase : public AgilexBase<Parser>, public ScoutInterface {
|
|||||||
|
|
||||||
void ParseCANFrame(can_frame *rx_frame) override {
|
void ParseCANFrame(can_frame *rx_frame) override {
|
||||||
AgxMessage status_msg;
|
AgxMessage status_msg;
|
||||||
DecodeCanFrame(rx_frame, &status_msg);
|
AgilexBase<Parser>::parser_.DecodeMessage(rx_frame, &status_msg);
|
||||||
std::lock_guard<std::mutex> guard(AgilexBase<Parser>::state_mutex_);
|
std::lock_guard<std::mutex> guard(AgilexBase<Parser>::state_mutex_);
|
||||||
UpdateScoutState(status_msg, scout_state_);
|
UpdateScoutState(status_msg, scout_state_);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "agx_protocol_v2.h"
|
#include "agx_protocol_v2.h"
|
||||||
#include "ugv_sdk/details/protocol_v2/agilex_msg_parser.h"
|
#include "protocol_v2/agilex_msg_parser.h"
|
||||||
|
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
* Copyright (c) 2021 Weston Robot Pte. Ltd.
|
* Copyright (c) 2021 Weston Robot Pte. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ugv_sdk/details/protocol_v2/agilex_msg_parser.h"
|
|
||||||
#include "ugv_sdk/details/protocol_v2/protocol_v2_parser.hpp"
|
#include "ugv_sdk/details/protocol_v2/protocol_v2_parser.hpp"
|
||||||
|
#include "protocol_v2/agilex_msg_parser.h"
|
||||||
|
|
||||||
namespace westonrobot {
|
namespace westonrobot {
|
||||||
bool ProtocolV2Parser::DecodeMessage(const struct can_frame *rx_frame,
|
bool ProtocolV2Parser::DecodeMessage(const struct can_frame *rx_frame,
|
||||||
|
|||||||
Reference in New Issue
Block a user