mirror of
https://github.com/westonrobot/ugv_sdk
synced 2023-04-08 06:32:14 +08:00
renamed folder with '_v2' back, disabled ci for ros temporarily
This commit is contained in:
108
.gitlab-ci.yml
108
.gitlab-ci.yml
@@ -27,62 +27,62 @@ focal-cpp-build:
|
|||||||
- cmake --build . && cpack
|
- cmake --build . && cpack
|
||||||
|
|
||||||
## Build and test as catkin package
|
## Build and test as catkin package
|
||||||
kinetic-catkin-build:
|
# kinetic-catkin-build:
|
||||||
stage: build
|
# stage: build
|
||||||
image: rduweston/ubuntu-ci:kinetic
|
# image: rduweston/ubuntu-ci:kinetic
|
||||||
script:
|
# script:
|
||||||
- mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace"
|
# - mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace"
|
||||||
- cp -r /builds/$CI_PROJECT_PATH /catkin_ws/src/wrp_sdk
|
# - cp -r /builds/$CI_PROJECT_PATH /catkin_ws/src/wrp_sdk
|
||||||
- cd /catkin_ws/src/wrp_sdk && git submodule update --init --recursive
|
# - cd /catkin_ws/src/wrp_sdk && git submodule update --init --recursive
|
||||||
- cd /catkin_ws/src && git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/westonrobot/ros/scout_base.git
|
# - cd /catkin_ws/src && git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/westonrobot/ros/scout_base.git
|
||||||
- cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make"
|
# - cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make"
|
||||||
|
|
||||||
kinetic-catkin-isolated-build:
|
# kinetic-catkin-isolated-build:
|
||||||
stage: build
|
# stage: build
|
||||||
image: rduweston/ubuntu-ci:kinetic
|
# image: rduweston/ubuntu-ci:kinetic
|
||||||
script:
|
# script:
|
||||||
- mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace"
|
# - mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace"
|
||||||
- cp -r /builds/$CI_PROJECT_PATH /catkin_ws/src/wrp_sdk
|
# - cp -r /builds/$CI_PROJECT_PATH /catkin_ws/src/wrp_sdk
|
||||||
- cd /catkin_ws/src/wrp_sdk && git submodule update --init --recursive
|
# - cd /catkin_ws/src/wrp_sdk && git submodule update --init --recursive
|
||||||
- cd /catkin_ws/src && git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/westonrobot/ros/scout_base.git
|
# - cd /catkin_ws/src && git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/westonrobot/ros/scout_base.git
|
||||||
- cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make_isolated --install"
|
# - cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make_isolated --install"
|
||||||
|
|
||||||
melodic-catkin-build:
|
# melodic-catkin-build:
|
||||||
stage: build
|
# stage: build
|
||||||
image: rduweston/ubuntu-ci:melodic
|
# image: rduweston/ubuntu-ci:melodic
|
||||||
script:
|
# script:
|
||||||
- mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace"
|
# - mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace"
|
||||||
- cp -r /builds/$CI_PROJECT_PATH /catkin_ws/src/wrp_sdk
|
# - cp -r /builds/$CI_PROJECT_PATH /catkin_ws/src/wrp_sdk
|
||||||
- cd /catkin_ws/src/wrp_sdk && git submodule update --init --recursive
|
# - cd /catkin_ws/src/wrp_sdk && git submodule update --init --recursive
|
||||||
- cd /catkin_ws/src && git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/westonrobot/ros/scout_base.git
|
# - cd /catkin_ws/src && git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/westonrobot/ros/scout_base.git
|
||||||
- cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make"
|
# - cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make"
|
||||||
|
|
||||||
melodic-catkin-isolated-build:
|
# melodic-catkin-isolated-build:
|
||||||
stage: build
|
# stage: build
|
||||||
image: rduweston/ubuntu-ci:melodic
|
# image: rduweston/ubuntu-ci:melodic
|
||||||
script:
|
# script:
|
||||||
- mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace"
|
# - mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace"
|
||||||
- cp -r /builds/$CI_PROJECT_PATH /catkin_ws/src/wrp_sdk
|
# - cp -r /builds/$CI_PROJECT_PATH /catkin_ws/src/wrp_sdk
|
||||||
- cd /catkin_ws/src/wrp_sdk && git submodule update --init --recursive
|
# - cd /catkin_ws/src/wrp_sdk && git submodule update --init --recursive
|
||||||
- cd /catkin_ws/src && git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/westonrobot/ros/scout_base.git
|
# - cd /catkin_ws/src && git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/westonrobot/ros/scout_base.git
|
||||||
- cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make_isolated --install"
|
# - cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make_isolated --install"
|
||||||
|
|
||||||
noetic-catkin-build:
|
# noetic-catkin-build:
|
||||||
stage: build
|
# stage: build
|
||||||
image: rduweston/ubuntu-ci:noetic
|
# image: rduweston/ubuntu-ci:noetic
|
||||||
script:
|
# script:
|
||||||
- mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace"
|
# - mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace"
|
||||||
- cp -r /builds/$CI_PROJECT_PATH /catkin_ws/src/wrp_sdk
|
# - cp -r /builds/$CI_PROJECT_PATH /catkin_ws/src/wrp_sdk
|
||||||
- cd /catkin_ws/src/wrp_sdk && git submodule update --init --recursive
|
# - cd /catkin_ws/src/wrp_sdk && git submodule update --init --recursive
|
||||||
- cd /catkin_ws/src && git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/westonrobot/ros/scout_base.git
|
# - cd /catkin_ws/src && git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/westonrobot/ros/scout_base.git
|
||||||
- cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make"
|
# - cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make"
|
||||||
|
|
||||||
noetic-catkin-isolated-build:
|
# noetic-catkin-isolated-build:
|
||||||
stage: build
|
# stage: build
|
||||||
image: rduweston/ubuntu-ci:noetic
|
# image: rduweston/ubuntu-ci:noetic
|
||||||
script:
|
# script:
|
||||||
- mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace"
|
# - mkdir -p /catkin_ws/src && cd /catkin_ws/src && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace"
|
||||||
- cp -r /builds/$CI_PROJECT_PATH /catkin_ws/src/wrp_sdk
|
# - cp -r /builds/$CI_PROJECT_PATH /catkin_ws/src/wrp_sdk
|
||||||
- cd /catkin_ws/src/wrp_sdk && git submodule update --init --recursive
|
# - cd /catkin_ws/src/wrp_sdk && git submodule update --init --recursive
|
||||||
- cd /catkin_ws/src && git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/westonrobot/ros/scout_base.git
|
# - cd /catkin_ws/src && git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/westonrobot/ros/scout_base.git
|
||||||
- cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make_isolated --install"
|
# - cd /catkin_ws && /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make_isolated --install"
|
||||||
@@ -117,7 +117,7 @@ if(BUILD_WITHOUT_ROS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# add app source directory
|
# add app source directory
|
||||||
add_subdirectory(apps)
|
# add_subdirectory(apps)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Build tests
|
# Build tests
|
||||||
|
|||||||
@@ -14,6 +14,6 @@ target_link_libraries(app_hunter_demo ugv_sdk)
|
|||||||
# add_executable(app_tracer_demo tracer_demo/tracer_demo.cpp)
|
# add_executable(app_tracer_demo tracer_demo/tracer_demo.cpp)
|
||||||
# target_link_libraries(app_tracer_demo ugv_sdk)
|
# target_link_libraries(app_tracer_demo ugv_sdk)
|
||||||
|
|
||||||
if(BUILD_MONITOR)
|
# if(BUILD_MONITOR)
|
||||||
add_subdirectory(scout_monitor)
|
# add_subdirectory(scout_monitor)
|
||||||
endif()
|
# endif()
|
||||||
@@ -17,9 +17,9 @@
|
|||||||
|
|
||||||
#include "ugv_sdk/mobile_base.hpp"
|
#include "ugv_sdk/mobile_base.hpp"
|
||||||
|
|
||||||
#include "ugv_sdk/hunter_v2/hunter_protocol.h"
|
#include "ugv_sdk/hunter/hunter_protocol.h"
|
||||||
#include "ugv_sdk/hunter_v2/hunter_can_parser.h"
|
#include "ugv_sdk/hunter/hunter_can_parser.h"
|
||||||
#include "ugv_sdk/hunter_v2/hunter_types.hpp"
|
#include "ugv_sdk/hunter/hunter_types.hpp"
|
||||||
|
|
||||||
namespace westonrobot {
|
namespace westonrobot {
|
||||||
class HunterBase : public MobileBase {
|
class HunterBase : public MobileBase {
|
||||||
@@ -31,7 +31,8 @@ class HunterBase : public MobileBase {
|
|||||||
HunterState GetHunterState();
|
HunterState GetHunterState();
|
||||||
|
|
||||||
// motion control
|
// motion control
|
||||||
void SetMotionCommand(double linear_vel, double angular_vel, double steering_angle,
|
void SetMotionCommand(double linear_vel, double angular_vel,
|
||||||
|
double steering_angle,
|
||||||
HunterMotionCmd::FaultClearFlag fault_clr_flag =
|
HunterMotionCmd::FaultClearFlag fault_clr_flag =
|
||||||
HunterMotionCmd::FaultClearFlag::NO_FAULT);
|
HunterMotionCmd::FaultClearFlag::NO_FAULT);
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ extern "C" {
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "ugv_sdk/hunter_v2/hunter_protocol.h"
|
#include "ugv_sdk/hunter/hunter_protocol.h"
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <linux/can.h>
|
#include <linux/can.h>
|
||||||
@@ -17,7 +17,7 @@ namespace westonrobot
|
|||||||
{
|
{
|
||||||
struct HunterState
|
struct HunterState
|
||||||
{
|
{
|
||||||
struct MotorHeightSpeedState
|
struct MotorHighSpeedState
|
||||||
{
|
{
|
||||||
double current = 0; // in A
|
double current = 0; // in A
|
||||||
double rpm = 0;
|
double rpm = 0;
|
||||||
@@ -42,8 +42,8 @@ struct HunterState
|
|||||||
|
|
||||||
// motor state
|
// motor state
|
||||||
static constexpr uint8_t motor_num = 3;
|
static constexpr uint8_t motor_num = 3;
|
||||||
MotorHeightSpeedState motor_H_state[motor_num];
|
MotorHighSpeedState motor_hs_state[motor_num];
|
||||||
MotorLowSpeedState motor_L_state[motor_num];
|
MotorLowSpeedState motor_ls_state[motor_num];
|
||||||
|
|
||||||
// motion state
|
// motion state
|
||||||
double linear_velocity = 0;
|
double linear_velocity = 0;
|
||||||
@@ -18,10 +18,10 @@
|
|||||||
|
|
||||||
#include "ugv_sdk/mobile_base.hpp"
|
#include "ugv_sdk/mobile_base.hpp"
|
||||||
|
|
||||||
#include "ugv_sdk/scout_v2/scout_protocol.h"
|
#include "ugv_sdk/scout/scout_protocol.h"
|
||||||
#include "ugv_sdk/scout_v2/scout_can_parser.h"
|
#include "ugv_sdk/scout/scout_can_parser.h"
|
||||||
#include "ugv_sdk/scout_v2/scout_uart_parser.h"
|
#include "ugv_sdk/scout/scout_uart_parser.h"
|
||||||
#include "ugv_sdk/scout_v2/scout_types.hpp"
|
#include "ugv_sdk/scout/scout_types.hpp"
|
||||||
|
|
||||||
namespace westonrobot {
|
namespace westonrobot {
|
||||||
class ScoutBase : public MobileBase {
|
class ScoutBase : public MobileBase {
|
||||||
@@ -17,7 +17,7 @@ extern "C" {
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "ugv_sdk/scout_v2/scout_protocol.h"
|
#include "ugv_sdk/scout/scout_protocol.h"
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <linux/can.h>
|
#include <linux/can.h>
|
||||||
136
ugv_sdk/include/ugv_sdk/scout/scout_types.hpp
Normal file
136
ugv_sdk/include/ugv_sdk/scout/scout_types.hpp
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
/*
|
||||||
|
* scout_state.hpp
|
||||||
|
*
|
||||||
|
* Created on: Jun 11, 2019 08:48
|
||||||
|
* Description:
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Ruixiang Du (rdu)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SCOUT_STATE_HPP
|
||||||
|
#define SCOUT_STATE_HPP
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace westonrobot {
|
||||||
|
struct ScoutState {
|
||||||
|
enum MotorID {
|
||||||
|
FRONT_RIGHT = 0,
|
||||||
|
FRONT_LEFT = 1,
|
||||||
|
REAR_LEFT = 2,
|
||||||
|
REAR_RIGHT = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MotorState {
|
||||||
|
double current = 0; // in A
|
||||||
|
double rpm = 0;
|
||||||
|
double temperature = 0;
|
||||||
|
double motor_pose = 0;
|
||||||
|
};
|
||||||
|
struct DriverState {
|
||||||
|
double driver_voltage = 0;
|
||||||
|
double driver_temperature = 0;
|
||||||
|
uint8_t driver_state = 0;
|
||||||
|
};
|
||||||
|
struct MotorHighSpeedState {
|
||||||
|
double current = 0; // in A
|
||||||
|
double rpm = 0;
|
||||||
|
double motor_pose = 0;
|
||||||
|
};
|
||||||
|
struct MotorLowSpeedState {
|
||||||
|
double driver_voltage = 0;
|
||||||
|
double driver_temperature = 0;
|
||||||
|
double motor_temperature = 0;
|
||||||
|
uint8_t driver_state = 0;
|
||||||
|
};
|
||||||
|
struct LightState {
|
||||||
|
uint8_t mode = 0;
|
||||||
|
uint8_t custom_value = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// base state
|
||||||
|
uint8_t base_state = 0;
|
||||||
|
uint8_t control_mode = 0;
|
||||||
|
uint8_t fault_code = 0;
|
||||||
|
double battery_voltage = 0.0;
|
||||||
|
|
||||||
|
// motor state
|
||||||
|
static constexpr uint8_t motor_num = 4;
|
||||||
|
// MotorState motor_states[motor_num];
|
||||||
|
// DriverState driver_states[motor_num];
|
||||||
|
MotorHighSpeedState motor_hs_state[motor_num];
|
||||||
|
MotorLowSpeedState motor_ls_state[motor_num];
|
||||||
|
|
||||||
|
// light state
|
||||||
|
bool light_control_enabled = false;
|
||||||
|
LightState front_light_state;
|
||||||
|
LightState rear_light_state;
|
||||||
|
|
||||||
|
// motion state
|
||||||
|
double linear_velocity = 0;
|
||||||
|
double angular_velocity = 0;
|
||||||
|
|
||||||
|
// odometer state
|
||||||
|
double left_odomter = 0;
|
||||||
|
double right_odomter = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ScoutMotionCmd {
|
||||||
|
enum class FaultClearFlag {
|
||||||
|
NO_FAULT = 0x00,
|
||||||
|
BAT_UNDER_VOL = 0x01,
|
||||||
|
BAT_OVER_VOL = 0x02,
|
||||||
|
MOTOR1_COMM = 0x03,
|
||||||
|
MOTOR2_COMM = 0x04,
|
||||||
|
MOTOR3_COMM = 0x05,
|
||||||
|
MOTOR4_COMM = 0x06,
|
||||||
|
MOTOR_DRV_OVERHEAT = 0x07,
|
||||||
|
MOTOR_OVERCURRENT = 0x08
|
||||||
|
};
|
||||||
|
|
||||||
|
ScoutMotionCmd(int8_t linear_height_byte = 0, int8_t linear_low_byte = 0,
|
||||||
|
int8_t angular_height_byte = 0, int8_t angular_low_byte = 0,
|
||||||
|
FaultClearFlag fault_clr_flag = FaultClearFlag::NO_FAULT)
|
||||||
|
: linear_velocity_height_byte(linear_height_byte),
|
||||||
|
linear_velocity_low_byte(linear_low_byte),
|
||||||
|
angular_velocity_height_byte(angular_height_byte),
|
||||||
|
angular_velocity_low_byte(angular_low_byte),
|
||||||
|
fault_clear_flag(fault_clr_flag) {}
|
||||||
|
|
||||||
|
int8_t linear_velocity_height_byte;
|
||||||
|
int8_t linear_velocity_low_byte;
|
||||||
|
int8_t angular_velocity_height_byte;
|
||||||
|
int8_t angular_velocity_low_byte;
|
||||||
|
FaultClearFlag fault_clear_flag;
|
||||||
|
|
||||||
|
static constexpr double max_linear_velocity = 1.5; // 1.5 m/s
|
||||||
|
static constexpr double min_linear_velocity = -1.5; // -1.5 m/s
|
||||||
|
static constexpr double max_angular_velocity = 0.5235; // 0.5235 rad/s
|
||||||
|
static constexpr double min_angular_velocity = -0.5235; // -0.5235 rad/s
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ScoutLightCmd {
|
||||||
|
enum class LightMode {
|
||||||
|
CONST_OFF = 0x00,
|
||||||
|
CONST_ON = 0x01,
|
||||||
|
BREATH = 0x02,
|
||||||
|
CUSTOM = 0x03
|
||||||
|
};
|
||||||
|
|
||||||
|
ScoutLightCmd() = default;
|
||||||
|
ScoutLightCmd(LightMode f_mode, uint8_t f_value, LightMode r_mode,
|
||||||
|
uint8_t r_value)
|
||||||
|
: front_mode(f_mode),
|
||||||
|
front_custom_value(f_value),
|
||||||
|
rear_mode(r_mode),
|
||||||
|
rear_custom_value(r_value) {}
|
||||||
|
|
||||||
|
LightMode front_mode;
|
||||||
|
uint8_t front_custom_value;
|
||||||
|
LightMode rear_mode;
|
||||||
|
uint8_t rear_custom_value;
|
||||||
|
};
|
||||||
|
} // namespace westonrobot
|
||||||
|
|
||||||
|
#endif /* SCOUT_STATE_HPP */
|
||||||
@@ -18,7 +18,7 @@ extern "C" {
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "ugv_sdk/scout_v2/scout_protocol.h"
|
#include "ugv_sdk/scout/scout_protocol.h"
|
||||||
|
|
||||||
bool DecodeScoutMsgFromUART(uint8_t c, ScoutMessage *msg);
|
bool DecodeScoutMsgFromUART(uint8_t c, ScoutMessage *msg);
|
||||||
void EncodeScoutMsgToUART(const ScoutMessage *msg, uint8_t *buf, uint8_t *len);
|
void EncodeScoutMsgToUART(const ScoutMessage *msg, uint8_t *buf, uint8_t *len);
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
/*
|
|
||||||
* scout_state.hpp
|
|
||||||
*
|
|
||||||
* Created on: Jun 11, 2019 08:48
|
|
||||||
* Description:
|
|
||||||
*
|
|
||||||
* Copyright (c) 2019 Ruixiang Du (rdu)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SCOUT_STATE_HPP
|
|
||||||
#define SCOUT_STATE_HPP
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace westonrobot
|
|
||||||
{
|
|
||||||
struct ScoutState
|
|
||||||
{
|
|
||||||
enum MotorID
|
|
||||||
{
|
|
||||||
FRONT_RIGHT = 0,
|
|
||||||
FRONT_LEFT = 1,
|
|
||||||
REAR_LEFT = 2,
|
|
||||||
REAR_RIGHT = 3
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MotorState
|
|
||||||
{
|
|
||||||
double current = 0; // in A
|
|
||||||
double rpm = 0;
|
|
||||||
double temperature = 0;
|
|
||||||
double motor_pose=0;
|
|
||||||
};
|
|
||||||
struct DriverState
|
|
||||||
{
|
|
||||||
double driver_voltage = 0;
|
|
||||||
double driver_temperature = 0;
|
|
||||||
uint8_t driver_state = 0;
|
|
||||||
};
|
|
||||||
struct MotorHeightSpeedState
|
|
||||||
{
|
|
||||||
double current = 0; // in A
|
|
||||||
double rpm = 0;
|
|
||||||
double motor_pose = 0;
|
|
||||||
};
|
|
||||||
struct MotorLowSpeedState
|
|
||||||
{
|
|
||||||
double driver_voltage = 0;
|
|
||||||
double driver_temperature = 0;
|
|
||||||
double motor_temperature = 0;
|
|
||||||
uint8_t driver_state = 0;
|
|
||||||
};
|
|
||||||
struct LightState
|
|
||||||
{
|
|
||||||
uint8_t mode = 0;
|
|
||||||
uint8_t custom_value = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// base state
|
|
||||||
uint8_t base_state = 0;
|
|
||||||
uint8_t control_mode = 0;
|
|
||||||
uint8_t fault_code = 0;
|
|
||||||
double battery_voltage = 0.0;
|
|
||||||
|
|
||||||
// motor state
|
|
||||||
static constexpr uint8_t motor_num = 4;
|
|
||||||
// MotorState motor_states[motor_num];
|
|
||||||
// DriverState driver_states[motor_num];
|
|
||||||
MotorHeightSpeedState motor_H_state[motor_num];
|
|
||||||
MotorLowSpeedState motor_L_state[motor_num];
|
|
||||||
|
|
||||||
// light state
|
|
||||||
bool light_control_enabled = false;
|
|
||||||
LightState front_light_state;
|
|
||||||
LightState rear_light_state;
|
|
||||||
|
|
||||||
// motion state
|
|
||||||
double linear_velocity = 0;
|
|
||||||
double angular_velocity = 0;
|
|
||||||
|
|
||||||
//odometer state
|
|
||||||
double left_odomter=0;
|
|
||||||
double right_odomter=0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ScoutMotionCmd
|
|
||||||
{
|
|
||||||
enum class FaultClearFlag
|
|
||||||
{
|
|
||||||
NO_FAULT = 0x00,
|
|
||||||
BAT_UNDER_VOL = 0x01,
|
|
||||||
BAT_OVER_VOL = 0x02,
|
|
||||||
MOTOR1_COMM = 0x03,
|
|
||||||
MOTOR2_COMM = 0x04,
|
|
||||||
MOTOR3_COMM = 0x05,
|
|
||||||
MOTOR4_COMM = 0x06,
|
|
||||||
MOTOR_DRV_OVERHEAT = 0x07,
|
|
||||||
MOTOR_OVERCURRENT = 0x08
|
|
||||||
};
|
|
||||||
|
|
||||||
ScoutMotionCmd(int8_t linear_height_byte = 0, int8_t linear_low_byte = 0,int8_t angular_height_byte = 0,int8_t angular_low_byte = 0,
|
|
||||||
FaultClearFlag fault_clr_flag = FaultClearFlag::NO_FAULT)
|
|
||||||
: linear_velocity_height_byte(linear_height_byte),linear_velocity_low_byte(linear_low_byte), angular_velocity_height_byte(angular_height_byte),angular_velocity_low_byte(angular_low_byte),
|
|
||||||
fault_clear_flag(fault_clr_flag) {}
|
|
||||||
|
|
||||||
int8_t linear_velocity_height_byte;
|
|
||||||
int8_t linear_velocity_low_byte;
|
|
||||||
int8_t angular_velocity_height_byte;
|
|
||||||
int8_t angular_velocity_low_byte;
|
|
||||||
FaultClearFlag fault_clear_flag;
|
|
||||||
|
|
||||||
static constexpr double max_linear_velocity = 1.5; // 1.5 m/s
|
|
||||||
static constexpr double min_linear_velocity = -1.5; // -1.5 m/s
|
|
||||||
static constexpr double max_angular_velocity = 0.5235; // 0.5235 rad/s
|
|
||||||
static constexpr double min_angular_velocity = -0.5235; // -0.5235 rad/s
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ScoutLightCmd
|
|
||||||
{
|
|
||||||
enum class LightMode
|
|
||||||
{
|
|
||||||
CONST_OFF = 0x00,
|
|
||||||
CONST_ON = 0x01,
|
|
||||||
BREATH = 0x02,
|
|
||||||
CUSTOM = 0x03
|
|
||||||
};
|
|
||||||
|
|
||||||
ScoutLightCmd() = default;
|
|
||||||
ScoutLightCmd(LightMode f_mode, uint8_t f_value, LightMode r_mode, uint8_t r_value) : front_mode(f_mode), front_custom_value(f_value),
|
|
||||||
rear_mode(r_mode), rear_custom_value(r_value) {}
|
|
||||||
|
|
||||||
LightMode front_mode;
|
|
||||||
uint8_t front_custom_value;
|
|
||||||
LightMode rear_mode;
|
|
||||||
uint8_t rear_custom_value;
|
|
||||||
};
|
|
||||||
} // namespace westonrobot
|
|
||||||
|
|
||||||
#endif /* SCOUT_STATE_HPP */
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "ugv_sdk/hunter_v2/hunter_base.hpp"
|
#include "ugv_sdk/hunter/hunter_base.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
@@ -28,7 +28,8 @@ void HunterBase::SendMotionCmd(uint8_t count) {
|
|||||||
/*if (can_connected_)
|
/*if (can_connected_)
|
||||||
m_msg.body.motion_control_msg.data.cmd.control_mode = CTRL_MODE_CMD_CAN;
|
m_msg.body.motion_control_msg.data.cmd.control_mode = CTRL_MODE_CMD_CAN;
|
||||||
else if (serial_connected_)
|
else if (serial_connected_)
|
||||||
m_msg.body.motion_cmd_msg.data.cmd.control_mode = CTRL_MODE_CMD_UART*/;
|
m_msg.body.motion_cmd_msg.data.cmd.control_mode = CTRL_MODE_CMD_UART*/
|
||||||
|
;
|
||||||
motion_cmd_mutex_.lock();
|
motion_cmd_mutex_.lock();
|
||||||
m_msg.body.motion_control_msg.data.cmd.linear_velocity_cmd.high_byte =
|
m_msg.body.motion_control_msg.data.cmd.linear_velocity_cmd.high_byte =
|
||||||
current_motion_cmd_.linear_velocity_height_byte;
|
current_motion_cmd_.linear_velocity_height_byte;
|
||||||
@@ -45,7 +46,6 @@ void HunterBase::SendMotionCmd(uint8_t count) {
|
|||||||
m_msg.body.motion_control_msg.data.cmd.reserved2 = 0;
|
m_msg.body.motion_control_msg.data.cmd.reserved2 = 0;
|
||||||
m_msg.body.motion_control_msg.data.cmd.reserved3 = 0;
|
m_msg.body.motion_control_msg.data.cmd.reserved3 = 0;
|
||||||
|
|
||||||
|
|
||||||
// send to can bus
|
// send to can bus
|
||||||
if (can_connected_) {
|
if (can_connected_) {
|
||||||
can_frame m_frame;
|
can_frame m_frame;
|
||||||
@@ -60,7 +60,7 @@ HunterState HunterBase::GetHunterState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HunterBase::SetMotionCommand(
|
void HunterBase::SetMotionCommand(
|
||||||
double linear_vel, double angular_vel,double steering_angle,
|
double linear_vel, double angular_vel, double steering_angle,
|
||||||
HunterMotionCmd::FaultClearFlag fault_clr_flag) {
|
HunterMotionCmd::FaultClearFlag fault_clr_flag) {
|
||||||
// make sure cmd thread is started before attempting to send commands
|
// make sure cmd thread is started before attempting to send commands
|
||||||
if (!cmd_thread_started_) StartCmdThread();
|
if (!cmd_thread_started_) StartCmdThread();
|
||||||
@@ -75,64 +75,69 @@ void HunterBase::SetMotionCommand(
|
|||||||
steering_angle = HunterMotionCmd::max_steering_angle;
|
steering_angle = HunterMotionCmd::max_steering_angle;
|
||||||
|
|
||||||
std::lock_guard<std::mutex> guard(motion_cmd_mutex_);
|
std::lock_guard<std::mutex> guard(motion_cmd_mutex_);
|
||||||
current_motion_cmd_.linear_velocity_height_byte = static_cast<int16_t>(linear_vel*1000)>>8;
|
current_motion_cmd_.linear_velocity_height_byte =
|
||||||
current_motion_cmd_.linear_velocity_low_byte = static_cast<int16_t>(linear_vel*1000)&0xff;
|
static_cast<int16_t>(linear_vel * 1000) >> 8;
|
||||||
current_motion_cmd_.angular_velocity_height_byte = static_cast<int16_t>(angular_vel*1000)>>8;
|
current_motion_cmd_.linear_velocity_low_byte =
|
||||||
current_motion_cmd_.angular_velocity_low_byte = static_cast<int16_t>(angular_vel*1000)&0xff;
|
static_cast<int16_t>(linear_vel * 1000) & 0xff;
|
||||||
|
current_motion_cmd_.angular_velocity_height_byte =
|
||||||
|
static_cast<int16_t>(angular_vel * 1000) >> 8;
|
||||||
|
current_motion_cmd_.angular_velocity_low_byte =
|
||||||
|
static_cast<int16_t>(angular_vel * 1000) & 0xff;
|
||||||
current_motion_cmd_.fault_clear_flag = fault_clr_flag;
|
current_motion_cmd_.fault_clear_flag = fault_clr_flag;
|
||||||
|
|
||||||
FeedCmdTimeoutWatchdog();
|
FeedCmdTimeoutWatchdog();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HunterBase::SendModeCtl(){
|
void HunterBase::SendModeCtl() {
|
||||||
HunterMessage m_msg;
|
HunterMessage m_msg;
|
||||||
m_msg.type = HunterControlModeMsg;
|
m_msg.type = HunterControlModeMsg;
|
||||||
mode_cmd_mutex_.lock();
|
mode_cmd_mutex_.lock();
|
||||||
m_msg.body.mode_cmd_msg.data.cmd.mode_control=0x01;
|
m_msg.body.mode_cmd_msg.data.cmd.mode_control = 0x01;
|
||||||
mode_cmd_mutex_.unlock();
|
mode_cmd_mutex_.unlock();
|
||||||
m_msg.body.mode_cmd_msg.data.cmd.reserved0=0;
|
m_msg.body.mode_cmd_msg.data.cmd.reserved0 = 0;
|
||||||
m_msg.body.mode_cmd_msg.data.cmd.reserved1=0;
|
m_msg.body.mode_cmd_msg.data.cmd.reserved1 = 0;
|
||||||
m_msg.body.mode_cmd_msg.data.cmd.reserved2=0;
|
m_msg.body.mode_cmd_msg.data.cmd.reserved2 = 0;
|
||||||
m_msg.body.mode_cmd_msg.data.cmd.reserved3=0;
|
m_msg.body.mode_cmd_msg.data.cmd.reserved3 = 0;
|
||||||
m_msg.body.mode_cmd_msg.data.cmd.reserved4=0;
|
m_msg.body.mode_cmd_msg.data.cmd.reserved4 = 0;
|
||||||
m_msg.body.mode_cmd_msg.data.cmd.reserved5=0;
|
m_msg.body.mode_cmd_msg.data.cmd.reserved5 = 0;
|
||||||
m_msg.body.mode_cmd_msg.data.cmd.reserved6=0;
|
m_msg.body.mode_cmd_msg.data.cmd.reserved6 = 0;
|
||||||
if (can_connected_) {
|
if (can_connected_) {
|
||||||
// send to can bus
|
// send to can bus
|
||||||
can_frame m_frame;
|
can_frame m_frame;
|
||||||
EncodeHunterMsgToCAN(&m_msg, &m_frame);
|
EncodeHunterMsgToCAN(&m_msg, &m_frame);
|
||||||
can_if_->SendFrame(m_frame);
|
can_if_->SendFrame(m_frame);
|
||||||
}else {}
|
} else {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HunterBase::SetParkMode(){
|
void HunterBase::SetParkMode() {
|
||||||
HunterMessage m_msg;
|
HunterMessage m_msg;
|
||||||
m_msg.type = HunterParkControlMsg;
|
m_msg.type = HunterParkControlMsg;
|
||||||
bool flag = current_motion_cmd_.linear_velocity_height_byte ||
|
bool flag = current_motion_cmd_.linear_velocity_height_byte ||
|
||||||
current_motion_cmd_.linear_velocity_low_byte;
|
current_motion_cmd_.linear_velocity_low_byte;
|
||||||
if(flag)
|
if (flag) {
|
||||||
{
|
|
||||||
pack_mode_cmd_mutex_.lock();
|
pack_mode_cmd_mutex_.lock();
|
||||||
m_msg.body.park_control_msg.data.cmd.packing_mode=0x00;
|
m_msg.body.park_control_msg.data.cmd.packing_mode = 0x00;
|
||||||
pack_mode_cmd_mutex_.unlock();
|
pack_mode_cmd_mutex_.unlock();
|
||||||
}else {
|
} else {
|
||||||
pack_mode_cmd_mutex_.lock();
|
pack_mode_cmd_mutex_.lock();
|
||||||
m_msg.body.park_control_msg.data.cmd.packing_mode=0x01;
|
m_msg.body.park_control_msg.data.cmd.packing_mode = 0x01;
|
||||||
pack_mode_cmd_mutex_.unlock();
|
pack_mode_cmd_mutex_.unlock();
|
||||||
}
|
}
|
||||||
m_msg.body.park_control_msg.data.cmd.reserved0=0;
|
m_msg.body.park_control_msg.data.cmd.reserved0 = 0;
|
||||||
m_msg.body.park_control_msg.data.cmd.reserved1=0;
|
m_msg.body.park_control_msg.data.cmd.reserved1 = 0;
|
||||||
m_msg.body.park_control_msg.data.cmd.reserved2=0;
|
m_msg.body.park_control_msg.data.cmd.reserved2 = 0;
|
||||||
m_msg.body.park_control_msg.data.cmd.reserved3=0;
|
m_msg.body.park_control_msg.data.cmd.reserved3 = 0;
|
||||||
m_msg.body.park_control_msg.data.cmd.reserved4=0;
|
m_msg.body.park_control_msg.data.cmd.reserved4 = 0;
|
||||||
m_msg.body.park_control_msg.data.cmd.reserved5=0;
|
m_msg.body.park_control_msg.data.cmd.reserved5 = 0;
|
||||||
m_msg.body.park_control_msg.data.cmd.reserved6=0;
|
m_msg.body.park_control_msg.data.cmd.reserved6 = 0;
|
||||||
if (can_connected_) {
|
if (can_connected_) {
|
||||||
// send to can bus
|
// send to can bus
|
||||||
can_frame m_frame;
|
can_frame m_frame;
|
||||||
EncodeHunterMsgToCAN(&m_msg, &m_frame);
|
EncodeHunterMsgToCAN(&m_msg, &m_frame);
|
||||||
can_if_->SendFrame(m_frame);
|
can_if_->SendFrame(m_frame);
|
||||||
}else {}
|
} else {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HunterBase::ParseCANFrame(can_frame *rx_frame) {
|
void HunterBase::ParseCANFrame(can_frame *rx_frame) {
|
||||||
@@ -185,24 +190,24 @@ void HunterBase::UpdateHunterState(const HunterMessage &status_msg,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case HunterMotorDriverHeightSpeedStatusMsg: {
|
case HunterMotorDriverHeightSpeedStatusMsg: {
|
||||||
// std::cout << "motor driver height speed feedback received" << std::endl;
|
// std::cout << "motor driver height speed feedback received" <<
|
||||||
|
// std::endl;
|
||||||
const MotorDriverHeightSpeedStatusMessage &msg =
|
const MotorDriverHeightSpeedStatusMessage &msg =
|
||||||
status_msg.body.motor_driver_height_speed_status_msg;
|
status_msg.body.motor_driver_height_speed_status_msg;
|
||||||
for (int i = 0; i < HunterState::motor_num; ++i) {
|
for (int i = 0; i < HunterState::motor_num; ++i) {
|
||||||
state.motor_H_state[msg.motor_id].current
|
state.motor_hs_state[msg.motor_id].current =
|
||||||
=(static_cast<uint16_t>(msg.data.status.current.low_byte) |
|
(static_cast<uint16_t>(msg.data.status.current.low_byte) |
|
||||||
static_cast<uint16_t>(msg.data.status.current.high_byte) << 8) /
|
static_cast<uint16_t>(msg.data.status.current.high_byte) << 8) /
|
||||||
10.0;
|
10.0;
|
||||||
state.motor_H_state[msg.motor_id].rpm
|
state.motor_hs_state[msg.motor_id].rpm = static_cast<int16_t>(
|
||||||
= static_cast<int16_t>(
|
|
||||||
static_cast<uint16_t>(msg.data.status.rpm.low_byte) |
|
static_cast<uint16_t>(msg.data.status.rpm.low_byte) |
|
||||||
static_cast<uint16_t>(msg.data.status.rpm.high_byte) << 8);
|
static_cast<uint16_t>(msg.data.status.rpm.high_byte) << 8);
|
||||||
state.motor_H_state[msg.motor_id].motor_pose
|
state.motor_hs_state[msg.motor_id].motor_pose = static_cast<int32_t>(
|
||||||
= static_cast<int32_t>(
|
|
||||||
static_cast<uint32_t>(msg.data.status.moter_pose.lowest) |
|
static_cast<uint32_t>(msg.data.status.moter_pose.lowest) |
|
||||||
static_cast<uint32_t>(msg.data.status.moter_pose.sec_lowest) << 8 |
|
static_cast<uint32_t>(msg.data.status.moter_pose.sec_lowest) << 8 |
|
||||||
static_cast<uint32_t>(msg.data.status.moter_pose.sec_heighest)<< 16|
|
static_cast<uint32_t>(msg.data.status.moter_pose.sec_heighest)
|
||||||
static_cast<uint32_t>(msg.data.status.moter_pose.heighest)<< 24 );
|
<< 16 |
|
||||||
|
static_cast<uint32_t>(msg.data.status.moter_pose.heighest) << 24);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -211,18 +216,20 @@ void HunterBase::UpdateHunterState(const HunterMessage &status_msg,
|
|||||||
const MotorDriverLowSpeedStatusMessage &msg =
|
const MotorDriverLowSpeedStatusMessage &msg =
|
||||||
status_msg.body.motor_driver_low_speed_status_msg;
|
status_msg.body.motor_driver_low_speed_status_msg;
|
||||||
for (int i = 0; i < HunterState::motor_num; ++i) {
|
for (int i = 0; i < HunterState::motor_num; ++i) {
|
||||||
state.motor_L_state[msg.motor_id].driver_voltage
|
state.motor_ls_state[msg.motor_id].driver_voltage =
|
||||||
=(static_cast<uint16_t>(msg.data.status.driver_voltage.low_byte) |
|
(static_cast<uint16_t>(msg.data.status.driver_voltage.low_byte) |
|
||||||
static_cast<uint16_t>(msg.data.status.driver_voltage.high_byte) << 8) /
|
static_cast<uint16_t>(msg.data.status.driver_voltage.high_byte)
|
||||||
|
<< 8) /
|
||||||
10.0;
|
10.0;
|
||||||
state.motor_L_state[msg.motor_id].driver_temperature
|
state.motor_ls_state[msg.motor_id]
|
||||||
= static_cast<int16_t>(
|
.driver_temperature = static_cast<int16_t>(
|
||||||
static_cast<uint16_t>(msg.data.status.driver_temperature.low_byte) |
|
static_cast<uint16_t>(msg.data.status.driver_temperature.low_byte) |
|
||||||
static_cast<uint16_t>(msg.data.status.driver_temperature.high_byte) << 8);
|
static_cast<uint16_t>(msg.data.status.driver_temperature.high_byte)
|
||||||
state.motor_L_state[msg.motor_id].motor_temperature
|
<< 8);
|
||||||
= msg.data.status.motor_temperature;
|
state.motor_ls_state[msg.motor_id].motor_temperature =
|
||||||
state.motor_L_state[msg.motor_id].driver_state
|
msg.data.status.motor_temperature;
|
||||||
= msg.data.status.driver_status;
|
state.motor_ls_state[msg.motor_id].driver_state =
|
||||||
|
msg.data.status.driver_status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
* Copyright (c) 2019 Ruixiang Du (rdu)
|
* Copyright (c) 2019 Ruixiang Du (rdu)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ugv_sdk/hunter_v2/hunter_can_parser.h"
|
#include "ugv_sdk/hunter/hunter_can_parser.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
static void EncodeHunterMotionControlMsgToCAN(const MotionControlMessage *msg, struct can_frame *tx_frame);
|
static void EncodeHunterMotionControlMsgToCAN(const MotionControlMessage *msg, struct can_frame *tx_frame);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "ugv_sdk/scout_v2/scout_base.hpp"
|
#include "ugv_sdk/scout/scout_base.hpp"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@@ -294,16 +294,16 @@ void ScoutBase::UpdateScoutState(const ScoutMessage &status_msg,
|
|||||||
// std::cout << "motor 1 driver feedback received" << std::endl;
|
// std::cout << "motor 1 driver feedback received" << std::endl;
|
||||||
const MotorDriverHeightSpeedStatusMessage &msg =status_msg.body.motor_driver_height_speed_status_msg;
|
const MotorDriverHeightSpeedStatusMessage &msg =status_msg.body.motor_driver_height_speed_status_msg;
|
||||||
for (int i = 0; i < ScoutState::motor_num; ++i) {
|
for (int i = 0; i < ScoutState::motor_num; ++i) {
|
||||||
state.motor_H_state[status_msg.body.motor_driver_height_speed_status_msg.motor_id]
|
state.motor_hs_state[status_msg.body.motor_driver_height_speed_status_msg.motor_id]
|
||||||
.current =
|
.current =
|
||||||
(static_cast<uint16_t>(msg.data.status.current.low_byte) |
|
(static_cast<uint16_t>(msg.data.status.current.low_byte) |
|
||||||
static_cast<uint16_t>(msg.data.status.current.high_byte) << 8) /
|
static_cast<uint16_t>(msg.data.status.current.high_byte) << 8) /
|
||||||
10.0;
|
10.0;
|
||||||
state.motor_H_state[status_msg.body.motor_driver_height_speed_status_msg.motor_id]
|
state.motor_hs_state[status_msg.body.motor_driver_height_speed_status_msg.motor_id]
|
||||||
.rpm = static_cast<int16_t>(
|
.rpm = static_cast<int16_t>(
|
||||||
static_cast<int16_t>(msg.data.status.rpm.low_byte) |
|
static_cast<int16_t>(msg.data.status.rpm.low_byte) |
|
||||||
static_cast<int16_t>(msg.data.status.rpm.high_byte) << 8);
|
static_cast<int16_t>(msg.data.status.rpm.high_byte) << 8);
|
||||||
state.motor_H_state[status_msg.body.motor_driver_height_speed_status_msg.motor_id]
|
state.motor_hs_state[status_msg.body.motor_driver_height_speed_status_msg.motor_id]
|
||||||
.motor_pose = static_cast<int32_t>(static_cast<uint32_t>(msg.data.status.moter_pose.lowest)|static_cast<uint32_t>(msg.data.status.moter_pose.sec_lowest
|
.motor_pose = static_cast<int32_t>(static_cast<uint32_t>(msg.data.status.moter_pose.lowest)|static_cast<uint32_t>(msg.data.status.moter_pose.sec_lowest
|
||||||
)<<8|static_cast<uint32_t>(msg.data.status.moter_pose.sec_heighest)<<16|static_cast<uint32_t>(msg.data.status.moter_pose.heighest)<<24);
|
)<<8|static_cast<uint32_t>(msg.data.status.moter_pose.sec_heighest)<<16|static_cast<uint32_t>(msg.data.status.moter_pose.heighest)<<24);
|
||||||
}
|
}
|
||||||
@@ -313,18 +313,18 @@ void ScoutBase::UpdateScoutState(const ScoutMessage &status_msg,
|
|||||||
// std::cout << "motor 1 driver feedback received" << std::endl;
|
// std::cout << "motor 1 driver feedback received" << std::endl;
|
||||||
const MotorDriverLowSpeedStatusMessage &msg =status_msg.body.motor_driver_low_speed_status_msg;
|
const MotorDriverLowSpeedStatusMessage &msg =status_msg.body.motor_driver_low_speed_status_msg;
|
||||||
for (int i = 0; i < ScoutState::motor_num; ++i) {
|
for (int i = 0; i < ScoutState::motor_num; ++i) {
|
||||||
state.motor_L_state[status_msg.body.motor_driver_low_speed_status_msg.motor_id]
|
state.motor_ls_state[status_msg.body.motor_driver_low_speed_status_msg.motor_id]
|
||||||
.driver_voltage =
|
.driver_voltage =
|
||||||
(static_cast<uint16_t>(msg.data.status.driver_voltage.low_byte) |
|
(static_cast<uint16_t>(msg.data.status.driver_voltage.low_byte) |
|
||||||
static_cast<uint16_t>(msg.data.status.driver_voltage.high_byte) << 8) /
|
static_cast<uint16_t>(msg.data.status.driver_voltage.high_byte) << 8) /
|
||||||
10.0;
|
10.0;
|
||||||
state.motor_L_state[status_msg.body.motor_driver_low_speed_status_msg.motor_id]
|
state.motor_ls_state[status_msg.body.motor_driver_low_speed_status_msg.motor_id]
|
||||||
.driver_temperature = static_cast<int16_t>(
|
.driver_temperature = static_cast<int16_t>(
|
||||||
static_cast<uint16_t>(msg.data.status.driver_temperature.low_byte) |
|
static_cast<uint16_t>(msg.data.status.driver_temperature.low_byte) |
|
||||||
static_cast<uint16_t>(msg.data.status.driver_temperature.high_byte) << 8);
|
static_cast<uint16_t>(msg.data.status.driver_temperature.high_byte) << 8);
|
||||||
state.motor_L_state[status_msg.body.motor_driver_low_speed_status_msg.motor_id]
|
state.motor_ls_state[status_msg.body.motor_driver_low_speed_status_msg.motor_id]
|
||||||
.motor_temperature = msg.data.status.motor_temperature;
|
.motor_temperature = msg.data.status.motor_temperature;
|
||||||
state.motor_L_state[status_msg.body.motor_driver_low_speed_status_msg.motor_id]
|
state.motor_ls_state[status_msg.body.motor_driver_low_speed_status_msg.motor_id]
|
||||||
.driver_state = msg.data.status.driver_state;
|
.driver_state = msg.data.status.driver_state;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
* Copyright (c) 2019 Ruixiang Du (rdu)
|
* Copyright (c) 2019 Ruixiang Du (rdu)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ugv_sdk/scout_v2/scout_can_parser.h"
|
#include "ugv_sdk/scout/scout_can_parser.h"
|
||||||
|
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
* Copyright (c) 2019 Ruixiang Du (rdu)
|
* Copyright (c) 2019 Ruixiang Du (rdu)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ugv_sdk/scout_v2/scout_uart_parser.h"
|
#include "ugv_sdk/scout/scout_uart_parser.h"
|
||||||
|
|
||||||
// #define USE_XOR_CHECKSUM
|
// #define USE_XOR_CHECKSUM
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user