fix:新增例程

This commit is contained in:
2025-07-25 17:54:28 +08:00
parent 78481c265e
commit 637343d716
108 changed files with 5755 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
{
"VisionSensors":[
{
"SeqID":0, //视觉传感器序号0 1 2 3 ...排序。如果填0则自动递增排序。
"TypeID":20, //视觉传感器类型1:RGB2:深度3:灰度4:分割5:测距7:深度转点云20-23:激光雷达40-41:热力红外(收费版)
"TargetCopter":1, //传感器绑定的CopterID号注:免费版只支持绑定1号飞机
"TargetMountType":0, //绑定方式0:固定飞机几何中心, 1:固定飞机底部中心2:固定地面上3:弱固定飞机上姿态不随动4:绑定其他视觉传感器上
"DataWidth":900, //图像像素长度
"DataHeight":32,//图像像素宽度
"DataCheckFreq":10,//图像检查更新频率如果发现UE渲染更新了取决于UE刷新帧率会立刻发出数据。UE刷新率+DataCheckFreq检查频率共同决定图像延迟。
"SendProtocol":[1,0,0,0,0,0,0,0],// SendProtocol[0]表示传输协议0共享内存仅限Windows下获取图像1UDP网络传输模式图片使用jpeg压缩点云直传2UDP直传图片不压缩3UDP直传图片png压缩。注0-1适用所有传感器2-3选项仅限图像类传感器。
//SendProtocol[1-4]位对应IP地址位表示请求返回的IP地址。默认都填0或127.0.0.1会自动请求UE返回图像到本电脑SendProtocol[5]端口位指定传感器图像回传端口需要为每个传感器设置不同端口。默认填0会自动使用9999+SeqID的递增端口号。
"CameraFOV":90, //视觉传感器的FOV视场角和焦距呈现一定数值关系能间接修改焦距。
"EularOrQuat":0, //使用欧拉角SensorAngEular还是四元数SensorAngQuat来设置视觉传感器姿态默认使用0欧拉角。
"SensorPosXYZ":[0,0,-0.3], //视觉传感器的安装位置和TargetMountType对应偏移中心单位米
"SensorAngQuat":[0,0,0,0], // 视觉传感器的安装姿态,用四元数方式表示
"SensorAngEular":[0,0,0],// 视觉传感器的安装姿态,用欧拉角方式表示,单位角度制
"otherParams":[200,0.05,-45,45,-20,20,0,0,0,0,0,0,0,0,0,0] //其他参数
}
]
}

View File

@@ -0,0 +1,5 @@
if not defined PSP_PATH (
SET PSP_PATH=C:\PX4PSP
SET PSP_PATH_LINUX=/mnt/c/PX4PSP
)
start cmd.exe /k "echo Python3.8 environment has been set with openCV+pymavlink+numpy+pyulog etc. && echo You can use pip or pip3 command to install other libraries && echo Put Python38Run.bat into your code folder && echo Use the command: 'python XXX.py' to run the script with Python && SET PATH=%PSP_PATH%\Python38;%PSP_PATH%\Python38\Scripts;%CD%;%PATH%"

View File

@@ -0,0 +1,12 @@
@echo off
REM Set the path of the RflySim tools
if not defined PSP_PATH (
SET PSP_PATH=C:\PX4PSP
SET PSP_PATH_LINUX=/mnt/c/PX4PSP
)
cd /d %PSP_PATH%\VcXsrv
tasklist|find /i "vcxsrv.exe" >nul || Xlaunch.exe -run config1.xlaunch
cd /d %~dp0
wsl -d RflySim-20.04

View File

