Skip to content

Commit

Permalink
update point_cloud.py to latest API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sytelus committed Jan 20, 2018
1 parent 282b34c commit 963e30e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions PythonClient/point_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import math
import numpy as np

outputFile = "cloud.asc"
# file will be saved in PythonClient folder (i.e. same folder as script)
# point cloud ASCII format, use viewers like CloudCompare http://www.danielgm.net/cc/ or see http://www.geonext.nl/wp-content/uploads/2014/05/Point-Cloud-Viewers.pdf
outputFile = "cloud.asc"
color = (0,255,0)
rgb = "%d %d %d" % color
projectionMatrix = np.array([[-0.501202762, 0.000000000, 0.000000000, 0.000000000],
Expand All @@ -20,8 +22,8 @@ def printUsage():

def savePointCloud(image, fileName):
f = open(fileName, "w")
for x in xrange(image.shape[0]):
for y in xrange(image.shape[1]):
for x in range(image.shape[0]):
for y in range(image.shape[1]):
pt = image[x,y]
if (math.isinf(pt[0]) or math.isnan(pt[0])):
# skip it
Expand All @@ -33,15 +35,15 @@ def savePointCloud(image, fileName):
for arg in sys.argv[1:]:
cloud.txt = arg

client = AirSimClient('127.0.0.1')
client = MultirotorClient()

while True:
rawImage = client.getImageForCamera(0, AirSimImageType.Depth)
rawImage = client.simGetImage(0, AirSimImageType.DepthPerspective)
if (rawImage is None):
print("Camera is not returning image, please check airsim for error messages")
sys.exit(0)
else:
png = cv2.imdecode(rawImage, cv2.IMREAD_UNCHANGED)
png = cv2.imdecode(np.frombuffer(rawImage, np.uint8) , cv2.IMREAD_UNCHANGED)
gray = cv2.cvtColor(png, cv2.COLOR_BGR2GRAY)
Image3D = cv2.reprojectImageTo3D(gray, projectionMatrix)
savePointCloud(Image3D, outputFile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ ASimModeWorldBase::VehiclePtr ASimModeWorldMultiRotor::createVehicle(VehiclePawn

std::shared_ptr<MultiRotorConnector> vehicle = std::make_shared<MultiRotorConnector>(

wrapper, vehicle_params_.back().get(), getSettings().enable_rpc, getSettings().api_server_address,
vehicle_params_.back()->getParams().api_server_port + vehicle_params_.size() - 1, manual_pose_controller);
wrapper, vehicle_params_.back().get(), getSettings().enable_rpc, getSettings().api_server_address,
vehicle_params_.back()->getParams().api_server_port + vehicle_params_.size() - 1, manual_pose_controller);

if (vehicle->getPhysicsBody() != nullptr)
wrapper->setKinematics(&(static_cast<PhysicsBody*>(vehicle->getPhysicsBody())->getKinematics()));
Expand Down

0 comments on commit 963e30e

Please sign in to comment.