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 questions about VehicleControlSensor #389

Closed
OutOfCage opened this issue Sep 24, 2019 · 5 comments
Closed

Some questions about VehicleControlSensor #389

OutOfCage opened this issue Sep 24, 2019 · 5 comments

Comments

@OutOfCage
Copy link

Hi, LG Team.
I have some questions about Assets/Scripts/Sensors/VehicleControlSensor.cs.

  • From Line 122 to 129. We send control command in 100HZ. If the values of GearPosition are all Drive, the gear of VehicleDynamics is always on the first gear.
                    if (data.CurrentGear == GearPosition.Reverse)
                    {
                        Dynamics.ShiftReverseAutoGearBox();
                    }
                    else if (data.CurrentGear == GearPosition.Drive)
                    {
                        Dynamics.ShiftFirstGear();
                    }
  • Line 116. Is it if (sgn != Mathf.Sign(steeringTarget - steeringAngle)) ?
                    if (sgn != steeringTarget - steeringAngle) // to prevent oversteering
                        steeringAngle = steeringTarget;

Thank you.

@EricBoiseLGSVL
Copy link
Contributor

EricBoiseLGSVL commented Sep 24, 2019

@OutOfCage

Let's see if I can help. I'm not exactly sure what your questions are though but I'll try and you can clarify.

  1. Are you setting all wheel drive? Are you trying to drive in reverse? The dynamics code has an array for the gear ratios. If you look at the example vehicles in the Unity editor you can see what the index values are. This dynamics model uses index 1- 7 for CurrentGear. If the car is set in Reverse then CurrentGear is still 1 but the bool Reverse is true. If it is Reverse then gearRatio is assigned -1 * gearRatio[0]. (VehicleDynamics.cs line 213). These gear changes happen over a timed interval.
    This dynamics model is older and we plan to refactor.

  2. This is checking that the current steering angle (after applying rate and time) isn't greater the steering target. It is limiting the steering command to -1..1 to apply gradual change to the wheel.

Hope this helps and if not, please clarify what is causing you issues or needs more explanation.

@OutOfCage
Copy link
Author

@EricBoiseLGSVL
Thank you for reply.

  1. For the first issue, it is caused by continuously sending control commands. When I use apollo to send control message (100 HZ), the function ShiftFirstGear of dynamics model is also repeated call during this time. Because lastShift is updated continuously, the dynamics can not achieve the condition of shifting (Time.time - lastShift > shiftDelay) and CurrentGear is always 1.
    public void ShiftFirstGear()
    {
        lastGear = 1;
        targetGear = 1;
        lastShift = Time.time;
        Reverse = false;
    }

If the goal of ShiftFirstGear() is only shifting from Reverse to First Gear, I think maybe add a judgment condition whether Reverse is true.

  1. For the second issue, I just feel strange of the condition. Var sgn is the sign of steeringTarget - steeringAngle(before applying rate and time) and its value should be one of -1(<0) and 1(>=0). But steeringTarget - steeringAngle(after applying rate and time) is real difference between them. In most cases, I think the result of this condition is true.

@EricBoiseLGSVL
Copy link
Contributor

We will look into both of these issues, thanks for the info

@EricBoiseLGSVL
Copy link
Contributor

@OutOfCage

We have fixed the issue that Apollo control shifts to first, thanks for the find. This fix will be in our next release.

We are looking into the sgn condition check. It was in out old simulator and maybe a hold over from older versions of Apollo or some edge case. We will let you know when we test more.

@OutOfCage
Copy link
Author

@EricBoiseLGSVL
Thanks for your work.

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

No branches or pull requests

2 participants