-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from xrobot-org/dev
修改自定义控制器&提交飞镖/无人机相关代码
- Loading branch information
Showing
12 changed files
with
347 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,50 @@ | ||
#include "comp_cmd.hpp" | ||
#include "comp_ui.hpp" | ||
#include "device.hpp" | ||
|
||
namespace Device { | ||
class CustomController { | ||
public: | ||
CustomController(); | ||
typedef struct { | ||
float offset[6]; | ||
} Param; | ||
|
||
CustomController(Param& param); | ||
|
||
typedef struct __attribute__((packed)) { | ||
struct __attribute__((packed)) { | ||
uint8_t sof; // 起始字节,固定值为0xA5 | ||
uint16_t data_length; // 数据帧中data的长度 | ||
uint8_t seq; // 包序号 | ||
uint8_t crc8; // 帧头CRC8校验 | ||
} frame_header; // 帧头 | ||
uint16_t cmd_id; // 命令码 | ||
union __attribute__((packed)) { | ||
float angle[6]; // 自定义控制器的数据帧 | ||
uint8_t raw_data[30]; | ||
}; | ||
} Data; // 自定义控制器数据包 | ||
|
||
typedef enum { NUM = 144 } ControllerEvent; | ||
|
||
Param param_; | ||
|
||
bool online_ = false; | ||
|
||
uint32_t last_online_time_ = 0; | ||
|
||
bool StartRecv(); | ||
|
||
void Prase(); | ||
|
||
void Offline(); | ||
|
||
private: | ||
System::Semaphore packet_recv_ = System::Semaphore(false); | ||
Data data_; | ||
|
||
Message::Topic<Component::CMD::Data> controller_angel_ = | ||
Message::Topic<Component::CMD::Data>("collectangle"); | ||
System::Semaphore packet_recv_ = System::Semaphore(false); | ||
|
||
Message::Event event_; | ||
System::Thread recv_thread_; | ||
System::Thread trans_thread_; | ||
Component::CMD::Data controller_data_{}; | ||
}; | ||
} // namespace Device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.