-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Linear Velocity publishing. Added TimeScale configuration.
- Loading branch information
1 parent
551f22c
commit 04320af
Showing
10 changed files
with
109 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using UnityEngine; | ||
|
||
namespace RosSharp.RosBridgeClient.MessageTypes.swc_msgs | ||
{ | ||
[RequireComponent(typeof(AckermannController))] | ||
public class LinearVelocityPublisher : UnityPublisher<Gps> | ||
{ | ||
private Gps message; | ||
|
||
private float previousScanTime = 5; | ||
|
||
private float velocityNoiseStdDev = 0.1f; | ||
|
||
private float updatePeriod = 0.05f; | ||
private AckermannController c; | ||
|
||
public bool noNoiseOverride = false; | ||
|
||
protected override void Start() | ||
{ | ||
base.Start(); | ||
c = GetComponent<AckermannController>(); | ||
message = new Gps(); | ||
|
||
switch (ConfigLoader.competition.NoiseLevel) { | ||
case ConfigLoader.CompetitionConfig.NoiseLevels.none: | ||
velocityNoiseStdDev *= 0; | ||
break; | ||
case ConfigLoader.CompetitionConfig.NoiseLevels.reduced: | ||
velocityNoiseStdDev *= 0.5f; | ||
break; | ||
} | ||
|
||
if (noNoiseOverride) { | ||
velocityNoiseStdDev = 0; | ||
} | ||
} | ||
|
||
private void FixedUpdate() | ||
{ | ||
if (UnityEngine.Time.time >= previousScanTime + updatePeriod) | ||
{ | ||
WriteMessage(); | ||
previousScanTime = UnityEngine.Time.time; | ||
} | ||
} | ||
|
||
private void WriteMessage() { | ||
message.latitude = Mathf.Round((c.linear_vel.x + SimUtils.getRandNormal(0, velocityNoiseStdDev) * c.Power / 4.0f) * 1000f) / 1000f; | ||
message.longitude = Mathf.Round((c.linear_vel.z + SimUtils.getRandNormal(0, velocityNoiseStdDev) * c.Power / 4.0f) * 1000f) / 1000f; | ||
Publish(message); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Unity/Assets/RosSharpModules/LinearVelocityPublisher.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters