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

SteerAngle conversion fix in ROS2 bridge #1372

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions Assets/Scripts/Bridge/Ros2/Ros2Conversions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,34 +368,14 @@ public static Detected3DObjectArray ConvertTo(Lgsvl.Detection3DArray data)

public static VehicleControlData ConvertTo(Lgsvl.VehicleControlData data)
{
float Deg2Rad = UnityEngine.Mathf.Deg2Rad;
float MaxSteeringAngle = 39.4f * Deg2Rad;
float wheelAngle = 0f;

if (data.target_wheel_angle > MaxSteeringAngle)
{
wheelAngle = MaxSteeringAngle;
}
else if (data.target_wheel_angle < -MaxSteeringAngle)
{
wheelAngle = -MaxSteeringAngle;
}
else
{
wheelAngle = data.target_wheel_angle;
}

// ratio between -MaxSteeringAngle and MaxSteeringAngle
var k = (float)(wheelAngle + MaxSteeringAngle) / (MaxSteeringAngle*2);

// target_gear are not supported on simulator side

return new VehicleControlData()
{
TimeStampSec = Convert(data.header.stamp),
Acceleration = data.acceleration_pct,
Braking = data.braking_pct,
SteerAngle = UnityEngine.Mathf.Lerp(-1f, 1f, k),
SteerAngle = data.target_wheel_angle * UnityEngine.Mathf.Rad2Deg,
SteerInput = data.target_wheel_angular_rate,
};
}
Expand Down