@@ -0,0 +1,21 @@
@echo off
REM Set the path of the RflySim tools
if not defined PSP_PATH (
SET PSP_PATH=C:\PX4PSP
SET PSP_PATH_LINUX=/mnt/c/PX4PSP
)
tasklist|find /i "vcxsrv.exe" >nul && taskkill /f /IM "vcxsrv.exe" >nul
tasklist|find /i "vcxsrv.exe" >nul && taskkill /f /IM "vcxsrv.exe" >nul
cd /d %PSP_PATH%\VcXsrv
Xlaunch.exe -run config.xlaunch
choice /t 1 /d y /n >nul
cd /d %~dp0
wsl -d RflySim-20.04 ~/StartUI.sh
choice /t 1 /d y /n >nul
tasklist|find /i "vcxsrv.exe" && taskkill /f /IM "vcxsrv.exe"
wsl --shutdown

View File

@@ -0,0 +1,162 @@
@ECHO OFF
REM Run script as administrator
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c ""%~s0"" ::","","runas",1)(window.close)&&exit
REM The text start with 'REM' is annotation, the following options are corresponding to Options on CopterSim
REM Start index of vehicle number (should larger than 0)
REM This option is useful for simulation with multi-computers
SET /a START_INDEX=1
REM Set the vehicleType/ClassID of vehicle 3D display in RflySim3D
SET /a CLASS_3D_ID=-1
REM Set use DLL model name or not, use number index or name string
REM This option is useful for simulation with other types of vehicles instead of multicopters
set DLLModel=0
REM Set the simulation mode on CopterSim, use number index or name string
REM e.g., SimMode=2 equals to SimMode=PX4_SITL_RFLY
set SimMode=2
REM Set the vehicle-model (airframe) of PX4 SITL simulation, the default airframe is a quadcopter: iris
REM Check folder Firmware\ROMFS\px4fmu_common\init.d-posix for supported airframes (Note: You can also create your airframe file here)
REM E.g., fixed-wing aircraft: PX4SitlFrame=plane; small cars: PX4SitlFrame=rover
set PX4SitlFrame=iris
REM Set the map, use index or name of the map on CopterSim
REM e.g., UE4_MAP=1 equals to UE4_MAP=Grasslands
SET UE4_MAP=NeighborhoodPark
REM Set the origin x,y position (m) and yaw angle (degree) at the map
SET /a ORIGIN_POS_X=0
SET /a ORIGIN_POS_Y=0
SET /a ORIGIN_YAW=0
REM Set the interval between two vehicle, unit:m
SET /a VEHICLE_INTERVAL=2
REM Set broadcast to other computer; 0: only this computer, 1: broadcast; or use IP address to increase speed
REM e.g., IS_BROADCAST=0 equals to IS_BROADCAST=127.0.0.1, IS_BROADCAST=1 equals to IS_BROADCAST=255.255.255.255
SET IS_BROADCAST=0
REM Set UDP data mode; 0: UDP_FULL, 1:UDP_Simple, 2: Mavlink_Full, 3: Mavlink_simple. input number or string
REM 4:Mavlink_NoSend, 5:Mavlink_NoGPS, 6:Mavlink_Vision (NoGPS and set PX4 EKF)
SET UDPSIMMODE=2
REM Set the path of the RflySim tools
if not defined PSP_PATH (
SET PSP_PATH=C:\PX4PSP
SET PSP_PATH_LINUX=/mnt/c/PX4PSP
)
:Top
ECHO.
ECHO ---------------------------------------
REM Max vehicle number 50
SET /a MAX_VEHICLE=50
REM SET /P VehicleNum=Please input UAV swarm number:
SET /A VehicleNum=1
SET /A Evaluated=VehicleNum
if %Evaluated% EQU %VehicleNum% (
IF %VehicleNum% GTR 0 (
IF %VehicleNum% GTR %MAX_VEHICLE% (
ECHO The vehicle number is too large, which may cause a crash
pause
)
GOTO StartSim
)
ECHO Not a positive integer
GOTO Top
) ELSE (
ECHO Not a integer
GOTO Top
)
:StartSim
SET /A VehicleTotalNum=%VehicleNum% + %START_INDEX% - 1
if not defined TOTOAL_COPTER (
SET /A TOTOAL_COPTER=%VehicleTotalNum%
)
set /a sqrtNum=1
set /a squareNum=1
:loopSqrt
set /a squareNum=%sqrtNum% * %sqrtNum%
if %squareNum% EQU %TOTOAL_COPTER% (
goto loopSqrtEnd
)
if %squareNum% GTR %TOTOAL_COPTER% (
goto loopSqrtEnd
)
set /a sqrtNum=%sqrtNum%+1
goto loopSqrt
:loopSqrtEnd
REM QGCPath
tasklist|find /i "QGroundControl.exe" || start %PSP_PATH%\QGroundControl\QGroundControl.exe -noComPix
ECHO Start QGroundControl
REM UE4Path
cd /d %PSP_PATH%\RflySim3D
tasklist|find /i "RflySim3D.exe" || start %PSP_PATH%\Rflysim3D\RflySim3D.exe
choice /t 5 /d y /n >nul
tasklist|find /i "CopterSim.exe" && taskkill /im "CopterSim.exe"
ECHO Kill all CopterSims
REM CptSmPath
cd /d %PSP_PATH%\CopterSim
set /a cntr=%START_INDEX%
set /a endNum=%VehicleTotalNum%+1
:loopBegin
set /a PosXX=((%cntr%-1) / %sqrtNum%)*%VEHICLE_INTERVAL% + %ORIGIN_POS_X%
set /a PosYY=((%cntr%-1) %% %sqrtNum%)*%VEHICLE_INTERVAL% + %ORIGIN_POS_Y%
start /realtime CopterSim.exe 1 %cntr% %CLASS_3D_ID% %DLLModel% %SimMode% %UE4_MAP% %IS_BROADCAST% %PosXX% %PosYY% %ORIGIN_YAW% 1 %UDPSIMMODE%
choice /t 1 /d y /n >nul
set /a cntr=%cntr%+1
if %cntr% EQU %endNum% goto loopEnd
goto loopBegin
:loopEnd
REM Set ToolChainType 1:Win10WSL 3:Cygwin
SET /a ToolChainType=1
if "%IS_BROADCAST%" == "0" (
SET IS_BROADCAST=0
) else (
SET IS_BROADCAST=1
)
SET WINDOWSPATH=%PATH%
if %ToolChainType% EQU 1 (
wsl -d RflySim-20.04 echo Starting PX4 Build; cd %PSP_PATH_LINUX%/Firmware; ./BkFile/EnvOri.sh; export PATH=$HOME/ninja:$HOME/gcc-arm-none-eabi-7-2017-q4-major/bin:$PATH;make px4_sitl_default; ./Tools/sitl_multiple_run_rfly.sh %VehicleNum% %START_INDEX% %PX4SitlFrame%;echo Press any key to exit; read -n 1
) else (
REM CYGPath
cd /d %PSP_PATH%\CygwinToolchain
CALL setPX4Env.bat
bash -l -i -c 'echo Starting SITL SIMULATION; cd %PSP_PATH_LINUX%/Firmware; ./BkFile/EnvOri.sh; pwd; make px4_sitl_default; ./Tools/sitl_multiple_run_rfly.sh %VehicleNum% %START_INDEX% %PX4SitlFrame%;echo Press any key to exit; read -n 1; pkill -x px4 || true;'
)
SET PATH=%WINDOWSPATH%
REM kill all applications when press a key
tasklist|find /i "CopterSim.exe" && taskkill /im "CopterSim.exe"
tasklist|find /i "QGroundControl.exe" && taskkill /f /im "QGroundControl.exe"
tasklist|find /i "RflySim3D.exe" && taskkill /f /im "RflySim3D.exe"
tasklist|find /i "python.exe" && taskkill /f /im "python.exe"
tasklist|find /i "cmd.exe" && taskkill /f /im "cmd.exe"
ECHO Start End.

