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

Some problem about the Unitydemo/carDemo #3276

Closed
MiaoMiaoMeng opened this issue Jan 6, 2021 · 12 comments · Fixed by #3343
Closed

Some problem about the Unitydemo/carDemo #3276

MiaoMiaoMeng opened this issue Jan 6, 2021 · 12 comments · Fixed by #3343

Comments

@MiaoMiaoMeng
Copy link

private static bool SetDistortionParam(string cameraName, string paramName, float value, string vehicleName) {

Hi, I have some question about this function, It seem like we didn't use this function.
So I try to annotation this part of code.
But when I try to run the carDemo, the Editor will crash.
From the Log i found

Loaded scene 'Assets/Scenes/CarDemo.unity'
Deserialize: 27.018 ms
Integration: 13.212 ms
Integration of assets: 1.326 ms
Thread Wait Time: 6.267 ms
Total Operation Time: 47.824 ms
NullReferenceException: Object reference not set to an instance of an object
at AirSimUnity.VehicleCompanion.Reset (System.String vehicleName) [0x00025] in C:\AirSim-master\Unity\UnityDemo\Assets\AirSimAssets\Scripts\Vehicles\VehicleCompanion.cs:146

But I didn't found which code use it, except “getfunctionpointerfordelegate”.

Is there anyone else have the same situation like me?

@ahmed-elsaharti
Copy link
Contributor

Hi @MiaoMiaoMeng , it looks like this was added as a placeholder for camera distortion in e5967a0 of #3039

@MiaoMiaoMeng
Copy link
Author

Thx for your help@ahmed-elsaharti,
I read the part of code in e5967a0, but in this part:

    private static bool SetDistortionParam(string cameraName, string paramName, float value, string vehicleName) {
        var vehicle = Vehicles.Find(element => element.vehicleName == vehicleName);
        return vehicle.VehicleInterface.SetDistortionParam(cameraName, fov_degrees);
    }

the value which named as fov_degrees is not found. I think that is the 'value'
So I try to rename float 'value' to fov_degrees, but i didn't found the override function with two param.

BTW,I also didn‘t found any reference about this function.

@MiaoMiaoMeng
Copy link
Author

MiaoMiaoMeng commented Jan 8, 2021

Hi @MiaoMiaoMeng , it looks like this was added as a placeholder for camera distortion in e5967a0 of #3039

I read the src in this morning and set a try catch in Reset() function, from the result I think that Vehicles can't Find the element with 'vehicleName'

    private static bool Reset(string vehicleName)
            {
                try
                {
                    var vehicle = Vehicles.Find(element => element.vehicleName == vehicleName);
                    vehicle.VehicleInterface.ResetVehicle();
                }
                catch (Exception e) {
                    Debug.Log("vehicle is null");
                    throw e;
                }
                return true;
            }

that's make me feel confuse, I think the vehicleName is already pass in InitDelegators() when the StartVehicleServer() been used.
So I can't find the reason why it has a NullReference in Reset() function.

@ahmed-elsaharti
Copy link
Contributor

Thx for your help@ahmed-elsaharti,
I read the part of code in e5967a0, but in this part:

    private static bool SetDistortionParam(string cameraName, string paramName, float value, string vehicleName) {
        var vehicle = Vehicles.Find(element => element.vehicleName == vehicleName);
        return vehicle.VehicleInterface.SetDistortionParam(cameraName, fov_degrees);
    }

the value which named as fov_degrees is not found. I think that is the 'value'
So I try to rename float 'value' to fov_degrees, but i didn't found the override function with two param.

BTW,I also didn‘t found any reference about this function.

My understanding is that camera distortion hasn't been implemented in Unity yet. I could be wrong though since I barely looked into the code within the PR. @saihv would probably be able to answer this better than me.

@jonyMarino
Copy link
Collaborator

Yes, that is correct; the programmable camera distortion was not implemented for Unity.

@JW-Kwon35
Copy link

Hi @MiaoMiaoMeng,
so how did u build the system? I tried to comment out the SetDistortionParam function and the build process seemed quite ok until Unity said "Problem in starting AirSim server".

@kengregson
Copy link

kengregson commented Jan 13, 2021

Encountered same, last working Unity version I found can be checked out via:
'git checkout 7f48ba3'

Unity build is currently broken, @jonyMarino maybe this is more than a feature request?
Attached screen snap of errors in Editor that prevent running either Car or Drone Mode of demo.
UnityErrors

@david9705
Copy link

david9705 commented Jan 14, 2021

Hello, @MiaoMiaoMeng .
I also encounter same problem.
Unity build is currently broken when annotate the SetDistortionParam function, but without annotation Unity report 'IVehicleInterface' does not contain a definition for 'SetDistortionParam' and no accessible extension method 'SetDistortionParam' (same as @kengregson picture)

How do you solve those errors?

@MiaoMiaoMeng
Copy link
Author

Hi @MiaoMiaoMeng,
so how did u build the system? I tried to comment out the SetDistortionParam function and the build process seemed quite ok until Unity said "Problem in starting AirSim server".

Hi @MultiPsy,
I have not successfully built this system, as I said there is a null reference in Reset() function.
And for now, I didn't spend time on it. Because I need to deal with the transplantation of a slam system.
So if I have time after, I will find out how to avoid this problem.

@zimmy87
Copy link
Contributor

zimmy87 commented Jan 25, 2021

Hi @MiaoMiaoMeng and @MultiPsy, thank you for reporting and testing this issue. I just created a PR that should address both issues you are experiencing with the UnityDemo. Please apply this PR and test again and let me know if you are still seeing this issue.

@MiaoMiaoMeng
Copy link
Author

Hi @MiaoMiaoMeng and @MultiPsy, thank you for reporting and testing this issue. I just created a PR that should address both issues you are experiencing with the UnityDemo. Please apply this PR and test again and let me know if you are still seeing this issue.

Thanks @zimmy87 ,

It works well.
I will close the issue.

Thank you again.

@kengregson
Copy link

kengregson commented Jan 26, 2021

@zimmy87, please accept my thanks as well!
Also verified under Ubuntu 20.04/Unity 2019.3.12f1 with PX4-SITL/QGroundControl.

Note: Issue #1617 still seems to prevent proper operation of PX4 SITL unless settings.json and VehicleCompanion.cs are modified as described in the workaround.

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

Successfully merging a pull request may close this issue.

7 participants