Learning Agents exception when adding a Direction observation.

Hello, been experimenting with the Learning Agents plugin and it’s been a smooth experience so far, nice work!

However, when adding a Direction observation I get a number of exceptions. This seems to only concern the normal 3D direction observations, not the planar variant.

In the FDirectionFeature constructor I get following exception:

This exception is ‘continuable’ in the debugger and resuming leads to the following exception during training

The setup which causes this behavior is simple: in SetupObservations I AddDirectionObservation, then during SetObservations I SetDirectionObservation.

Lastly, I’ve been wondering if there is a meaningful difference between position observations and direction observations? I imagine since both are 3D vectors they would both be just represented as 3 float input features to the RNN?

1 Like

Thanks for reporting. We will work on testing on our end and make the necessary changes on ue5-main.

Thanks for looking into it, I’ll keep an eye on ue5-main

Lastly, I’ve been wondering if there is a meaningful difference between position observations and direction observations? I imagine since both are 3D vectors they would both be just represented as 3 float input features to the NN?

Could you share your thoughts on this? I’m trying to get a better understanding of how Learning Agents works, and if both types are just syntactic sugar for an array of float input features, then I could use the position observation for now until it’s fixed.

Yes, it’s basically just syntactic sugar. It’s fully possible to implement everything using AddFloatObservation if you do any transformations yourself. One thing that’s nice is these observations will do more of the math in C++ vs in blueprints (which evaluate quite slowly).

The difference between the two is that PositionObservation can take a relative position and rotation, vs DirectionObservation only takes a relative rotation.

You can do the same thing with PositionObservation by passing in the relative rotation but omitting the relative position.

Brendan

P.S. Underlying code for each:

			const FVector LocalDirection = RelativeRotation.UnrotateVector(Direction);
			Output[0] = LocalDirection.X / FMath::Max(Scale, Epsilon);
			Output[1] = LocalDirection.Y / FMath::Max(Scale, Epsilon);
			Output[2] = LocalDirection.Z / FMath::Max(Scale, Epsilon);

			const FVector LocalPosition = RelativeRotation.UnrotateVector(Position - RelativePosition);
			Output[0] = LocalPosition.X / FMath::Max(Scale, Epsilon);
			Output[1] = LocalPosition.Y / FMath::Max(Scale, Epsilon);
			Output[2] = LocalPosition.Z / FMath::Max(Scale, Epsilon);
1 Like