Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
using Fluctio.FluctioSim.Common.Configuration;
using Unity.MLAgents.Actuators;
using UnityEngine;

namespace Fluctio.FluctioSim.Core.Components.MachineLearning.Actuating
{
	[AddComponentMenu(Config.PrefixedName+"/Machine Learning/Actuating/Differential Drive", Config.ComponentMenuOrder + 510)]
	public class DifferentialDrive : Control
	{
		[SerializeField] public Control forward;
		[SerializeField] public Control turn;
		[SerializeField] public WheelSide wheelSide = WheelSide.Left;

		public override ActionBuffers GetActions()
		{
			var invertedFactor = wheelSide == WheelSide.Left ? -1 : 1;
			var turnFactor = wheelSide == WheelSide.Left ? 1 : -1;
			var forwardAction = forward.GetActions().GetOneContinuous();
			var turnAction = turn.GetActions().GetOneContinuous();
			var resultAction = invertedFactor * (forwardAction + turnFactor * turnAction) / 2;
			return ActionBuffersExtensions.FromOneContinuous(resultAction);
		}
	}
	
	public enum WheelSide { Left, Right }
}