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 */
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* agilex_msg_parser.h
|
||||
*
|
||||
* Created on: Dec 22, 2020 17:11
|
||||
* Description: public API to encode/decode protocol messages
|
||||
*
|
||||
* Copyright (c) 2020 Ruixiang Du (rdu)
|
||||
*/
|
||||
|
||||
#ifndef AGILEX_MSG_PARSER_H
|
||||
#define AGILEX_MSG_PARSER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <linux/can.h>
|
||||
#else
|
||||
struct can_frame {
|
||||
uint32_t can_id;
|
||||
uint8_t can_dlc;
|
||||
uint8_t data[8] __attribute__((aligned(8)));
|
||||
};
|
||||
#endif
|
||||
|
||||
#include "ugv_sdk/details/interface/agilex_message.h"
|
||||
|
||||
bool DecodeCanFrame(const struct can_frame *rx_frame, AgxMessage *msg);
|
||||
void EncodeCanFrame(const AgxMessage *msg, struct can_frame *tx_frame);
|
||||
uint8_t CalcCanFrameChecksum(uint16_t id, uint8_t *data, uint8_t dlc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AGILEX_MSG_PARSER_H */
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "ugv_sdk/details/stopwatch.hpp"
|
||||
#include "ugv_sdk/details/async_port/async_can.hpp"
|
||||
#include "ugv_sdk/details/interface/robot_interface.hpp"
|
||||
#include "ugv_sdk/details/protocol_v2/agilex_msg_parser.h"
|
||||
|
||||
namespace westonrobot {
|
||||
template <typename ParserType>
|
||||
|
||||
@@ -61,7 +61,7 @@ class ScoutBase : public AgilexBase<Parser>, public ScoutInterface {
|
||||
|
||||
void ParseCANFrame(can_frame *rx_frame) override {
|
||||
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_);
|
||||
UpdateScoutState(status_msg, scout_state_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user