aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.clang-format121
-rw-r--r--.gitignore3
-rw-r--r--CMakeLists.txt4
-rwxr-xr-x[-rw-r--r--]lib/arm64-v8a/liblcm.so (renamed from lib/aarch64/liblcm.so)bin95736 -> 95736 bytes
-rwxr-xr-xlib/x86_64/liblcm.so (renamed from lib/x86/liblcm.so)bin144320 -> 144320 bytes
-rwxr-xr-xrunme.sh34
-rw-r--r--serial/CMakeLists.txt2
-rw-r--r--serial/serial.c31
-rw-r--r--serial/serial.h6
-rw-r--r--serial/wheel.c7
-rw-r--r--udp2lcm/CMakeLists.txt2
-rw-r--r--udp2lcm/udp.c30
-rw-r--r--udp2lcm/udp2lcm.c48
-rw-r--r--udp2lcm/udp2lcm.h6
14 files changed, 264 insertions, 30 deletions
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..a1054a5
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,121 @@
1---
2Language: Cpp
3# BasedOnStyle: LLVM
4AccessModifierOffset: -2
5AlignAfterOpenBracket: Align
6AlignConsecutiveAssignments: false
7AlignConsecutiveDeclarations: false
8AlignEscapedNewlines: Right
9AlignOperands: true
10AlignTrailingComments: true
11AllowAllParametersOfDeclarationOnNextLine: true
12AllowShortBlocksOnASingleLine: false
13AllowShortCaseLabelsOnASingleLine: false
14AllowShortFunctionsOnASingleLine: All
15AllowShortIfStatementsOnASingleLine: false
16AllowShortLoopsOnASingleLine: false
17AlwaysBreakAfterDefinitionReturnType: None
18AlwaysBreakAfterReturnType: None
19AlwaysBreakBeforeMultilineStrings: false
20AlwaysBreakTemplateDeclarations: MultiLine
21BinPackArguments: true
22BinPackParameters: true
23BraceWrapping:
24 AfterClass: false
25 AfterControlStatement: false
26 AfterEnum: false
27 AfterFunction: false
28 AfterNamespace: false
29 AfterObjCDeclaration: false
30 AfterStruct: false
31 AfterUnion: false
32 AfterExternBlock: false
33 BeforeCatch: false
34 BeforeElse: false
35 IndentBraces: false
36 SplitEmptyFunction: true
37 SplitEmptyRecord: true
38 SplitEmptyNamespace: true
39BreakBeforeBinaryOperators: None
40BreakBeforeBraces: Attach
41BreakBeforeInheritanceComma: false
42BreakInheritanceList: BeforeColon
43BreakBeforeTernaryOperators: true
44BreakConstructorInitializersBeforeComma: false
45BreakConstructorInitializers: BeforeColon
46BreakAfterJavaFieldAnnotations: false
47BreakStringLiterals: true
48ColumnLimit: 80
49CommentPragmas: '^ IWYU pragma:'
50CompactNamespaces: false
51ConstructorInitializerAllOnOneLineOrOnePerLine: false
52ConstructorInitializerIndentWidth: 4
53ContinuationIndentWidth: 4
54Cpp11BracedListStyle: true
55DerivePointerAlignment: false
56DisableFormat: false
57ExperimentalAutoDetectBinPacking: false
58FixNamespaceComments: true
59ForEachMacros:
60 - foreach
61 - Q_FOREACH
62 - BOOST_FOREACH
63IncludeBlocks: Preserve
64IncludeCategories:
65 - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
66 Priority: 2
67 - Regex: '^(<|"(gtest|gmock|isl|json)/)'
68 Priority: 3
69 - Regex: '.*'
70 Priority: 1
71IncludeIsMainRegex: '(Test)?$'
72IndentCaseLabels: false
73IndentPPDirectives: None
74IndentWidth: 4
75IndentWrappedFunctionNames: false
76JavaScriptQuotes: Leave
77JavaScriptWrapImports: true
78KeepEmptyLinesAtTheStartOfBlocks: true
79MacroBlockBegin: ''
80MacroBlockEnd: ''
81MaxEmptyLinesToKeep: 1
82NamespaceIndentation: None
83ObjCBinPackProtocolList: Auto
84ObjCBlockIndentWidth: 2
85ObjCSpaceAfterProperty: false
86ObjCSpaceBeforeProtocolList: true
87PenaltyBreakAssignment: 2
88PenaltyBreakBeforeFirstCallParameter: 19
89PenaltyBreakComment: 300
90PenaltyBreakFirstLessLess: 120
91PenaltyBreakString: 1000
92PenaltyBreakTemplateDeclaration: 10
93PenaltyExcessCharacter: 1000000
94PenaltyReturnTypeOnItsOwnLine: 60
95PointerAlignment: Right
96ReflowComments: true
97SortIncludes: true
98SortUsingDeclarations: true
99SpaceAfterCStyleCast: false
100SpaceAfterTemplateKeyword: true
101SpaceBeforeAssignmentOperators: true
102SpaceBeforeCpp11BracedList: false
103SpaceBeforeCtorInitializerColon: true
104SpaceBeforeInheritanceColon: true
105SpaceBeforeParens: ControlStatements
106SpaceBeforeRangeBasedForLoopColon: true
107SpaceInEmptyParentheses: false
108SpacesBeforeTrailingComments: 1
109SpacesInAngles: false
110SpacesInContainerLiterals: true
111SpacesInCStyleCastParentheses: false
112SpacesInParentheses: false
113SpacesInSquareBrackets: false
114Standard: Cpp11
115StatementMacros:
116 - Q_UNUSED
117 - QT_REQUIRE_VERSION
118TabWidth: 8
119UseTab: Never
120...
121
diff --git a/.gitignore b/.gitignore
index 938c377..9497a1d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
1build/* 1build/*
2bin/* 2bin/*
3.vscode/* \ No newline at end of file 3.vscode/*
4compile_commands.json
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c487036..c01ccfc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,10 +9,10 @@ include_directories(
9) 9)
10# 添加库文件路径 10# 添加库文件路径
11link_directories( 11link_directories(
12 ${CMAKE_SOURCE_DIR}/lib 12 ${CMAKE_SOURCE_DIR}/lib/${OHOS_ARCH}
13) 13)
14# 设置输出路径 14# 设置输出路径
15set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) 15set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
16 16
17add_subdirectory(serial) 17add_subdirectory(serial)
18add_subdirectory(udp2lcm) \ No newline at end of file 18add_subdirectory(udp2lcm)
diff --git a/lib/aarch64/liblcm.so b/lib/arm64-v8a/liblcm.so
index 98bb954..98bb954 100644..100755
--- a/lib/aarch64/liblcm.so
+++ b/lib/arm64-v8a/liblcm.so
Binary files differ
diff --git a/lib/x86/liblcm.so b/lib/x86_64/liblcm.so
index cb18db8..cb18db8 100755
--- a/lib/x86/liblcm.so
+++ b/lib/x86_64/liblcm.so
Binary files differ
diff --git a/runme.sh b/runme.sh
new file mode 100755
index 0000000..947d50a
--- /dev/null
+++ b/runme.sh
@@ -0,0 +1,34 @@
1#!/bin/bash
2
3##########################################################################
4# File Name : compile.sh
5# Encoding : utf-8
6# Author : We-unite
7# Email : weunite1848@gmail.com
8# Created Time : 2024-02-29 15:19:15
9##########################################################################
10
11set -e
12
13if [ $UID -eq 0 ]; then
14 echo "Please do not run this script as root"
15 exit 1
16fi
17
18if [ $# -ne 1 ]; then
19 echo "ERROR: $0 <arm64-v8a|x86_64>"
20 exit 1
21fi
22
23arch=$1
24link=static # or shared
25native_path=/home/player/app/native
26
27if [ $arch == "arm64-v8a" ]; then
28 export PATH=$native_path/build-tools/cmake/bin:$PATH
29 cmake -B build -D OHOS_STL=c++_$link -D OHOS_ARCH=$arch -D OHOS_PLATFORM=OHOS -D CMAKE_TOOLCHAIN_FILE=$(find $native_path -name ohos.toolchain.cmake)
30else
31 cmake -B build -D OHOS_ARCH=$arch
32fi
33
34cmake --build build
diff --git a/serial/CMakeLists.txt b/serial/CMakeLists.txt
index 5ded98c..c0bc05a 100644
--- a/serial/CMakeLists.txt
+++ b/serial/CMakeLists.txt
@@ -8,4 +8,4 @@ aux_source_directory(${CMAKE_SOURCE_DIR}/lcmtype DIR_SRCS)
8add_executable(serial ${DIR_SRCS}) 8add_executable(serial ${DIR_SRCS})
9 9
10# 添加链接库 10# 添加链接库
11target_link_libraries(serial lcm) \ No newline at end of file 11target_link_libraries(serial lcm pthread)
diff --git a/serial/serial.c b/serial/serial.c
index a2f253a..6163703 100644
--- a/serial/serial.c
+++ b/serial/serial.c
@@ -1,7 +1,12 @@
1#include "serial.h" 1#include "serial.h"
2#include <math.h>
2 3
3lcm_t *lcm; 4lcm_t *lcm;
4 5
6// TODO 屏蔽停止指令
7bool stopFlag = false;
8////////////////////////
9
5int curStatus = -1, curSpeed = 0; // 这里的速度指百分比速度 10int curStatus = -1, curSpeed = 0; // 这里的速度指百分比速度
6double curOmega = 0.0; 11double curOmega = 0.0;
7// 临界区数据 12// 临界区数据
@@ -72,6 +77,23 @@ void parseCmd(const lcm_recv_buf_t *rbuf, const char *channel,
72 curOmega = (double)-DEFAULT_SPEED * FULLSPEED / 100 / RADIUS; 77 curOmega = (double)-DEFAULT_SPEED * FULLSPEED / 100 / RADIUS;
73 curSpeed = 0; 78 curSpeed = 0;
74 break; 79 break;
80 // TODO 屏蔽停止指令
81 case 4:
82 wheelSend(0x00, 0x00, 0x00, 0x00);
83 curOmega = 0;
84 curSpeed = 0;
85 stopFlag = true;
86 printf("Stop for 2 seconds\n");
87 break;
88 // 取消屏蔽
89 case 5:
90 wheelSend(0x00, 0x00, 0x00, 0x00);
91 curOmega = 0;
92 curSpeed = 0;
93 stopFlag = false;
94 printf("Stop but can recieve cmd\n");
95 break;
96 ////////////////////////////////////
75 case 0: 97 case 0:
76 default: 98 default:
77 wheelSend(0x00, 0x00, 0x00, 0x00); 99 wheelSend(0x00, 0x00, 0x00, 0x00);
@@ -85,6 +107,11 @@ void parseCmd(const lcm_recv_buf_t *rbuf, const char *channel,
85 107
86void parsePath(const lcm_recv_buf_t *rbuf, const char *channel, 108void parsePath(const lcm_recv_buf_t *rbuf, const char *channel,
87 const path_t *msg, void *userdata) { 109 const path_t *msg, void *userdata) {
110 // TODO
111 if (stopFlag) {
112 return;
113 }
114 /////////////////
88 int16_t length = msg->length; 115 int16_t length = msg->length;
89 double v, w; 116 double v, w;
90 int8_t vWheels[2]; 117 int8_t vWheels[2];
@@ -127,7 +154,7 @@ void setCurPose(const lcm_recv_buf_t *rbuf, const char *channel,
127 pthread_mutex_unlock(&curPoseMutex); 154 pthread_mutex_unlock(&curPoseMutex);
128} 155}
129 156
130void sendCurPose() { 157void *sendCurPose(void *args) {
131 pose_t pose; 158 pose_t pose;
132 while (true) { 159 while (true) {
133 renewCurPose(); 160 renewCurPose();
@@ -152,4 +179,4 @@ void renewCurPose() {
152 curPose[2] += curOmega * dt; 179 curPose[2] += curOmega * dt;
153 lastTime = clock(); 180 lastTime = clock();
154 pthread_mutex_unlock(&curPoseMutex); 181 pthread_mutex_unlock(&curPoseMutex);
155} \ No newline at end of file 182}
diff --git a/serial/serial.h b/serial/serial.h
index 3563557..2fbf870 100644
--- a/serial/serial.h
+++ b/serial/serial.h
@@ -19,7 +19,7 @@
19// TODO: 两个待测数据 19// TODO: 两个待测数据
20#define RADIUS 0.13 // 两轮之间的距离的一半,米 20#define RADIUS 0.13 // 两轮之间的距离的一半,米
21#define FULLSPEED 0.60 // 轮子全速,m/s 21#define FULLSPEED 0.60 // 轮子全速,m/s
22#define fabs(x) ((x) > 0 ? (x) : -(x)) 22// #define fabs(x) ((x) > 0 ? (x) : -(x))
23typedef unsigned char byte; 23typedef unsigned char byte;
24 24
25int identify_device(const char *port); 25int identify_device(const char *port);
@@ -34,6 +34,6 @@ void parsePath(const lcm_recv_buf_t *rbuf, const char *channel,
34void setCurPose(const lcm_recv_buf_t *rbuf, const char *channel, 34void setCurPose(const lcm_recv_buf_t *rbuf, const char *channel,
35 const pose_t *msg, void *userdata); 35 const pose_t *msg, void *userdata);
36void renewCurPose(); 36void renewCurPose();
37void sendCurPose(); 37void *sendCurPose(void *args);
38 38
39#endif \ No newline at end of file 39#endif
diff --git a/serial/wheel.c b/serial/wheel.c
index 8155734..c470234 100644
--- a/serial/wheel.c
+++ b/serial/wheel.c
@@ -5,7 +5,8 @@ char *portname; // 串口设备名
5struct termios tty; 5struct termios tty;
6 6
7bool whellInit() { 7bool whellInit() {
8 portname = findUSBDev("wheel"); 8 // portname = findUSBDev("wheel");
9 portname = "/dev/ttyUSB1"; // "/dev/ttyUSB1
9 if (portname == NULL) { 10 if (portname == NULL) {
10 fprintf(stderr, "Error: Failed to find wheel serial port\n"); 11 fprintf(stderr, "Error: Failed to find wheel serial port\n");
11 return false; 12 return false;
@@ -55,6 +56,10 @@ bool wheelSend(byte a, byte a_v, byte b, byte b_v) {
55 unsigned char data[7] = {0x53, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00}; 56 unsigned char data[7] = {0x53, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00};
56 byte checksum = 0; 57 byte checksum = 0;
57 data[2] = a; 58 data[2] = a;
59 // TODO: 速度转换
60 int temp = ((int)a_v + 2);
61 a_v = (byte)temp;
62 ////////////////////////
58 data[3] = a_v; 63 data[3] = a_v;
59 data[4] = b; 64 data[4] = b;
60 data[5] = b_v; 65 data[5] = b_v;
diff --git a/udp2lcm/CMakeLists.txt b/udp2lcm/CMakeLists.txt
index aaf54db..206a8a8 100644
--- a/udp2lcm/CMakeLists.txt
+++ b/udp2lcm/CMakeLists.txt
@@ -7,4 +7,4 @@ aux_source_directory(${CMAKE_SOURCE_DIR}/lcmtype DIR_SRCS)
7 7
8# 生成可执行文件 8# 生成可执行文件
9add_executable(udp2lcm ${DIR_SRCS}) 9add_executable(udp2lcm ${DIR_SRCS})
10target_link_libraries(udp2lcm lcm) \ No newline at end of file 10target_link_libraries(udp2lcm lcm pthread)
diff --git a/udp2lcm/udp.c b/udp2lcm/udp.c
index 6c4bd4a..97fb53e 100644
--- a/udp2lcm/udp.c
+++ b/udp2lcm/udp.c
@@ -1,6 +1,6 @@
1#include "udp2lcm.h" 1#include "udp2lcm.h"
2 2
3void udpRecvHandler() { 3void *udpRecvHandler(void *args) {
4 int socketfd = -1; 4 int socketfd = -1;
5 char buffer[MAX_BUFFER_SIZE]; 5 char buffer[MAX_BUFFER_SIZE];
6 struct sockaddr_in serverAddr; 6 struct sockaddr_in serverAddr;
@@ -13,7 +13,7 @@ void udpRecvHandler() {
13 printf("udpRecvHandler\n"); 13 printf("udpRecvHandler\n");
14 if ((socketfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) { 14 if ((socketfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
15 fprintf(stderr, "Error: Failed to create socket\n"); 15 fprintf(stderr, "Error: Failed to create socket\n");
16 return; 16 return NULL;
17 } 17 }
18 memset((char *)&serverAddr, 0, sizeof(serverAddr)); 18 memset((char *)&serverAddr, 0, sizeof(serverAddr));
19 memset(buffer, 0, sizeof(buffer)); 19 memset(buffer, 0, sizeof(buffer));
@@ -25,7 +25,7 @@ void udpRecvHandler() {
25 -1) { 25 -1) {
26 fprintf(stderr, "Error: Bind failed\n"); 26 fprintf(stderr, "Error: Bind failed\n");
27 close(socketfd); 27 close(socketfd);
28 return; 28 return NULL;
29 } 29 }
30 30
31 bytesReceived = recvfrom(socketfd, buffer, MAX_BUFFER_SIZE, 0, 31 bytesReceived = recvfrom(socketfd, buffer, MAX_BUFFER_SIZE, 0,
@@ -33,7 +33,7 @@ void udpRecvHandler() {
33 if (bytesReceived == -1) { 33 if (bytesReceived == -1) {
34 fprintf(stderr, "Error: Failed to receive data\n"); 34 fprintf(stderr, "Error: Failed to receive data\n");
35 close(socketfd); 35 close(socketfd);
36 return; 36 return NULL;
37 } 37 }
38 printf("Start message from %s: %s\n", inet_ntoa(clientAddr.sin_addr), 38 printf("Start message from %s: %s\n", inet_ntoa(clientAddr.sin_addr),
39 buffer); 39 buffer);
@@ -57,13 +57,13 @@ void udpRecvHandler() {
57 robotCtrlData.iparams[0] = 1; 57 robotCtrlData.iparams[0] = 1;
58 robot_control_t_publish(lcm, "ROBOT_CONTROL", &robotCtrlData); 58 robot_control_t_publish(lcm, "ROBOT_CONTROL", &robotCtrlData);
59 freeRobotCtrl(&robotCtrlData); 59 freeRobotCtrl(&robotCtrlData);
60 // 随即下达30号命令,开始建图 60 // // 随即下达30号命令,开始建图
61 robotCtrlInit(&robotCtrlData, 0, 30, 0, 1, 1, 0, 0); 61 // robotCtrlInit(&robotCtrlData, 0, 30, 0, 1, 1, 0, 0);
62 robotCtrlData.dparams[0] = 0.05; 62 // robotCtrlData.dparams[0] = 0.05;
63 robotCtrlData.niparams = 1; 63 // robotCtrlData.niparams = 1;
64 robotCtrlData.iparams[0] = 1; 64 // robotCtrlData.iparams[0] = 1;
65 robot_control_t_publish(lcm, "ROBOT_CONTROL", &robotCtrlData); 65 // robot_control_t_publish(lcm, "ROBOT_CONTROL", &robotCtrlData);
66 freeRobotCtrl(&robotCtrlData); 66 // freeRobotCtrl(&robotCtrlData);
67 67
68 /* 68 /*
69 * 开始接收来自手机端的命令 69 * 开始接收来自手机端的命令
@@ -99,13 +99,13 @@ void udpRecvHandler() {
99 } 99 }
100} 100}
101 101
102void udpSendHandler() { 102void *udpSendHandler(void *args) {
103 // 创建UDP套接字 103 // 创建UDP套接字
104 int sockfd = -1; 104 int sockfd = -1;
105 struct sockaddr_in serverAddr; 105 struct sockaddr_in serverAddr;
106 if ((sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) { 106 if ((sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
107 fprintf(stderr, "Error: Failed to create socket\n"); 107 fprintf(stderr, "Error: Failed to create socket\n");
108 return; 108 return NULL;
109 } 109 }
110 110
111 memset((char *)&serverAddr, 0, sizeof(serverAddr)); 111 memset((char *)&serverAddr, 0, sizeof(serverAddr));
@@ -114,7 +114,7 @@ void udpSendHandler() {
114 if (inet_aton(clientIP, &serverAddr.sin_addr) == 0) { 114 if (inet_aton(clientIP, &serverAddr.sin_addr) == 0) {
115 fprintf(stderr, "Error: Failed to convert IP address\n"); 115 fprintf(stderr, "Error: Failed to convert IP address\n");
116 close(sockfd); 116 close(sockfd);
117 return; 117 return NULL;
118 } 118 }
119 119
120 while (true) { 120 while (true) {
@@ -124,4 +124,4 @@ void udpSendHandler() {
124 pthread_mutex_unlock(&heartBeatMutex); 124 pthread_mutex_unlock(&heartBeatMutex);
125 sleep(1); 125 sleep(1);
126 } 126 }
127} \ No newline at end of file 127}
diff --git a/udp2lcm/udp2lcm.c b/udp2lcm/udp2lcm.c
index 36100da..5514b24 100644
--- a/udp2lcm/udp2lcm.c
+++ b/udp2lcm/udp2lcm.c
@@ -71,7 +71,13 @@ void parseCmd(const char *buffer, int bytesReceived) {
71 if (buffer[0] == 0) { 71 if (buffer[0] == 0) {
72 // 手机端用来与udp2lcm服务器建立连接的初始化消息 72 // 手机端用来与udp2lcm服务器建立连接的初始化消息
73 // 也是手机端的心跳 73 // 也是手机端的心跳
74 ; 74 // 下达30号命令,开始建图
75 robotCtrlInit(&robotCtrlData, 0, 30, 0, 1, 1, 0, 0);
76 robotCtrlData.dparams[0] = 0.05;
77 robotCtrlData.niparams = 1;
78 robotCtrlData.iparams[0] = 1;
79 robot_control_t_publish(lcm, "ROBOT_CONTROL", &robotCtrlData);
80 freeRobotCtrl(&robotCtrlData);
75 } else if (buffer[0] == 1) { 81 } else if (buffer[0] == 1) {
76 // 建图过程中,手机端遥控小车进行移动,命令下发至轮控模块 82 // 建图过程中,手机端遥控小车进行移动,命令下发至轮控模块
77 path.cmd = buffer[1]; 83 path.cmd = buffer[1];
@@ -125,7 +131,47 @@ void parseCmd(const char *buffer, int bytesReceived) {
125 } else if (buffer[0] == 4) { 131 } else if (buffer[0] == 4) {
126 // 取消导航,删除上一个目标点 132 // 取消导航,删除上一个目标点
127 robotCtrlInit(&robotCtrlData, 0, 23, 0, 0, 0, 0, 0); 133 robotCtrlInit(&robotCtrlData, 0, 23, 0, 0, 0, 0, 0);
134 // TODO 第一次停止指令
135 printf("Cancel Navigation!\n");
136 path.cmd = 4;
137 path_ctrl_t_publish(lcm, "wheel_ctrl", &path);
138 /////////////////////////////
139 robot_control_t_publish(lcm, "ROBOT_CONTROL", &robotCtrlData);
140 // TODO 再次下达停止指令
141 sleep(2);
142 path.cmd = 5;
143 printf("Stop but can recieve cmd\n");
144 path_ctrl_t_publish(lcm, "wheel_ctrl", &path);
145 /////////////////////////
146 } else if (buffer[0] == 5) {
147 /*
148 加载地图,需要注意的是所加载的地图是由电脑控制端下发的
149 该部分由建图部分修改
150 */
151 path.cmd = 0;
152 path.speed = 0;
153 path_ctrl_t_publish(lcm, "wheel_ctrl", &path);
154
155 printf("Load Map!\n");
156 // robotCtrlInit(&robotCtrlData, 0, 32, 0, 0, 0, 0, 0);
157 // robot_control_t_publish(lcm, "ROBOT_CONTROL", &robotCtrlData);
158 // freeRobotCtrl(&robotCtrlData);
159
160 // sleep(2);
161
162 robotCtrlInit(&robotCtrlData, 0, 10, 0, 7, 0, 0, 0);
163 pthread_mutex_lock(&heartBeatMutex);
164 int16_t x, y, sita;
165 x = swapEndian(*(int16_t *)&heartBeat[3]);
166 y = swapEndian(*(int16_t *)&heartBeat[5]);
167 sita = swapEndian(*(int16_t *)&heartBeat[7]);
168 printf("NOW point: x: %d, y: %d, sita: %d\n", x, y, sita);
169 robotCtrlData.dparams[4] = 0;
170 robotCtrlData.dparams[5] = 0;
171 robotCtrlData.dparams[6] = 0;
172 pthread_mutex_unlock(&heartBeatMutex);
128 robot_control_t_publish(lcm, "ROBOT_CONTROL", &robotCtrlData); 173 robot_control_t_publish(lcm, "ROBOT_CONTROL", &robotCtrlData);
174 freeRobotCtrl(&robotCtrlData);
129 } else { 175 } else {
130 fprintf(stderr, "Error: Invalid command: "); 176 fprintf(stderr, "Error: Invalid command: ");
131 for (int i = 0; i < 9; i++) { 177 for (int i = 0; i < 9; i++) {
diff --git a/udp2lcm/udp2lcm.h b/udp2lcm/udp2lcm.h
index 1ab7cf3..e78bc73 100644
--- a/udp2lcm/udp2lcm.h
+++ b/udp2lcm/udp2lcm.h
@@ -33,8 +33,8 @@ extern char clientIP[20];
33extern lcm_t *lcm; 33extern lcm_t *lcm;
34 34
35bool LCMInit(); 35bool LCMInit();
36void udpSendHandler(); 36void *udpSendHandler(void *args);
37void udpRecvHandler(); 37void *udpRecvHandler(void *args);
38void parseCmd(const char *buffer, int bytesReceived); 38void parseCmd(const char *buffer, int bytesReceived);
39void robotCtrlInit(robot_control_t *robotCtrlData, int64_t utime, 39void robotCtrlInit(robot_control_t *robotCtrlData, int64_t utime,
40 int8_t commandid, int8_t robotid, int8_t ndparams, 40 int8_t commandid, int8_t robotid, int8_t ndparams,
@@ -44,4 +44,4 @@ void poseHandler(const lcm_recv_buf_t *rbuf, const char *channel,
44 const pose_t *msg, void *userdata); 44 const pose_t *msg, void *userdata);
45int16_t swapEndian(int16_t val); 45int16_t swapEndian(int16_t val);
46 46
47#endif \ No newline at end of file 47#endif