Reputation: 19
I am using unity and ml-agents, and have started modifying this project: https://github.com/CoderOneHQ/ultimate-volleyball
I have a added more observations to my agents, where it used to have 11 observations and now i added 7 more. The observations i tried adding was positioning of a second player (teammate). here are my the observations section of my code:
public override void CollectObservations(VectorSensor sensor)
{
// Agent rotation (1 float)
sensor.AddObservation(this.transform.rotation.y);
// Vector from agent to ball (direction to ball) (3 floats)
Vector3 toBall = new Vector3((ballRb.transform.position.x - this.transform.position.x)*agentRot,
(ballRb.transform.position.y - this.transform.position.y),
(ballRb.transform.position.z - this.transform.position.z)*agentRot);
sensor.AddObservation(toBall.normalized);
// Distance from the ball (1 float)
sensor.AddObservation(toBall.magnitude);
// Agent velocity (3 floats)
sensor.AddObservation(agentRb.velocity);
// Ball velocity (3 floats)
sensor.AddObservation(ballRb.velocity.y);
sensor.AddObservation(ballRb.velocity.z*agentRot);
sensor.AddObservation(ballRb.velocity.x*agentRot);
// Vector from agent to teammate (direction to teammate) (3 floats)
Vector3 toMate = new Vector3((mateRb.transform.position.x - this.transform.position.x)*agentRot,
(mateRb.transform.position.y - this.transform.position.y),
(mateRb.transform.position.z - this.transform.position.z)*agentRot);
sensor.AddObservation(toMate.normalized);
// Distance from the mate (1 float)
sensor.AddObservation(toMate.magnitude);
// Mate velocity (3 floats)
sensor.AddObservation(mateRb.velocity.y);
sensor.AddObservation(mateRb.velocity.z*agentRot);
sensor.AddObservation(mateRb.velocity.x*agentRot);
}
When i run unity i now get one error and one warning at the same time, the error and warning are given in the following line respectivly:
Sensor shapes must match. [18] != [11]
UnityEngine.Debug:AssertFormat (bool,string,object[])
Unity.MLAgents.Sensors.SensorShapeValidator:ValidateSensors (System.Collections.Generic.List`1<Unity.MLAgents.Sensors.ISensor>) (at Library/PackageCache/[email protected]/Runtime/Sensors/SensorShapeValidator.cs:43)
Unity.MLAgents.RpcCommunicator:PutObservations (string,Unity.MLAgents.AgentInfo,System.Collections.Generic.List`1<Unity.MLAgents.Sensors.ISensor>) (at Library/PackageCache/[email protected]/Runtime/Communicator/RpcCommunicator.cs:319)
Unity.MLAgents.Policies.RemotePolicy:RequestDecision (Unity.MLAgents.AgentInfo,System.Collections.Generic.List`1<Unity.MLAgents.Sensors.ISensor>) (at Library/PackageCache/[email protected]/Runtime/Policies/RemotePolicy.cs:46)
Unity.MLAgents.Agent:SendInfoToBrain () (at Library/PackageCache/[email protected]/Runtime/Agent.cs:1096)
Unity.MLAgents.Agent:SendInfo () (at Library/PackageCache/[email protected]/Runtime/Agent.cs:1323)
Unity.MLAgents.Academy:EnvironmentStep () (at Library/PackageCache/[email protected]/Runtime/Academy.cs:573)
Unity.MLAgents.AcademyFixedUpdateStepper:FixedUpdate () (at Library/PackageCache/[email protected]/Runtime/Academy.cs:43)
More observations (18) made than vector observation size (11). The observations will be truncated.
UnityEngine.Debug:LogWarningFormat (string,object[])
Unity.MLAgents.Sensors.VectorSensor:Write (Unity.MLAgents.Sensors.ObservationWriter) (at Library/PackageCache/[email protected]/Runtime/Sensors/VectorSensor.cs:47)
Unity.MLAgents.GrpcExtensions:GetObservationProto (Unity.MLAgents.Sensors.ISensor,Unity.MLAgents.Sensors.ObservationWriter) (at Library/PackageCache/[email protected]/Runtime/Communicator/GrpcExtensions.cs:399)
Unity.MLAgents.RpcCommunicator:PutObservations (string,Unity.MLAgents.AgentInfo,System.Collections.Generic.List`1<Unity.MLAgents.Sensors.ISensor>) (at Library/PackageCache/[email protected]/Runtime/Communicator/RpcCommunicator.cs:330)
Unity.MLAgents.Policies.RemotePolicy:RequestDecision (Unity.MLAgents.AgentInfo,System.Collections.Generic.List`1<Unity.MLAgents.Sensors.ISensor>) (at Library/PackageCache/[email protected]/Runtime/Policies/RemotePolicy.cs:46)
Unity.MLAgents.Agent:SendInfoToBrain () (at Library/PackageCache/[email protected]/Runtime/Agent.cs:1096)
Unity.MLAgents.Agent:SendInfo () (at Library/PackageCache/[email protected]/Runtime/Agent.cs:1323)
Unity.MLAgents.Academy:EnvironmentStep () (at Library/PackageCache/[email protected]/Runtime/Academy.cs:573)
Unity.MLAgents.AcademyFixedUpdateStepper:FixedUpdate () (at Library/PackageCache/[email protected]/Runtime/Academy.cs:43)
How can i fix this?
Upvotes: 0
Views: 270
Reputation: 1
Hey man just came across similar error.The error is that the changes that you have made for example the distinguishable tags for ray perceptor cud have been applied only for a single agent or environment ..do double check once and change the prefab tooo. GUD LUCK
Upvotes: 0