Skip to content

Commit e12de8c

Browse files
committed
add python wrapper for different python version
1 parent 7a09517 commit e12de8c

File tree

236 files changed

+48358
-872
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

236 files changed

+48358
-872
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ build
22

33
*.o
44
.vscode
5+
.clang-format

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64.*")
1515
endif()
1616

1717
link_directories(lib/cpp/${ARCH})
18-
set(EXTRA_LIBS -pthread libunitree_legged_sdk.so)
18+
set(EXTRA_LIBS -pthread libunitree_legged_sdk.a)
1919

2020
set(CMAKE_CXX_FLAGS "-O3 -fPIC")
2121

22+
add_subdirectory(python_wrapper)
23+
2224
# one pc one process
2325
add_executable(example_position example/example_position.cpp)
2426
target_link_libraries(example_position ${EXTRA_LIBS})

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# v3.8.0
1+
# v3.8.5
22
The unitree_legged_sdk is mainly used for communication between PC and Controller board.
33
It also can be used in other PCs with UDP.
44

55
### Notice
66
support robot: Go1
77

8-
not support robot: Laikago, Aliengo, A1. (Check release [v3.3.1](https://github.com/unitreerobotics/unitree_legged_sdk/releases/tag/v3.3.1) for support)
8+
not support robot: Laikago, B1, Aliengo, A1. (Check release [v3.3.1](https://github.com/unitreerobotics/unitree_legged_sdk/releases/tag/v3.3.1) for support)
99

1010
### Dependencies
11-
* [Unitree](https://www.unitree.com/go1_update)
11+
* [Unitree](https://www.unitree.com/download)
1212
```bash
1313
Legged_sport >= v1.36.0
1414
firmware H0.1.7 >= v0.1.35

example/example_joystick.cpp

Lines changed: 49 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/************************************************************************
2-
Copyright (c) 2020, Unitree Robotics.Co.Ltd. All rights reserved.
3-
Use of this source code is governed by the MPL-2.0 license, see LICENSE.
4-
************************************************************************/
1+
/**********************************************************************
2+
Copyright (c) 2020-2023, Unitree Robotics.Co.Ltd. All rights reserved.
3+
***********************************************************************/
54

65
#include "unitree_legged_sdk/unitree_legged_sdk.h"
76
#include "unitree_legged_sdk/joystick.h"
@@ -11,72 +10,66 @@ Use of this source code is governed by the MPL-2.0 license, see LICENSE.
1110

1211
using namespace UNITREE_LEGGED_SDK;
1312

14-
class Custom
15-
{
16-
public:
17-
Custom(uint8_t level):
18-
safe(LeggedType::Go1),
19-
udp(level, 8090, "192.168.123.10", 8007){
20-
udp.InitCmdData(cmd);
21-
}
22-
void UDPSend();
23-
void UDPRecv();
24-
void RobotControl();
13+
class Custom {
14+
public:
15+
Custom(uint8_t level) : safe(LeggedType::Go1),
16+
udp(level, 8090, "192.168.123.10", 8007) {
17+
udp.InitCmdData(cmd);
18+
}
19+
void UDPSend();
20+
void UDPRecv();
21+
void RobotControl();
2522

26-
Safety safe;
27-
UDP udp;
28-
LowCmd cmd = {0};
29-
LowState state = {0};
30-
xRockerBtnDataStruct _keyData;
31-
int motiontime = 0;
32-
float dt = 0.002; // 0.001~0.01
23+
Safety safe;
24+
UDP udp;
25+
LowCmd cmd = {0};
26+
LowState state = {0};
27+
xRockerBtnDataStruct _keyData;
28+
int motiontime = 0;
29+
float dt = 0.002; // 0.001~0.01
3330
};
3431

35-
void Custom::UDPRecv()
36-
{
37-
udp.Recv();
32+
void Custom::UDPRecv() {
33+
udp.Recv();
3834
}
3935

40-
void Custom::UDPSend()
41-
{
42-
udp.Send();
36+
void Custom::UDPSend() {
37+
udp.Send();
4338
}
4439

45-
void Custom::RobotControl()
46-
{
47-
motiontime++;
48-
udp.GetRecv(state);
40+
void Custom::RobotControl() {
41+
motiontime++;
42+
udp.GetRecv(state);
4943

50-
memcpy(&_keyData, &state.wirelessRemote[0], 40);
44+
memcpy(&_keyData, &state.wirelessRemote[0], 40);
5145

52-
if((int)_keyData.btn.components.A == 1){
53-
std::cout << "The key A is pressed, and the value of lx is " << _keyData.lx << std::endl;
54-
}
46+
if ((int)_keyData.btn.components.A == 1) {
47+
std::cout << "The key A is pressed, and the value of lx is " << _keyData.lx << std::endl;
48+
}
5549

56-
safe.PowerProtect(cmd, state, 1);
57-
udp.SetSend(cmd);
50+
safe.PowerProtect(cmd, state, 1);
51+
udp.SetSend(cmd);
5852
}
5953

60-
int main(void)
61-
{
62-
std::cout << "Communication level is set to LOW-level." << std::endl
63-
<< "WARNING: Make sure the robot is hung up." << std::endl
64-
<< "Press Enter to continue..." << std::endl;
65-
std::cin.ignore();
54+
int main(void) {
55+
std::cout << "Communication level is set to LOW-level." << std::endl
56+
<< "WARNING: Make sure the robot is hung up." << std::endl
57+
<< "Press Enter to continue..." << std::endl;
58+
std::cin.ignore();
6659

67-
Custom custom(LOWLEVEL);
68-
// InitEnvironment();
69-
LoopFunc loop_control("control_loop", custom.dt, boost::bind(&Custom::RobotControl, &custom));
70-
LoopFunc loop_udpSend("udp_send", custom.dt, 3, boost::bind(&Custom::UDPSend, &custom));
71-
LoopFunc loop_udpRecv("udp_recv", custom.dt, 3, boost::bind(&Custom::UDPRecv, &custom));
60+
Custom custom(LOWLEVEL);
61+
// InitEnvironment();
62+
LoopFunc loop_control("control_loop", custom.dt, boost::bind(&Custom::RobotControl, &custom));
63+
LoopFunc loop_udpSend("udp_send", custom.dt, 3, boost::bind(&Custom::UDPSend, &custom));
64+
LoopFunc loop_udpRecv("udp_recv", custom.dt, 3, boost::bind(&Custom::UDPRecv, &custom));
7265

73-
loop_udpSend.start();
74-
loop_udpRecv.start();
75-
loop_control.start();
66+
loop_udpSend.start();
67+
loop_udpRecv.start();
68+
loop_control.start();
7669

77-
while(1){
78-
sleep(10);
79-
};
70+
while (1) {
71+
sleep(10);
72+
};
8073

81-
return 0;
74+
return 0;
8275
}

0 commit comments

Comments
 (0)