View File

@@ -0,0 +1,106 @@
gpg-agent[345]: WARNING: "--write-env-file" is an obsolete option - it has no effect
gpg-agent[346]: gpg-agent (GnuPG) 2.2.19 started
(xfce4-session:296): xfce4-session-WARNING **: 14:45:54.182: gpg-agent returned no PID in the variables
(xfce4-session:296): xfce4-session-WARNING **: 14:45:54.185: xfsm_manager_load_session: Something wrong with /root/.cache/sessions/xfce4-session-localhost:0, Does it exist? Permissions issue?
(xfwm4:347): xfwm4-WARNING **: 14:45:56.494: Unsupported GL renderer (llvmpipe (LLVM 12.0.0, 256 bits)).
(xfsettingsd:385): libupower-glib-WARNING **: 14:45:56.733: Couldn't connect to proxy: Could not connect: No such file or directory
(xfsettingsd:385): libupower-glib-CRITICAL **: 14:45:56.733: up_client_get_lid_is_closed: assertion 'UP_IS_CLIENT (client)' failed
(xfsettingsd:385): GLib-GObject-WARNING **: 14:45:56.733: invalid (NULL) pointer instance
(xfsettingsd:385): GLib-GObject-CRITICAL **: 14:45:56.733: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(wrapper-2.0:406): GLib-GIO-CRITICAL **: 14:45:57.491: g_file_new_for_path: assertion 'path != NULL' failed
(wrapper-2.0:406): GLib-GIO-CRITICAL **: 14:45:57.491: g_file_monitor_file: assertion 'G_IS_FILE (file)' failed
(wrapper-2.0:406): GLib-GObject-WARNING **: 14:45:57.491: invalid (NULL) pointer instance
(wrapper-2.0:406): GLib-GObject-CRITICAL **: 14:45:57.491: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(wrapper-2.0:406): Gtk-WARNING **: 14:45:57.491: Attempting to add a widget with type GtkToggleButton to a container of type XfcePanelPlugin, but the widget is already inside a container of type XfcePanelPlugin, please remove the widget from its existing container first.
(xfce4-session:296): xfce4-session-WARNING **: 14:45:57.506: failed to run script: Failed to execute child process “/usr/bin/pm-is-supported” (No such file or directory)
(xfce4-session:296): xfce4-session-WARNING **: 14:45:57.516: failed to run script: Failed to execute child process “/usr/bin/pm-is-supported” (No such file or directory)
(xfce4-session:296): xfce4-session-WARNING **: 14:45:57.525: failed to run script: Failed to execute child process “/usr/bin/pm-is-supported” (No such file or directory)
(wrapper-2.0:407): Gtk-WARNING **: 14:45:57.577: Negative content width -1 (allocation 1, extents 1x1) while allocating gadget (node button, owner XfceArrowButton)
** (agent:423): CRITICAL **: 14:45:57.584: Failed to get connection to system bus: Could not connect: No such file or directory
(wrapper-2.0:406): Gtk-WARNING **: 14:45:57.611: Negative content width -3 (allocation 1, extents 2x2) while allocating gadget (node button, owner GtkToggleButton)
** (wrapper-2.0:405): WARNING **: 14:45:57.637: Binding 'XF86AudioMicMute' failed!
(wrapper-2.0:405): pulseaudio-plugin-WARNING **: 14:45:57.638: Could not have grabbed volume control keys. Is another volume control application (xfce4-volumed) running?
shared memfd open() failed: Function not implemented
(wrapper-2.0:405): Gtk-WARNING **: 14:45:57.817: Negative content width -3 (allocation 1, extents 2x2) while allocating gadget (node button, owner PulseaudioButton)
(nm-applet:442): nm-applet-WARNING **: 14:45:57.944: Error connecting to system D-Bus: Could not connect: No such file or directory
(nm-applet:442): nm-applet-WARNING **: 14:45:57.945: Could not connect: No such file or directory
(nm-applet:442): libnm-CRITICAL **: 14:45:57.946: ((libnm/nm-client.c:3905)): assertion '<dropped>' failed
(nm-applet:442): libnm-CRITICAL **: 14:45:57.950: ((libnm/nm-client.c:3859)): assertion '<dropped>' failed
(nm-applet:442): libnm-CRITICAL **: 14:45:57.950: ((libnm/nm-client.c:3937)): assertion '<dropped>' failed
(nm-applet:442): libnm-CRITICAL **: 14:45:57.950: ((libnm/nm-client.c:3986)): assertion '<dropped>' failed
(nm-applet:442): libnm-CRITICAL **: 14:45:57.950: ((libnm/nm-client.c:4026)): assertion '<dropped>' failed
(nm-applet:442): libnm-CRITICAL **: 14:45:57.950: ((libnm/nm-client.c:4042)): assertion '<dropped>' failed
(nm-applet:442): libnm-CRITICAL **: 14:45:57.950: ((libnm/nm-client.c:4080)): assertion '<dropped>' failed
(nm-applet:442): libnm-CRITICAL **: 14:45:57.950: ((libnm/nm-client.c:4598)): assertion '<dropped>' failed
(nm-applet:442): libnm-CRITICAL **: 14:45:57.951: ((libnm/nm-client.c:4598)): assertion '<dropped>' failed
shared memfd open() failed: Function not implemented
Connection failure: Connection refused
pa_context_connect() failed: Connection refused
** (xiccd:485): CRITICAL **: 14:45:58.141: Failed to connect to colord: Could not connect: No such file or directory
(xfdesktop:400): GVFS-RemoteVolumeMonitor-WARNING **: 14:45:58.495: remote volume monitor with dbus name org.gtk.vfs.UDisks2VolumeMonitor is not supported
** (xfdesktop:400): WARNING **: 14:45:58.676: Failed to get system bus: Could not connect: No such file or directory
system-config-printer-applet: failed to connect to system D-Bus
(xfce4-panel:386): xfce4-panel-CRITICAL **: 14:46:07.956: panel-window.c:2245 (panel_window_active_window_geometry_changed): expression 'WNCK_IS_WINDOW (active_window)' failed.
(xfce4-panel:386): xfce4-panel-CRITICAL **: 14:46:34.605: panel-window.c:2245 (panel_window_active_window_geometry_changed): expression 'WNCK_IS_WINDOW (active_window)' failed.
Gdk-Message: 14:58:12.289: xfce4-session: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0.
Gdk-Message: 14:58:12.290: xfwm4: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0.
xfsettingsd: Another instance took over. Leaving...
(xfce4-panel:386): xfce4-panel-CRITICAL **: 14:58:12.291: Name org.xfce.Panel lost on the message dbus, exiting.
(Thunar:394): thunar-WARNING **: 14:58:12.291: Name 'org.xfce.FileManager' lost on the message dbus.
(Thunar:394): thunar-WARNING **: 14:58:12.292: Name 'org.freedesktop.FileManager1' lost on the message dbus.
Gdk-Message: 14:58:12.298: xfsettingsd: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0.
Gdk-Message: 14:58:12.300: xfce4-panel: Fatal IO error 25 (Inappropriate ioctl for device) on X server :0.0.
Gdk-Message: 14:58:12.300: xfdesktop: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0.
Gdk-Message: 14:58:12.302: wrapper-2.0: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0.
Gdk-Message: 14:58:12.301: wrapper-2.0: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0.
Gdk-Message: 14:58:12.302: wrapper-2.0: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0.
Gdk-Message: 14:58:12.302: wrapper-2.0: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0.

