Skip to content

Commit

Permalink
chore: change to ObjectClassification Class
Browse files Browse the repository at this point in the history
  • Loading branch information
taikitanaka3 committed Oct 10, 2023
1 parent 1069cc3 commit 7c16cb0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace AWSIM
{
public class Classification : MonoBehaviour
public class ObjectClassification : MonoBehaviour
{
// Attach this script to target object to enable perception result sensor
public enum ObjectType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,28 +79,28 @@ void Publish(PerceptionResultSensor.OutputData outputData)
{
switch (detectedObject.classification)
{
case Classification.ObjectType.UNKNOWN:
case ObjectClassification.ObjectType.UNKNOWN:
classification.Label = autoware_auto_perception_msgs.msg.ObjectClassification.UNKNOWN;
break;
case Classification.ObjectType.CAR:
case ObjectClassification.ObjectType.CAR:
classification.Label = autoware_auto_perception_msgs.msg.ObjectClassification.CAR;
break;
case Classification.ObjectType.TRUCK:
case ObjectClassification.ObjectType.TRUCK:
classification.Label = autoware_auto_perception_msgs.msg.ObjectClassification.TRUCK;
break;
case Classification.ObjectType.BUS:
case ObjectClassification.ObjectType.BUS:
classification.Label = autoware_auto_perception_msgs.msg.ObjectClassification.BUS;
break;
case Classification.ObjectType.TRAILER:
case ObjectClassification.ObjectType.TRAILER:
classification.Label = autoware_auto_perception_msgs.msg.ObjectClassification.TRAILER;
break;
case Classification.ObjectType.MOTORCYCLE:
case ObjectClassification.ObjectType.MOTORCYCLE:
classification.Label = autoware_auto_perception_msgs.msg.ObjectClassification.MOTORCYCLE;
break;
case Classification.ObjectType.BICYCLE:
case ObjectClassification.ObjectType.BICYCLE:
classification.Label = autoware_auto_perception_msgs.msg.ObjectClassification.BICYCLE;
break;
case Classification.ObjectType.PEDESTRIAN:
case ObjectClassification.ObjectType.PEDESTRIAN:
classification.Label = autoware_auto_perception_msgs.msg.ObjectClassification.PEDESTRIAN;
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class DetectedObject
public Rigidbody rigidBody;
public Vector3 dimension;
public Vector2[] bounds;
public Classification.ObjectType classification;
public ObjectClassification.ObjectType classification;
}

public class OutputData
Expand Down Expand Up @@ -52,11 +52,11 @@ public class OutputData
public OnOutputDataDelegate OnOutputData;
float timer = 0;
public OutputData outputData = new OutputData();
private List<Classification> filteredObjects = new List<Classification>();
private List<ObjectClassification> filteredObjects = new List<ObjectClassification>();
[Header("Hint: Manually attaching classification objects is quicker.")]
[Header("Warning: Objects without a rigidbody are not supported for classification.")]

public Classification[] cachedObjectsWithClassification;
public ObjectClassification[] cachedObjectsWithClassification;
private bool manuallyCached = true;

// This method generates a footprint for the vehicle based on its dimensions, position, and rotation.
Expand Down Expand Up @@ -92,7 +92,7 @@ Vector2[] GenerateFootprint(Vector3 dimensions, Rigidbody vehicleRb)
void CreateDetectedObjectData(){
outputData.objects = new DetectedObject[cachedObjectsWithClassification.Length];
for (int i = 0; i < cachedObjectsWithClassification.Length; i++) {
Classification obj = cachedObjectsWithClassification[i];
ObjectClassification obj = cachedObjectsWithClassification[i];
outputData.objects[i] = new DetectedObject();
// add classification
outputData.objects[i].classification = obj.objectType;
Expand Down Expand Up @@ -129,7 +129,7 @@ void Start()
// Check if cachedObjectsWithClassification is empty
if(cachedObjectsWithClassification == null || cachedObjectsWithClassification.Length == 0)
{
cachedObjectsWithClassification = FindObjectsOfType<Classification>();
cachedObjectsWithClassification = FindObjectsOfType<ObjectClassification>();
manuallyCached = false;
}
CreateDetectedObjectData();
Expand All @@ -146,7 +146,7 @@ void FixedUpdate()
timer = 0;
outputData.origin = this.transform;
if(!manuallyCached){
var currentObjectsWithClassification = FindObjectsOfType<Classification>();
var currentObjectsWithClassification = FindObjectsOfType<ObjectClassification>();
if (!Enumerable.SequenceEqual(cachedObjectsWithClassification, currentObjectsWithClassification)) {
cachedObjectsWithClassification = currentObjectsWithClassification;
CreateDetectedObjectData();
Expand Down

0 comments on commit 7c16cb0

Please sign in to comment.