Repository URL to install this package:
|
Version:
1.3.2 ▾
|
using Fluctio.FluctioSim.Common.Configuration;
using Unity.MLAgents.Actuators;
using UnityEngine;
namespace Fluctio.FluctioSim.Core.Components.MachineLearning.Actuating
{
[AddComponentMenu(Config.PrefixedName+"/Machine Learning/Actuating/Servo Position Control", Config.ComponentMenuOrder + 530)]
public class ServoPositionControl : DirectControl
{
[SerializeField] private float minAngle = -Mathf.PI;
[SerializeField] private float maxAngle = Mathf.PI;
public override ActionBuffers GetActions()
{
var modelActionValue = base.GetActions().GetOneContinuous(); // [-1; 1]
var normalizedValue = (modelActionValue + 1) / 2; // [0; 1]
var remappedValue = normalizedValue * (maxAngle - minAngle) + minAngle; // [minAngle; maxAngle]
return ActionBuffersExtensions.FromOneContinuous(remappedValue);
}
}
}