View File

@@ -0,0 +1,185 @@
Panels:
- Class: rviz/Displays
Help Height: 78
Name: Displays
Property Tree Widget:
Expanded:
- /Global Options1
- /Status1
- /Axes1
- /PointCloud21/Status1
Splitter Ratio: 0.5
Tree Height: 546
- Class: rviz/Selection
Name: Selection
- Class: rviz/Tool Properties
Expanded:
- /2D Pose Estimate1
- /2D Nav Goal1
- /Publish Point1
Name: Tool Properties
Splitter Ratio: 0.5886790156364441
- Class: rviz/Views
Expanded:
- /Current View1
Name: Views
Splitter Ratio: 0.5
- Class: rviz/Time
Experimental: false
Name: Time
SyncMode: 0
SyncSource: PointCloud2
Preferences:
PromptSaveOnExit: true
Toolbars:
toolButtonStyle: 2
Visualization Manager:
Class: ""
Displays:
- Alpha: 0.5
Cell Size: 1
Class: rviz/Grid
Color: 160; 160; 164
Enabled: true
Line Style:
Line Width: 0.029999999329447746
Value: Lines
Name: Grid
Normal Cell Count: 0
Offset:
X: 0
Y: 0
Z: 0
Plane: XY
Plane Cell Count: 10
Reference Frame: <Fixed Frame>
Value: true
- Alpha: 1
Autocompute Intensity Bounds: true
Autocompute Value Bounds:
Max Value: 1.4648884534835815
Min Value: -7.074190616607666
Value: true
Axis: Z
Channel Name: intensity
Class: rviz/PointCloud
Color: 255; 255; 255
Color Transformer: AxisColor
Decay Time: 0
Enabled: false
Invert Rainbow: false
Max Color: 255; 255; 255
Min Color: 0; 0; 0
Name: PointCloud
Position Transformer: XYZ
Queue Size: 10
Selectable: true
Size (Pixels): 3
Size (m): 0.019999999552965164
Style: Flat Squares
Topic: /lidar_points
Unreliable: false
Use Fixed Frame: true
Use rainbow: true
Value: false
- Class: rviz/Axes
Enabled: true
Length: 2
Name: Axes
Radius: 0.20000000298023224
Reference Frame: <Fixed Frame>
Value: true
- Alpha: 1
Autocompute Intensity Bounds: true
Autocompute Value Bounds:
Max Value: 12.140262603759766
Min Value: -14.380321502685547
Value: true
Axis: Z
Channel Name: intensity
Class: rviz/PointCloud2
Color: 255; 255; 255
Color Transformer: AxisColor
Decay Time: 0
Enabled: true
Invert Rainbow: false
Max Color: 255; 255; 255
Min Color: 0; 0; 0
Name: PointCloud2
Position Transformer: XYZ
Queue Size: 10
Selectable: true
Size (Pixels): 3
Size (m): 0.20000000298023224
Style: Flat Squares
Topic: /rflysim/vehicle_0/lidar_0
Unreliable: false
Use Fixed Frame: true
Use rainbow: true
Value: true
Enabled: true
Global Options:
Background Color: 48; 48; 48
Default Light: true
Fixed Frame: rflysim_vehicle0
Frame Rate: 30
Name: root
Tools:
- Class: rviz/Interact
Hide Inactive Objects: true
- Class: rviz/MoveCamera
- Class: rviz/Select
- Class: rviz/FocusCamera
- Class: rviz/Measure
- Class: rviz/SetInitialPose
Theta std deviation: 0.2617993950843811
Topic: /initialpose
X std deviation: 0.5
Y std deviation: 0.5
- Class: rviz/SetGoal
Topic: /move_base_simple/goal
- Class: rviz/PublishPoint
Single click: true
Topic: /clicked_point
Value: true
Views:
Current:
Class: rviz/Orbit
Distance: 111.6949691772461
Enable Stereo Rendering:
Stereo Eye Separation: 0.05999999865889549
Stereo Focal Distance: 1
Swap Stereo Eyes: false
Value: false
Focal Point:
X: 25.732120513916016
Y: 8.539153099060059
Z: 0.2620249390602112
Focal Shape Fixed Size: true
Focal Shape Size: 0.05000000074505806
Invert Z Axis: false
Name: Current View
Near Clip Distance: 0.009999999776482582
Pitch: 0.2752034068107605
Target Frame: <Fixed Frame>
Value: Orbit (rviz)
Yaw: 4.4104323387146
Saved: ~
Window Geometry:
Displays:
collapsed: true
Height: 846
Hide Left Dock: true
Hide Right Dock: true
QMainWindow State: 000000ff00000000fd000000040000000000000156000002aefc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073000000003e000002ae000000ca00fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000002aefc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000003e000002ae000000a600fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004b00000003efc0100000002fb0000000800540069006d00650100000000000004b00000026200fffffffb0000000800540069006d00650100000000000004500000000000000000000004b0000002ae00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
Selection:
collapsed: false
Time:
collapsed: false
Tool Properties:
collapsed: false
Views:
collapsed: true
Width: 1200
X: 1063
Y: 195

