Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
507ec8ba59 |
@@ -0,0 +1,59 @@
|
|||||||
|
name: Bug Report
|
||||||
|
about: File a bug report
|
||||||
|
title: "[Bug]: "
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Thanks for taking the time to fill out this bug report!
|
||||||
|
- type: input
|
||||||
|
id: contact
|
||||||
|
attributes:
|
||||||
|
label: Contact Details
|
||||||
|
description: How can we get in touch with you if we need more info?
|
||||||
|
placeholder: ex. email@example.com
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
- type: textarea
|
||||||
|
id: what-happened
|
||||||
|
attributes:
|
||||||
|
label: What happened?
|
||||||
|
description: Also tell us, what did you expect to happen?
|
||||||
|
placeholder: Tell us what you see!
|
||||||
|
value: "A bug happened!"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
id: version
|
||||||
|
attributes:
|
||||||
|
label: Version
|
||||||
|
description: What version of our software are you running?
|
||||||
|
options:
|
||||||
|
- 1.0.2 (Default)
|
||||||
|
- 1.0.3 (Edge)
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
id: browsers
|
||||||
|
attributes:
|
||||||
|
label: What browsers are you seeing the problem on?
|
||||||
|
multiple: true
|
||||||
|
options:
|
||||||
|
- Firefox
|
||||||
|
- Chrome
|
||||||
|
- Safari
|
||||||
|
- Microsoft Edge
|
||||||
|
- type: textarea
|
||||||
|
id: logs
|
||||||
|
attributes:
|
||||||
|
label: Relevant log output
|
||||||
|
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
|
||||||
|
render: shell
|
||||||
|
- type: checkboxes
|
||||||
|
id: terms
|
||||||
|
attributes:
|
||||||
|
label: Code of Conduct
|
||||||
|
description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com)
|
||||||
|
options:
|
||||||
|
- label: I agree to follow this project's Code of Conduct
|
||||||
|
required: true
|
||||||
+8
-15
@@ -16,8 +16,6 @@ add_library(robomaster
|
|||||||
src/modules/sdk.c
|
src/modules/sdk.c
|
||||||
src/modules/chassis.c
|
src/modules/chassis.c
|
||||||
src/modules/gimbal.c
|
src/modules/gimbal.c
|
||||||
src/modules/blaster.c
|
|
||||||
src/modules/camera.c
|
|
||||||
src/connection.c
|
src/connection.c
|
||||||
src/robomaster.c
|
src/robomaster.c
|
||||||
src/robo.c
|
src/robo.c
|
||||||
@@ -30,19 +28,14 @@ target_include_directories(robomaster
|
|||||||
include
|
include
|
||||||
)
|
)
|
||||||
|
|
||||||
include(FetchContent)
|
find_package(SDL2)
|
||||||
FetchContent_Declare (
|
|
||||||
SDL2
|
|
||||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL
|
|
||||||
GIT_TAG release-2.0.20
|
|
||||||
GIT_SHALLOW TRUE
|
|
||||||
)
|
|
||||||
FetchContent_MakeAvailable(SDL2)
|
|
||||||
|
|
||||||
add_executable(robomasterapp
|
if(SDL2_FOUND)
|
||||||
|
add_executable(robomasterapp
|
||||||
src/sdl.c
|
src/sdl.c
|
||||||
)
|
)
|
||||||
target_link_libraries(robomasterapp
|
target_link_libraries(robomasterapp
|
||||||
robomaster
|
robomaster
|
||||||
SDL2-static
|
SDL2::SDL2-static
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "message.h"
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
static const uint8_t BLASTER_HOST = 23;
|
|
||||||
static const uint8_t BLASTER_INDEX = 0;
|
|
||||||
|
|
||||||
#define BLASTER_FIRE_CMD 0x513F
|
|
||||||
|
|
||||||
enum FIRETYPE {
|
|
||||||
FIRETYPE_WATER = 0,
|
|
||||||
FIRETYPE_INFRARED = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
enum FIRETIMES {
|
|
||||||
ONE = 1,
|
|
||||||
TWO = 2,
|
|
||||||
THREE = 3,
|
|
||||||
FOUR = 4,
|
|
||||||
FIVE = 5
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
|
||||||
blaster_fire (
|
|
||||||
union Request* req,
|
|
||||||
uint16_t seq,
|
|
||||||
bool ack,
|
|
||||||
enum FIRETYPE type,
|
|
||||||
enum FIRETIMES times );
|
|
||||||
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "message.h"
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
static const uint8_t STREAM_HOST = 1;
|
|
||||||
static const uint8_t STREAM_INDEX = 0;
|
|
||||||
|
|
||||||
#define STREAM_CTRL_CMD 0xD23F
|
|
||||||
|
|
||||||
#define VIDEO_STREAM_PORT 40921
|
|
||||||
|
|
||||||
enum STREAMSTATE {
|
|
||||||
STREAMSTATE_OFF = 0,
|
|
||||||
STREAMSTATE_ON = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
enum STREAMRESOLUTION {
|
|
||||||
RES_720P = 0,
|
|
||||||
RES_360P = 1,
|
|
||||||
RES_540P = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum STREAMCTRL {
|
|
||||||
STREAMCTRL_SDK = 1,
|
|
||||||
STREAMCTRL_VIDEO = 2,
|
|
||||||
STREAMCTRL_AUDIO = 3
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
|
||||||
stream_ctrl (
|
|
||||||
union Request* req,
|
|
||||||
uint16_t seq,
|
|
||||||
bool ack,
|
|
||||||
enum STREAMSTATE state,
|
|
||||||
enum STREAMRESOLUTION res,
|
|
||||||
enum STREAMCTRL ctrl );
|
|
||||||
|
|
||||||
+49
-140
@@ -3,20 +3,14 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#if defined(_MSC_VER) // Check if compiling with Microsoft Visual Studio
|
#define PACKED __attribute__((__packed__))
|
||||||
#define PACKED(__DECL__) __pragma(pack(push, 1)) __DECL__ __pragma(pack(pop))
|
|
||||||
#elif defined(__GNUC__) // Check if compiling with GCC or any compiler defining __GNUC__, including Clang
|
|
||||||
#define PACKED(__DECL__) __DECL__ __attribute__((packed))
|
|
||||||
#else
|
|
||||||
#error "Unsupported compiler"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const uint8_t CLIENT_HOST = 9;
|
static const uint8_t CLIENT_HOST = 9;
|
||||||
static const uint8_t CLIENT_INDEX = 6;
|
static const uint8_t CLIENT_INDEX = 6;
|
||||||
|
|
||||||
static const uint8_t PREAMBLE = 0x55;
|
static const uint8_t PREAMBLE = 0x55;
|
||||||
|
|
||||||
PACKED( struct Header {
|
struct PACKED Header {
|
||||||
|
|
||||||
// The preamble marks the start of a message and is always 0x55
|
// The preamble marks the start of a message and is always 0x55
|
||||||
uint8_t preamble;
|
uint8_t preamble;
|
||||||
@@ -59,13 +53,13 @@ PACKED( struct Header {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct Footer {
|
struct PACKED Footer {
|
||||||
uint16_t crc;
|
uint16_t crc;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct SetSystemLedReq {
|
struct PACKED SetSystemLedReq {
|
||||||
|
|
||||||
struct Header header;
|
struct Header header;
|
||||||
|
|
||||||
@@ -94,87 +88,87 @@ PACKED( struct SetSystemLedReq {
|
|||||||
|
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
|
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct SetSystemLedResp {
|
struct PACKED SetSystemLedResp {
|
||||||
struct Header header;
|
struct Header header;
|
||||||
uint8_t retcode;
|
uint8_t retcode;
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct SubscribeAddNodeReq
|
struct PACKED SubscribeAddNodeReq
|
||||||
{
|
{
|
||||||
struct Header header;
|
struct Header header;
|
||||||
uint8_t hostbyte;
|
uint8_t hostbyte;
|
||||||
uint32_t sub_vision; // always 0x03000000
|
uint32_t sub_vision; // always 0x03000000
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct SubscribeAddNodeResp
|
struct PACKED SubscribeAddNodeResp
|
||||||
{
|
{
|
||||||
struct Header header;
|
struct Header header;
|
||||||
uint8_t retcode; // 0x00 or 0x50 are acceptable here
|
uint8_t retcode; // 0x00 or 0x50 are acceptable here
|
||||||
uint8_t hostbyte;
|
uint8_t hostbyte;
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct SubNodeResetReq
|
struct PACKED SubNodeResetReq
|
||||||
{
|
{
|
||||||
struct Header header;
|
struct Header header;
|
||||||
uint8_t hostbyte;
|
uint8_t hostbyte;
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct SubNodeResetResp
|
struct PACKED SubNodeResetResp
|
||||||
{
|
{
|
||||||
struct Header header;
|
struct Header header;
|
||||||
uint8_t retcode;
|
uint8_t retcode;
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct SetRobotModeReq
|
struct PACKED SetRobotModeReq
|
||||||
{
|
{
|
||||||
struct Header header;
|
struct Header header;
|
||||||
uint8_t mode;
|
uint8_t mode;
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct SetRobotModeResp
|
struct PACKED SetRobotModeResp
|
||||||
{
|
{
|
||||||
struct Header header;
|
struct Header header;
|
||||||
uint8_t retcode;
|
uint8_t retcode;
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct ChassisSpeedModeReq
|
struct PACKED ChassisSpeedModeReq
|
||||||
{
|
{
|
||||||
struct Header header;
|
struct Header header;
|
||||||
float speed[3];
|
float speed[3];
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct ChassisSpeedModeResp
|
struct PACKED ChassisSpeedModeResp
|
||||||
{
|
{
|
||||||
struct Header header;
|
struct Header header;
|
||||||
int8_t retcode;
|
int8_t retcode;
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct SetChassisWheelSpeedReq
|
struct PACKED SetChassisWheelSpeedReq
|
||||||
{
|
{
|
||||||
struct Header header;
|
struct Header header;
|
||||||
int8_t wheel_speed[4];
|
int8_t wheel_speed[4];
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct SetChassisWheelSpeedResp
|
struct PACKED SetChassisWheelSpeedResp
|
||||||
{
|
{
|
||||||
struct Header header;
|
struct Header header;
|
||||||
int8_t retcode;
|
int8_t retcode;
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct GimbalCtrlSpeedReq
|
struct PACKED GimbalCtrlSpeedReq
|
||||||
{
|
{
|
||||||
struct Header header;
|
struct Header header;
|
||||||
// Values between -360 and 360
|
// Values between -360 and 360
|
||||||
@@ -189,53 +183,53 @@ PACKED( struct GimbalCtrlSpeedReq
|
|||||||
// Always 0xDC
|
// Always 0xDC
|
||||||
uint8_t ctrl;
|
uint8_t ctrl;
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct GimbalCtrlSpeedResp
|
struct PACKED GimbalCtrlSpeedResp
|
||||||
{
|
{
|
||||||
struct Header header;
|
struct Header header;
|
||||||
int8_t retcode;
|
int8_t retcode;
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct SetWheelSpeedReq
|
struct PACKED SetWheelSpeedReq
|
||||||
{
|
{
|
||||||
struct Header header;
|
struct Header header;
|
||||||
int16_t wheel_speed[4];
|
int16_t wheel_speed[4];
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct SetWheelSpeedResp
|
struct PACKED SetWheelSpeedResp
|
||||||
{
|
{
|
||||||
struct Header header;
|
struct Header header;
|
||||||
int8_t retcode;
|
int8_t retcode;
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct SdkHeartbeatReq {
|
struct PACKED SdkHeartbeatReq {
|
||||||
struct Header header;
|
struct Header header;
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct SdkHeartbeatResp {
|
struct PACKED SdkHeartbeatResp {
|
||||||
struct Header header;
|
struct Header header;
|
||||||
uint8_t retcode;
|
uint8_t retcode;
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct SetSdkModeReq {
|
struct PACKED SetSdkModeReq {
|
||||||
struct Header header;
|
struct Header header;
|
||||||
uint8_t enable;
|
uint8_t enable;
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct SetSdkModeResp {
|
struct PACKED SetSdkModeResp {
|
||||||
struct Header header;
|
struct Header header;
|
||||||
uint8_t retcode;
|
uint8_t retcode;
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct SetSdkConnectionReq {
|
struct PACKED SetSdkConnectionReq {
|
||||||
struct Header header;
|
struct Header header;
|
||||||
uint8_t control;
|
uint8_t control;
|
||||||
uint8_t host;
|
uint8_t host;
|
||||||
@@ -244,93 +238,15 @@ PACKED( struct SetSdkConnectionReq {
|
|||||||
uint32_t ip_address;
|
uint32_t ip_address;
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct SetSdkConnectionResp {
|
struct PACKED SetSdkConnectionResp {
|
||||||
struct Header header;
|
struct Header header;
|
||||||
uint8_t retcode;
|
uint8_t retcode;
|
||||||
uint8_t state;
|
uint8_t state;
|
||||||
uint32_t config_ip;
|
uint32_t config_ip;
|
||||||
struct Footer footer;
|
struct Footer footer;
|
||||||
});
|
};
|
||||||
|
|
||||||
PACKED( struct BlasterFireReq {
|
|
||||||
struct Header header;
|
|
||||||
struct {
|
|
||||||
uint8_t type : 4;
|
|
||||||
uint8_t times : 4;
|
|
||||||
};
|
|
||||||
struct Footer footer;
|
|
||||||
});
|
|
||||||
|
|
||||||
PACKED( struct BlasterFireResp {
|
|
||||||
struct Header header;
|
|
||||||
uint8_t retcode;
|
|
||||||
struct Footer footer;
|
|
||||||
});
|
|
||||||
|
|
||||||
PACKED( struct StreamCtrlReq {
|
|
||||||
struct Header header;
|
|
||||||
uint8_t ctrl;
|
|
||||||
struct {
|
|
||||||
uint8_t state : 4;
|
|
||||||
uint8_t conn_type : 4;
|
|
||||||
};
|
|
||||||
uint8_t resolution;
|
|
||||||
struct Footer footer;
|
|
||||||
});
|
|
||||||
|
|
||||||
PACKED( struct StreamCtrlResp {
|
|
||||||
struct Header header;
|
|
||||||
uint8_t retcode;
|
|
||||||
struct Footer footer;
|
|
||||||
});
|
|
||||||
|
|
||||||
PACKED( struct AddSubMsgReq {
|
|
||||||
struct Header header;
|
|
||||||
uint8_t node_id;
|
|
||||||
uint8_t msg_id;
|
|
||||||
uint8_t reserved;
|
|
||||||
uint8_t sub_mode;
|
|
||||||
uint8_t subject_count;
|
|
||||||
uint64_t subject_uuid;
|
|
||||||
uint16_t freq;
|
|
||||||
struct Footer footer;
|
|
||||||
});
|
|
||||||
|
|
||||||
PACKED( struct AddSubMsgResp {
|
|
||||||
struct Header header;
|
|
||||||
uint8_t retcode;
|
|
||||||
uint8_t pub_node_id;
|
|
||||||
uint8_t ack_sub_mode;
|
|
||||||
uint8_t ack_msg_id;
|
|
||||||
uint16_t ack_err_uid_data;
|
|
||||||
struct Footer footer;
|
|
||||||
});
|
|
||||||
|
|
||||||
PACKED( struct PushPeriodMsg {
|
|
||||||
struct Header header;
|
|
||||||
uint8_t sub_mode;
|
|
||||||
uint8_t msg_id;
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
float x;
|
|
||||||
float y;
|
|
||||||
float z;
|
|
||||||
} position;
|
|
||||||
struct {
|
|
||||||
uint16_t yaw_ground;
|
|
||||||
uint16_t pitch_ground;
|
|
||||||
uint16_t yaw;
|
|
||||||
uint16_t pitch;
|
|
||||||
struct {
|
|
||||||
uint8_t option_mode : 2;
|
|
||||||
uint8_t return_center : 1;
|
|
||||||
};
|
|
||||||
} gimbal;
|
|
||||||
};
|
|
||||||
struct Footer footer;
|
|
||||||
});
|
|
||||||
|
|
||||||
union Request {
|
union Request {
|
||||||
struct Header header;
|
struct Header header;
|
||||||
@@ -345,9 +261,6 @@ union Request {
|
|||||||
struct SubNodeResetReq subnodereset;
|
struct SubNodeResetReq subnodereset;
|
||||||
struct SubscribeAddNodeReq subnodeadd;
|
struct SubscribeAddNodeReq subnodeadd;
|
||||||
struct GimbalCtrlSpeedReq gimbspeed;
|
struct GimbalCtrlSpeedReq gimbspeed;
|
||||||
struct BlasterFireReq blaster;
|
|
||||||
struct StreamCtrlReq stream;
|
|
||||||
struct AddSubMsgReq sub;
|
|
||||||
};
|
};
|
||||||
union Response {
|
union Response {
|
||||||
struct Header header;
|
struct Header header;
|
||||||
@@ -362,10 +275,6 @@ union Response {
|
|||||||
struct SubNodeResetResp subnodereset;
|
struct SubNodeResetResp subnodereset;
|
||||||
struct SubscribeAddNodeResp subnodeadd;
|
struct SubscribeAddNodeResp subnodeadd;
|
||||||
struct GimbalCtrlSpeedResp gimbspeed;
|
struct GimbalCtrlSpeedResp gimbspeed;
|
||||||
struct BlasterFireResp blaster;
|
|
||||||
struct StreamCtrlResp stream;
|
|
||||||
struct AddSubMsgResp sub;
|
|
||||||
struct PushPeriodMsg push;
|
|
||||||
};
|
};
|
||||||
union Message {
|
union Message {
|
||||||
struct Header header;
|
struct Header header;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
// Handle for the high level robot interface
|
// Handle for the high level robot interface
|
||||||
struct RobotImp;
|
struct RobotImp;
|
||||||
typedef struct RobotImp* Robot;
|
typedef struct RobotImp* Robot;
|
||||||
@@ -67,10 +65,6 @@ int robot_drive(Robot, float x, float y, float r);
|
|||||||
*/
|
*/
|
||||||
int robot_led(Robot, unsigned char r, unsigned char g, unsigned char b);
|
int robot_led(Robot, unsigned char r, unsigned char g, unsigned char b);
|
||||||
|
|
||||||
int robot_blast(Robot);
|
|
||||||
|
|
||||||
int robot_stream(Robot, bool);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the robot is in ready mode, this makes the robot send a heartbeat in
|
* If the robot is in ready mode, this makes the robot send a heartbeat in
|
||||||
* the next tick of the work function. The work function will not do anything
|
* the next tick of the work function. The work function will not do anything
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ typedef struct Client* Client;
|
|||||||
#include "chassis.h"
|
#include "chassis.h"
|
||||||
#include "sdk.h"
|
#include "sdk.h"
|
||||||
#include "gimbal.h"
|
#include "gimbal.h"
|
||||||
#include "blaster.h"
|
|
||||||
#include "camera.h"
|
|
||||||
|
|
||||||
Client client_new();
|
Client client_new();
|
||||||
void client_connect(Client client);
|
void client_connect(Client client);
|
||||||
|
|||||||
@@ -108,34 +108,3 @@ subscribe_add_node (
|
|||||||
uint16_t seq,
|
uint16_t seq,
|
||||||
bool ack );
|
bool ack );
|
||||||
|
|
||||||
#define ADD_SUB_MSG_CMD 0x0348
|
|
||||||
|
|
||||||
#define PUSH_PERIOD_MSG_CMD 0x0848
|
|
||||||
|
|
||||||
#define DDS_BATTERY 0x000200096862229f
|
|
||||||
#define DDS_GIMBAL_BASE 0x00020009f5882874
|
|
||||||
#define DDS_VELOCITY 0x0002000949a4009c
|
|
||||||
#define DDS_ESC 0x00020009c14cb7c5
|
|
||||||
#define DDS_ATTITUDE 0x000200096b986306
|
|
||||||
#define DDS_IMU 0x00020009a7985b8d
|
|
||||||
#define DDS_POSITION 0x00020009eeb7cece
|
|
||||||
#define DDS_SA_STATUS 0x000200094a2c6d55
|
|
||||||
#define DDS_CHASSIS_MODE 0x000200094fcb1146
|
|
||||||
#define DDS_SBUS 0x0002000988223568
|
|
||||||
#define DDS_SERVO 0x000200095f0059e7
|
|
||||||
#define DDS_ARM 0x0002000926abd64d
|
|
||||||
#define DDS_GRIPPER 0x00020009124d156a
|
|
||||||
#define DDS_GIMBAL_POS 0x00020009f79b3c97
|
|
||||||
#define DDS_STICK 0x0002000955e9a0fa
|
|
||||||
#define DDS_MOVE_MODE 0x00020009784c7bfd
|
|
||||||
#define DDS_TOF 0x0002000986e4c05a
|
|
||||||
#define DDS_PINBOARD 0x00020009eebb9ffc
|
|
||||||
|
|
||||||
void
|
|
||||||
add_sub_msg (
|
|
||||||
union Request* req,
|
|
||||||
uint16_t seq,
|
|
||||||
bool ack,
|
|
||||||
uint8_t msg_id,
|
|
||||||
uint8_t freq,
|
|
||||||
uint64_t subject_uuid );
|
|
||||||
|
|||||||
+20
-61
@@ -4,26 +4,10 @@
|
|||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
bool StartupWSA() {
|
|
||||||
static bool wsastarted = false;
|
|
||||||
if (!wsastarted) {
|
|
||||||
WORD wVersionRequested;
|
|
||||||
WSADATA wsaData;
|
|
||||||
|
|
||||||
wVersionRequested = MAKEWORD(2, 2);
|
|
||||||
if (WSAStartup(wVersionRequested, &wsaData) == 0) {
|
|
||||||
wsastarted = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return wsastarted;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#endif
|
#include <arpa/inet.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -53,12 +37,6 @@ message_length(int cmd) {
|
|||||||
return sizeof(struct ChassisSpeedModeReq);
|
return sizeof(struct ChassisSpeedModeReq);
|
||||||
case GIMBAL_CTRL_SPEED_CMD:
|
case GIMBAL_CTRL_SPEED_CMD:
|
||||||
return sizeof(struct GimbalCtrlSpeedReq);
|
return sizeof(struct GimbalCtrlSpeedReq);
|
||||||
case BLASTER_FIRE_CMD:
|
|
||||||
return sizeof(struct BlasterFireReq);
|
|
||||||
case STREAM_CTRL_CMD:
|
|
||||||
return sizeof(struct StreamCtrlReq);
|
|
||||||
case ADD_SUB_MSG_CMD:
|
|
||||||
return sizeof(struct AddSubMsgReq);
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -76,17 +54,12 @@ message_module(int cmd) {
|
|||||||
case SET_ROBOT_MODE_CMD:
|
case SET_ROBOT_MODE_CMD:
|
||||||
case SUBNODE_RESET_CMD:
|
case SUBNODE_RESET_CMD:
|
||||||
case SUBSCRIBE_ADD_NODE_CMD:
|
case SUBSCRIBE_ADD_NODE_CMD:
|
||||||
case ADD_SUB_MSG_CMD:
|
|
||||||
return host2byte(SDK_HOST, SDK_INDEX);
|
return host2byte(SDK_HOST, SDK_INDEX);
|
||||||
case SET_WHEEL_SPEED_CMD:
|
case SET_WHEEL_SPEED_CMD:
|
||||||
case CHASSIS_SPEED_MODE_CMD:
|
case CHASSIS_SPEED_MODE_CMD:
|
||||||
return host2byte(CHASSIS_HOST, CHASSIS_INDEX);
|
return host2byte(CHASSIS_HOST, CHASSIS_INDEX);
|
||||||
case GIMBAL_CTRL_SPEED_CMD:
|
case GIMBAL_CTRL_SPEED_CMD:
|
||||||
return host2byte(GIMBAL_HOST, GIMBAL_INDEX);
|
return host2byte(GIMBAL_HOST, GIMBAL_INDEX);
|
||||||
case BLASTER_FIRE_CMD:
|
|
||||||
return host2byte(BLASTER_HOST, BLASTER_INDEX);
|
|
||||||
case STREAM_CTRL_CMD:
|
|
||||||
return host2byte(STREAM_HOST, STREAM_INDEX);
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -98,58 +71,44 @@ int max_fd = -1;
|
|||||||
|
|
||||||
// TODO: Close the socket and return NULL on error
|
// TODO: Close the socket and return NULL on error
|
||||||
struct Connection*
|
struct Connection*
|
||||||
connection_new(uint16_t source_port, uint32_t source_ip, uint16_t dest_port, uint32_t dest_ip)
|
connection_new(unsigned int source_port, const char* source_ip, unsigned int dest_port, const char* dest_ip)
|
||||||
{
|
{
|
||||||
struct Connection* conn = malloc(sizeof(struct Connection));
|
struct Connection* conn = malloc(sizeof(struct Connection));
|
||||||
memset(conn, 0, sizeof(struct Connection));
|
memset(conn, 0, sizeof(struct Connection));
|
||||||
|
|
||||||
|
// Request a UDP socket
|
||||||
|
conn->sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
|
||||||
// Set the source address and port if they are provided
|
// Set the source address and port if they are provided
|
||||||
if(source_port && source_ip) {
|
if(source_port && source_ip) {
|
||||||
conn->local_addr.sin_family = AF_INET;
|
struct sockaddr_in loc_addr;
|
||||||
conn->local_addr.sin_port = htons(source_port);
|
loc_addr.sin_family = AF_INET;
|
||||||
conn->local_addr.sin_addr.s_addr = source_ip;
|
loc_addr.sin_port = htons(source_port);
|
||||||
|
loc_addr.sin_addr.s_addr = inet_addr(source_ip);
|
||||||
|
if(bind(conn->sockfd, (struct sockaddr*)&loc_addr, sizeof(loc_addr)) < 0)
|
||||||
|
{
|
||||||
|
perror("unable to bind local port");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make the socket non-blocking
|
||||||
|
int flags = fcntl(conn->sockfd, F_GETFL);
|
||||||
|
fcntl(conn->sockfd, F_SETFL, flags | O_NONBLOCK);
|
||||||
|
|
||||||
// Set the address of the drone
|
// Set the address of the drone
|
||||||
memset(&conn->remote_addr, 0, sizeof(conn->remote_addr));
|
memset(&conn->remote_addr, 0, sizeof(conn->remote_addr));
|
||||||
conn->addrlen = sizeof(conn->remote_addr);
|
conn->addrlen = sizeof(conn->remote_addr);
|
||||||
conn->remote_addr.sin_family = AF_INET;
|
conn->remote_addr.sin_family = AF_INET;
|
||||||
conn->remote_addr.sin_port = htons(dest_port);
|
conn->remote_addr.sin_port = htons(dest_port);
|
||||||
conn->remote_addr.sin_addr.s_addr = dest_ip;
|
conn->remote_addr.sin_addr.s_addr = inet_addr(dest_ip);
|
||||||
|
|
||||||
return conn;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum connection_error
|
|
||||||
connection_connect(struct Connection* conn) {
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
StartupWSA();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Request a UDP socket
|
|
||||||
conn->sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
|
||||||
|
|
||||||
if(conn->local_addr.sin_addr.s_addr
|
|
||||||
&& bind(conn->sockfd, (struct sockaddr*)&conn->local_addr, sizeof(conn->local_addr)) < 0)
|
|
||||||
return CONNECTION_LOCAL_BIND;
|
|
||||||
|
|
||||||
// Make the socket non-blocking
|
|
||||||
#ifdef _WIN32
|
|
||||||
static unsigned long sock_opts = 1;
|
|
||||||
ioctlsocket(conn->sockfd, FIONBIO, &sock_opts); //Non-Blocking
|
|
||||||
#else
|
|
||||||
int flags = fcntl(conn->sockfd, F_GETFL);
|
|
||||||
fcntl(conn->sockfd, F_SETFL, flags | O_NONBLOCK);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// File descriptors are numbers that count up sequentially,
|
// File descriptors are numbers that count up sequentially,
|
||||||
// so save the last one as the greatest file descriptor.
|
// so save the last one as the greatest file descriptor.
|
||||||
// This is needed for polling the sockets later.
|
// This is needed for polling the sockets later.
|
||||||
max_fd = conn->sockfd;
|
max_fd = conn->sockfd;
|
||||||
|
|
||||||
return CONNECTION_NO_ERROR;
|
return conn;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Connection*
|
struct Connection*
|
||||||
|
|||||||
+1
-12
@@ -6,25 +6,14 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
|
||||||
#define ROBOT_DEFAULT_WIFI_ADDR 0X102A8C0
|
|
||||||
|
|
||||||
struct Connection {
|
struct Connection {
|
||||||
int sockfd;
|
int sockfd;
|
||||||
socklen_t addrlen;
|
socklen_t addrlen;
|
||||||
struct sockaddr_in remote_addr;
|
struct sockaddr_in remote_addr;
|
||||||
struct sockaddr_in local_addr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Connection*
|
struct Connection*
|
||||||
connection_new(uint16_t source_port, uint32_t source_ip, uint16_t dest_port, uint32_t dest_ip);
|
connection_new(unsigned int source_port, const char* source_ip, unsigned int dest_port, const char* dest_ip);
|
||||||
|
|
||||||
enum connection_error {
|
|
||||||
CONNECTION_NO_ERROR,
|
|
||||||
CONNECTION_LOCAL_BIND
|
|
||||||
};
|
|
||||||
|
|
||||||
enum connection_error
|
|
||||||
connection_connect();
|
|
||||||
|
|
||||||
struct Connection*
|
struct Connection*
|
||||||
connection_poll_ready(struct Client* client);
|
connection_poll_ready(struct Client* client);
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
#include "message.h"
|
|
||||||
#include "connection.h"
|
|
||||||
#include "robomaster.h"
|
|
||||||
|
|
||||||
void
|
|
||||||
blaster_fire (
|
|
||||||
union Request* req,
|
|
||||||
uint16_t seq,
|
|
||||||
bool ack,
|
|
||||||
enum FIRETYPE type,
|
|
||||||
enum FIRETIMES times ) {
|
|
||||||
req->blaster.type = type;
|
|
||||||
req->blaster.times = times;
|
|
||||||
req_finalize(seq, BLASTER_FIRE_CMD, ack, req);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
#include "message.h"
|
|
||||||
#include "connection.h"
|
|
||||||
#include "robomaster.h"
|
|
||||||
|
|
||||||
void
|
|
||||||
stream_ctrl (
|
|
||||||
union Request* req,
|
|
||||||
uint16_t seq,
|
|
||||||
bool ack,
|
|
||||||
enum STREAMSTATE state,
|
|
||||||
enum STREAMRESOLUTION res,
|
|
||||||
enum STREAMCTRL ctrl ) {
|
|
||||||
req->stream.state = state;
|
|
||||||
req->stream.resolution = res;
|
|
||||||
req->stream.ctrl = ctrl;
|
|
||||||
req->stream.conn_type = 0; // Hardcode to WiFi
|
|
||||||
req_finalize(seq, STREAM_CTRL_CMD, ack, req);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -96,24 +96,3 @@ set_system_led (
|
|||||||
req_finalize(seq, SET_SYSTEM_LED_CMD, ack, req);
|
req_finalize(seq, SET_SYSTEM_LED_CMD, ack, req);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
add_sub_msg (
|
|
||||||
union Request* req,
|
|
||||||
uint16_t seq,
|
|
||||||
bool ack,
|
|
||||||
uint8_t msg_id,
|
|
||||||
uint8_t freq,
|
|
||||||
uint64_t subject_uuid ) {
|
|
||||||
|
|
||||||
req->sub.node_id = host2byte(CLIENT_HOST, CLIENT_INDEX);
|
|
||||||
req->sub.msg_id = msg_id;
|
|
||||||
req->sub.reserved = 0; // NOTE: Always 0
|
|
||||||
req->sub.sub_mode = 0; // NOTE: Always 0
|
|
||||||
req->sub.subject_count = 1; // TODO: Add support for multiple
|
|
||||||
req->sub.subject_uuid = subject_uuid; // TODO: Add support for multiple
|
|
||||||
req->sub.freq = freq;
|
|
||||||
|
|
||||||
req_finalize(seq, ADD_SUB_MSG_CMD, ack, req);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
+2
-100
@@ -4,9 +4,6 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <arpa/inet.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
struct RobotImp {
|
struct RobotImp {
|
||||||
|
|
||||||
@@ -22,20 +19,8 @@ struct RobotImp {
|
|||||||
int16_t gimbal[2];
|
int16_t gimbal[2];
|
||||||
bool dirty_gimbal;
|
bool dirty_gimbal;
|
||||||
|
|
||||||
bool dirty_blaster;
|
|
||||||
|
|
||||||
bool stream_state;
|
|
||||||
bool dirty_stream;
|
|
||||||
|
|
||||||
bool sdk_mode;
|
bool sdk_mode;
|
||||||
|
|
||||||
float x, y, z;
|
|
||||||
|
|
||||||
uint16_t yaw_ground;
|
|
||||||
uint16_t pitch_ground;
|
|
||||||
uint16_t yaw;
|
|
||||||
uint16_t pitch;
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
CONNECTING_TO_PROXY_PORT,
|
CONNECTING_TO_PROXY_PORT,
|
||||||
SETTING_SDK_CONNECTION,
|
SETTING_SDK_CONNECTION,
|
||||||
@@ -44,8 +29,6 @@ struct RobotImp {
|
|||||||
RESETTING_SUBNODE,
|
RESETTING_SUBNODE,
|
||||||
SUSBCRIBING_SUBNODE,
|
SUSBCRIBING_SUBNODE,
|
||||||
SETTING_MOVEMENT_MODE,
|
SETTING_MOVEMENT_MODE,
|
||||||
SUBSCRIBING_POSITION_STATUS,
|
|
||||||
SUBSCRIBING_GIMBAL_STATUS,
|
|
||||||
SENDING_HEARTBEAT,
|
SENDING_HEARTBEAT,
|
||||||
WAITING,
|
WAITING,
|
||||||
READY,
|
READY,
|
||||||
@@ -54,19 +37,6 @@ struct RobotImp {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
|
||||||
robot_stream(Robot robot, bool state) {
|
|
||||||
robot->stream_state = state;
|
|
||||||
robot->dirty_stream = true;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
robot_blast(Robot robot) {
|
|
||||||
robot->dirty_blaster = true;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
robot_drive(Robot robot, float x, float y, float r) {
|
robot_drive(Robot robot, float x, float y, float r) {
|
||||||
// TODO: move individual wheel speed calculation to work function
|
// TODO: move individual wheel speed calculation to work function
|
||||||
@@ -120,8 +90,7 @@ robot_work(Robot robot) {
|
|||||||
|
|
||||||
case CONNECTING_TO_PROXY_PORT:
|
case CONNECTING_TO_PROXY_PORT:
|
||||||
{
|
{
|
||||||
robot->client->sdk_conn = connection_new(0, 0, 30030, ROBOT_DEFAULT_WIFI_ADDR);
|
robot->client->sdk_conn = connection_new(0, 0, 30030, "192.168.2.1");
|
||||||
connection_connect(robot->client->sdk_conn);
|
|
||||||
robot->state = SETTING_SDK_CONNECTION;
|
robot->state = SETTING_SDK_CONNECTION;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -136,8 +105,7 @@ robot_work(Robot robot) {
|
|||||||
|
|
||||||
case CONNECTING_TO_DEVICE_PORT:
|
case CONNECTING_TO_DEVICE_PORT:
|
||||||
{
|
{
|
||||||
if(connection_connect(robot->client->dev_conn))
|
robot->client->dev_conn = connection_new(10010, "192.168.2.24", 20020, "192.168.2.1");
|
||||||
robot->state = STOPPED;
|
|
||||||
robot->state = SETTING_SDK_MODE;
|
robot->state = SETTING_SDK_MODE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -182,22 +150,6 @@ robot_work(Robot robot) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SUBSCRIBING_POSITION_STATUS:
|
|
||||||
{
|
|
||||||
add_sub_msg ( &req, robot->seq++, true, 20, 1, DDS_POSITION );
|
|
||||||
req_send(robot->client->dev_conn, &req);
|
|
||||||
robot->state = SUBSCRIBING_GIMBAL_STATUS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case SUBSCRIBING_GIMBAL_STATUS:
|
|
||||||
{
|
|
||||||
add_sub_msg ( &req, robot->seq++, true, 21, 1, DDS_GIMBAL_POS );
|
|
||||||
req_send(robot->client->dev_conn, &req);
|
|
||||||
robot->state = WAITING;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case READY:
|
case READY:
|
||||||
{
|
{
|
||||||
if(robot->dirty_wheels) {
|
if(robot->dirty_wheels) {
|
||||||
@@ -233,32 +185,6 @@ robot_work(Robot robot) {
|
|||||||
req_send(robot->client->dev_conn, &req);
|
req_send(robot->client->dev_conn, &req);
|
||||||
robot->dirty_colors = false;
|
robot->dirty_colors = false;
|
||||||
}
|
}
|
||||||
if(robot->dirty_blaster) {
|
|
||||||
blaster_fire (
|
|
||||||
&req, robot->seq++, false,
|
|
||||||
FIRETYPE_INFRARED,
|
|
||||||
ONE
|
|
||||||
);
|
|
||||||
req_send(robot->client->dev_conn, &req);
|
|
||||||
robot->dirty_blaster = false;
|
|
||||||
}
|
|
||||||
if(robot->dirty_stream) {
|
|
||||||
stream_ctrl (
|
|
||||||
&req, robot->seq++, true,
|
|
||||||
robot->stream_state ? STREAMSTATE_ON : STREAMSTATE_OFF,
|
|
||||||
RES_720P,
|
|
||||||
STREAMCTRL_SDK
|
|
||||||
);
|
|
||||||
req_send(robot->client->dev_conn, &req);
|
|
||||||
stream_ctrl (
|
|
||||||
&req, robot->seq++, true,
|
|
||||||
robot->stream_state ? STREAMSTATE_ON : STREAMSTATE_OFF,
|
|
||||||
RES_720P,
|
|
||||||
STREAMCTRL_VIDEO
|
|
||||||
);
|
|
||||||
req_send(robot->client->dev_conn, &req);
|
|
||||||
robot->dirty_stream = false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,15 +198,12 @@ robot_work(Robot robot) {
|
|||||||
switch(resp.header.cmd) {
|
switch(resp.header.cmd) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
case SET_SDK_CONNECTION_CMD:
|
case SET_SDK_CONNECTION_CMD:
|
||||||
// TODO: Do more with this
|
// TODO: Do more with this
|
||||||
if(resp.resp.sdkconn.retcode) {
|
if(resp.resp.sdkconn.retcode) {
|
||||||
robot->state = STOPPED;
|
robot->state = STOPPED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
robot->client->dev_conn = connection_new(10010, resp.resp.sdkconn.config_ip, 20020, ROBOT_DEFAULT_WIFI_ADDR);
|
|
||||||
robot->state = CONNECTING_TO_DEVICE_PORT;
|
robot->state = CONNECTING_TO_DEVICE_PORT;
|
||||||
break;
|
break;
|
||||||
case SET_SDK_MODE_CMD:
|
case SET_SDK_MODE_CMD:
|
||||||
@@ -310,13 +233,6 @@ robot_work(Robot robot) {
|
|||||||
robot->state = STOPPED;
|
robot->state = STOPPED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
robot->state = SUBSCRIBING_POSITION_STATUS;
|
|
||||||
break;
|
|
||||||
case ADD_SUB_MSG_CMD:
|
|
||||||
if(resp.resp.sub.retcode) {
|
|
||||||
robot->state = STOPPED;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
robot->state = SENDING_HEARTBEAT;
|
robot->state = SENDING_HEARTBEAT;
|
||||||
break;
|
break;
|
||||||
case SDK_HEARTBEAT_CMD:
|
case SDK_HEARTBEAT_CMD:
|
||||||
@@ -326,20 +242,6 @@ robot_work(Robot robot) {
|
|||||||
}
|
}
|
||||||
robot->state = READY;
|
robot->state = READY;
|
||||||
break;
|
break;
|
||||||
case PUSH_PERIOD_MSG_CMD:
|
|
||||||
switch(resp.resp.push.msg_id) {
|
|
||||||
case 20:
|
|
||||||
robot->x = resp.resp.push.position.x;
|
|
||||||
robot->y = resp.resp.push.position.y;
|
|
||||||
robot->z = resp.resp.push.position.z;
|
|
||||||
break;
|
|
||||||
case 21:
|
|
||||||
robot->yaw_ground = resp.resp.push.gimbal.yaw_ground;
|
|
||||||
robot->pitch_ground = resp.resp.push.gimbal.pitch_ground;
|
|
||||||
robot->yaw = resp.resp.push.gimbal.yaw;
|
|
||||||
robot->pitch = resp.resp.push.gimbal.pitch;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -51,8 +51,6 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
Robot robot = robot_new();
|
Robot robot = robot_new();
|
||||||
robot_init(robot);
|
robot_init(robot);
|
||||||
robot_stream(robot, true);
|
|
||||||
|
|
||||||
SDL_AddTimer(75, drive_timer_handler, robot);
|
SDL_AddTimer(75, drive_timer_handler, robot);
|
||||||
SDL_AddTimer(1000, heartbeat_timer_handler, robot);
|
SDL_AddTimer(1000, heartbeat_timer_handler, robot);
|
||||||
|
|
||||||
@@ -92,9 +90,6 @@ int main(int argc, char* argv[]) {
|
|||||||
robot_led(robot, colors[color].r, colors[color].g, colors[color].b);
|
robot_led(robot, colors[color].r, colors[color].g, colors[color].b);
|
||||||
color = (color + 1) % 3;
|
color = (color + 1) % 3;
|
||||||
break;
|
break;
|
||||||
case SDL_SCANCODE_RETURN:
|
|
||||||
robot_blast(robot);
|
|
||||||
break;
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user