Getting lidar data from a QGC mission #3410
-
Hi everyone! I'm fairly new when it comes to Airsim and I'm currently working on a project where I'm supposed to get the lidar data from a flying multirotor. I'm toying with the idea of launching missions with QGC and then use python and getLidarData() in parallel to retrieve the data along the path. My question is, would this be feasible or would QGC shut any command coming from python? Currently I'm using: Thank you very much beforehand. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi @Agm2104 , AFAIK QGC commands should not interfere with Here are the settings I used: {
"SettingsVersion": 1.2,
"SimMode": "Multirotor",
"ClockSpeed": 1,
"DefaultSensors": {
"Barometer": {
"SensorType": 1,
"Enabled" : true
},
"Imu": {
"SensorType": 2,
"Enabled" : true
},
"Gps": {
"SensorType": 3,
"Enabled" : true
},
"Magnetometer": {
"SensorType": 4,
"Enabled" : true
},
"Distance": {
"SensorType": 5,
"Enabled" : true
},
"Lidar": {
"SensorType": 6,
"Enabled" : true,
"NumberOfChannels": 1,
"RotationsPerSecond": 10,
"PointsPerSecond": 10000,
"X": 0, "Y": 0, "Z": -1,
"Roll": 0, "Pitch": 0, "Yaw" : 0,
"VerticalFOVUpper": 0,
"VerticalFOVLower": 0,
"DrawDebugPoints": true,
"DataFrame": "VehicleInertialFrame"
}
},
"Vehicles": {
"PX4": {
"VehicleType": "PX4Multirotor",
"UseSerial": false,
"UseTcp": true,
"UdpIp": "127.0.0.1",
"TcpPort": 4560,
"ControlIp": "127.0.0.1",
"ControlPort": 14580
}
}
} and here's the crude python script I wrote for plotting: from mpl_toolkits import mplot3d import airsim
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
client = airsim.MultirotorClient()
fig = plt.figure()
ax = plt.axes(projection='3d')
def animate(i):
ptc = client.getLidarData().point_cloud
xs = np.empty(shape=[int(len(ptc)/3),])
ys = np.empty(shape=[int(len(ptc)/3),])
zs = np.empty(shape=[int(len(ptc)/3),])
for i in range(0,len(ptc)-1,3):
xs[int(i/3)]=ptc[i]
ys[int(i/3)]=ptc[i+1]
zs[int(i/3)]=-ptc[i+2]
#plt.cla()
ax.set_zlim([0, 20])
ax.scatter(xs,ys,zs,zdir='z',s=10,c='b')
ani = FuncAnimation(plt.gcf(),animate,interval=10)
plt.show() Hope this helps ^_^ |
Beta Was this translation helpful? Give feedback.
Hi @Agm2104 , AFAIK QGC commands should not interfere with
gitLidarData()
so your plan sounds doable.I did a quick test with PX4 SITL and the
getLidarData
API and I didn't face any issues retrieving the points and plotting them (using matplotlib) as the drone took off and landed:Here are the settings I used: