Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Python API example files #2683

Merged
merged 6 commits into from
Sep 2, 2020
Merged

Conversation

rajat2004
Copy link
Contributor

@rajat2004 rajat2004 commented May 10, 2020

Changes -

  1. Fix hello_car.py print, temp folder for images, cleanup
  2. Delete legacy_hello_car.py
  3. Add utility functions to check for NaN in Pose (simGetObjectPose() sometimes returns NaN #2695)
  4. Fix cv_mode.py
  5. [Unity] Don't send Alpha channel in image
  6. [Utils] Use cv2 to write images (Difference in image when using sim.getImages to retrieve a compressed and uncompressed image. #2892)

Just some things noticed when trying to figure out why Unity Car APIs aren't working which has been reported on multiple issues. I'm not seeing anything wrong or different from the Unreal implementation right now. Ping @madratman @saihv

Unity returns RGBA while Unreal does RGB (Not after this PR)

Comment on lines 60 to 64
# currently reset() doesn't work in CV mode. Below is the workaround
client.simSetPose(airsim.Pose(airsim.Vector3r(0, 0, 0), airsim.to_quaternion(0, 0, 0)), True) No newline at end of file
client.simSetVehiclePose(airsim.Pose(airsim.Vector3r(0, 0, 0), airsim.to_quaternion(0, 0, 0)), True)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually client.reset() does work in CV mode

@madratman
Copy link
Contributor

My guess would be we can change the buffer type of Unity from RGBA to RGB by not copying over the alpha channel?
It would be the equivalent of https://github.com/microsoft/AirSim/pull/1910/files#diff-598dac89bb5af3518db2ff6858f0a389L118. Can you try finding these lines in Unity?

@rajat2004
Copy link
Contributor Author

@madratman I think this is the one we need - https://github.com/microsoft/AirSim/blob/master/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Utilities/DataCaptureScript.cs#L153
I could comment it out, will backwards compatibility be a problem. since no. of channels will change? I'll still test it out and commit the change to this PR

@madratman
Copy link
Contributor

No, I think it would be for the better as it establishes consistency in num of channels in UE and Unity,

@rajat2004
Copy link
Contributor Author

rajat2004 commented Jul 25, 2020

Made the Unity change, and reversed the channel change in the script.
2 other things I noted from testing -

  1. Unity API (atleast Car movement one, need to check others also) is broken, Car doesn't move (Related issues Car in UnityDemo Project does not move using PythonClient scripts #2631, how to use python API to control car in unity? #2636)
  2. Uncompressed images are corrupted I think, they don't get saved, and cv2.imshow shows a blank screen. I got to know about this 1-2 days back when doing some work with Recording where setting Compress to False didn't save the images
    Edit: Nothing, just forgot waitKey while doing imshow

Forgot that I had mentioned the 1st problem in the PR description itself...

@madratman
Copy link
Contributor

Merging this.. let's track the remaining issues in new PRs

@madratman madratman merged commit 045766d into microsoft:master Sep 2, 2020
@rajat2004 rajat2004 deleted the api-examples branch September 3, 2020 03:07
@rajat2004
Copy link
Contributor Author

#2937 fixes the Unity Car API problem, still needs a bit more work though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants