Skip to content

Commit 99adb0a

Browse files
author
jake.luo
committed
init
0 parents  commit 99adb0a

File tree

252 files changed

+31703
-0
lines changed

Some content is hidden

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

252 files changed

+31703
-0
lines changed

LICENSE

Lines changed: 2068 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Robomaster自主无人机
2+
3+
## 注意
4+
组装文档中采用了悬挂方案安装飞控,该方案能够极大地减小震动对imu的影响。但是长时间的拉伸会使得皮筋产生脆化而失去弹性。将皮筋更换为工业橡皮筋可缓解该问题。同时碳纤维板上预留了飞控安装孔位,也可以选择直接将飞控安装到碳板上,但是该做法的imu减震性能不佳。
5+
6+
## 简介
7+
为了降低选手参与自主无人机赛事的门槛,减少用于调试安装设备的精力,推出了基于DJI Avata平台,Nvidia Jetson Xiaver NX 和 Ardupilot的开源自主无人机方案。
8+
*docs/RMUA2023自主无人机开源手册_bom.xlsx*包含有所需设备的详细信息,根据这个表格可以获得所需的所有零部件。
9+
*docs/RMUA2023自主无人机开源手册.md*详细介绍了安装,调试,参数配置,程序开发的全过程。按照该手册的指引,能够从0开始获得可以自主定位,手动或者离线控制的自主无人机。
10+
*models*中包含有所需的非标件模型文件。
11+
*catkin_ws_d430_ros*含有多个基本离线控制程序案例以供参考:
12+
1. 视觉定位 (*catkin_ws_d430_ros/src/d430_slam*);
13+
2. 定点悬浮 (*catkin_ws_d430_ros/src/offboard*);
14+
3. 位置控制巡航 (*catkin_ws_d430_ros/src/offboard*);
15+
4. 速度控制巡航 (*catkin_ws_d430_ros/src/offboard*);
16+
17+
## License
18+
本项目使用*GNU GPLv3*,查看*LICENSE*文件获得更多信息。
19+
20+

catkin_ws_d430_ros/set_origin.py

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Copyright © 2023 ROBOMASTER All Rights Reserved.
2+
# You may use, distribute and modify this code under the
3+
# terms of the MIT license, which unfortunately won't be
4+
# written for another century.
5+
6+
#!/usr/bin/env python
7+
8+
##
9+
#
10+
# Send SET_GPS_GLOBAL_ORIGIN and SET_HOME_POSITION messages
11+
#
12+
##
13+
14+
import rospy
15+
from pymavlink.dialects.v10 import ardupilotmega as MAV_APM
16+
from mavros.mavlink import convert_to_rosmsg
17+
from mavros_msgs.msg import Mavlink
18+
19+
# Global position of the origin
20+
lat = 425633500 # Terni
21+
lon = 126432900 # Terni
22+
alt = 163000
23+
24+
class fifo(object):
25+
""" A simple buffer """
26+
def __init__(self):
27+
self.buf = []
28+
def write(self, data):
29+
self.buf += data
30+
return len(data)
31+
def read(self):
32+
return self.buf.pop(0)
33+
34+
def send_message(msg, mav, pub):
35+
"""
36+
Send a mavlink message
37+
"""
38+
msg.pack(mav)
39+
rosmsg = convert_to_rosmsg(msg)
40+
pub.publish(rosmsg)
41+
42+
print("sent message %s" % msg)
43+
44+
def set_global_origin(mav, pub):
45+
"""
46+
Send a mavlink SET_GPS_GLOBAL_ORIGIN message, which allows us
47+
to use local position information without a GPS.
48+
"""
49+
target_system = mav.srcSystem
50+
#target_system = 0 # 0 --> broadcast to everyone
51+
lattitude = lat
52+
longitude = lon
53+
altitude = alt
54+
55+
msg = MAV_APM.MAVLink_set_gps_global_origin_message(
56+
target_system,
57+
lattitude,
58+
longitude,
59+
altitude)
60+
61+
send_message(msg, mav, pub)
62+
63+
def set_home_position(mav, pub):
64+
"""
65+
Send a mavlink SET_HOME_POSITION message, which should allow
66+
us to use local position information without a GPS
67+
"""
68+
target_system = 0
69+
#target_system = 0 # broadcast to everyone
70+
71+
lattitude = lat
72+
longitude = lon
73+
altitude = alt
74+
75+
x = 0
76+
y = 0
77+
z = 0
78+
q = [1, 0, 0, 0] # w x y z
79+
80+
approach_x = 0
81+
approach_y = 0
82+
approach_z = 0
83+
84+
msg = MAV_APM.MAVLink_set_home_position_message(
85+
target_system,
86+
lattitude,
87+
longitude,
88+
altitude,
89+
x,
90+
y,
91+
z,
92+
q,
93+
approach_x,
94+
approach_y,
95+
approach_z)
96+
97+
send_message(msg, mav, pub)
98+
99+
if __name__=="__main__":
100+
try:
101+
rospy.init_node("origin_publisher")
102+
mavlink_pub = rospy.Publisher("/mavlink/to", Mavlink, queue_size=20)
103+
104+
# Set up mavlink instance
105+
f = fifo()
106+
mav = MAV_APM.MAVLink(f, srcSystem=1, srcComponent=1)
107+
108+
# wait to initialize
109+
while mavlink_pub.get_num_connections() <= 0:
110+
pass
111+
112+
for _ in range(2):
113+
rospy.sleep(1)
114+
set_global_origin(mav, mavlink_pub)
115+
set_home_position(mav, mavlink_pub)
116+
except rospy.ROSInterruptException:
117+
pass
118+

catkin_ws_d430_ros/src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/opt/ros/noetic/share/catkin/cmake/toplevel.cmake
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
cmake_minimum_required(VERSION 3.0.2)
2+
project(apm_d430_bridge)
3+
4+
add_definitions(-std=c++11)
5+
6+
find_package(catkin REQUIRED COMPONENTS
7+
roscpp
8+
rospy
9+
dynamic_reconfigure
10+
tf
11+
mavros
12+
mavros_extras
13+
mavros_msgs
14+
mavlink
15+
)
16+
17+
catkin_package(
18+
INCLUDE_DIRS include
19+
CATKIN_DEPENDS roscpp rospy std_msgs mavros_msgs geometry_msgs mav_msgs sensor_msgs message_runtime tf
20+
# DEPENDS system_lib
21+
)
22+
23+
if(NOT CMAKE_BUILD_TYPE)
24+
set(CMAKE_BUILD_TYPE Release)
25+
endif(NOT CMAKE_BUILD_TYPE)
26+
27+
include_directories(
28+
include
29+
${catkin_INCLUDE_DIRS}
30+
${PCL_INCLUDE_DIRS}
31+
${YAML_CPP_INCLUDE_DIR}
32+
)
33+
34+
set(APM_D430_BRIDGE_CPP_FILES "src/nodes/apm_d430_bridge.cpp"
35+
"src/nodes/apm_d430_bridge_node.cpp"
36+
)
37+
38+
add_library(apm_d430_bridge "${APM_D430_BRIDGE_CPP_FILES}")
39+
40+
add_dependencies(apm_d430_bridge ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
41+
42+
add_executable(apm_d430_bridge_node src/nodes/apm_d430_bridge_node.cpp)
43+
44+
target_link_libraries(apm_d430_bridge_node
45+
apm_d430_bridge
46+
${catkin_LIBRARIES}
47+
${YAML_CPP_LIBRARIES})
48+

0 commit comments

Comments
 (0)