View File

@@ -0,0 +1 @@
/usr/bin/startxfce4: X server already running on display :0.0

View File

@@ -0,0 +1,106 @@
# import required libraries
# pip3 install pymavlink pyserial
import cv2
import numpy as np
import time
import VisionCaptureApi
import PX4MavCtrlV4 as PX4MavCtrl
import math
# import matplotlib.pyplot as plt
import ReqCopterSim
import Open3DShow
show3d=Open3DShow.Open3DShow()
vis = VisionCaptureApi.VisionCaptureApi()
# VisionCaptureApi 中的配置函数
vis.jsonLoad()
isSuss = vis.sendReqToUE4()
vis.startImgCap() # 开启取图循环执行本语句之后已经可以通过vis.Img[i]读取到图片了
print('Start Image Reciver')
# vis.sendImuReqCopterSim(1,'127.0.0.1') # 发送请求从目标飞机CopterSim读取IMU数据,回传地址为127.0.0.1默认频率为200Hz
# 执行本语句之后会自动开启数据监听已经可以通过vis.imu读取到IMU数据了。
mav = PX4MavCtrl.PX4MavCtrler(1)
time.sleep(2)
# Start MAV loop with UDP mode: MAVLINK_FULL
mav.InitMavLoop()
mav.InitTrueDataLoop()
# Enter Offboard mode to start vehicle control
time.sleep(2)
mav.initOffboard()
# Get the takeoff position of each vehicle to the UE4 Map
# this can be adopted to obtain the global position of a vehicle in swarm simulation
time.sleep(2)
Error2UE4Map = []
Error2UE4Map = -np.array([mav.uavGlobalPos[0]-mav.uavPosNED[0],
mav.uavGlobalPos[1]-mav.uavPosNED[1], mav.uavGlobalPos[2]-mav.uavPosNED[2]])
# fly to 10m high above its takeoff position
mav.SendPosNED(0, 0, -8, 0)
mav.SendCopterSpeed(3)
#time.sleep(10)
#创建点云显示窗口
show3d.CreatShow(0)
lastTime = time.time()
startTime = time.time()
timeInterval = 1/30.0 # here is 0.0333s (30Hz)
while True:
lastTime = lastTime + timeInterval
sleepTime = lastTime - time.time()
if sleepTime > 0:
time.sleep(sleepTime) # sleep until the desired clock
else:
lastTime = time.time()
# The following code will be executed 30Hz (0.0333s)
t = time.time()-startTime
# target position in UE4 map global frame
if t < 10:
# fly to 15 meters high in 0 to 10s
targetPosE = np.array([-0, 0, -5])
elif t<20: # fly circle after 10s
targetPosE = np.array(
[15,5, -5])
else:
targetPosE = np.array([15,-10, -5])
# target position in vehilce takeoff frame
targetPosE = targetPosE+Error2UE4Map
mav.SendPosNED(targetPosE[0], targetPosE[1], targetPosE[2], 0)
if vis.hasData[0]:
# 更新点云
show3d.UpdateShow(vis.Img[0])
# 标记
vis.hasData[0]=False
#isShowCloud = False
if t > 200: # end simulation when 200s
break
mav.endOffboard()
time.sleep(1)
mav.stopRun()