
# Invivo AI challenge simulation environment
# Copyright 2009 Simon Funk
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import math

class Controller(object):

	"""Test controller for Interface01.
	"""
	def __init__(self, interfaces):
		"""Interfaces is a pair of Interface01 objects."""

		self.bots = interfaces

	def update(self, time):

		self.foo(self.bots[0], time)
		self.foo(self.bots[1], time*1.234 + 10.)
		#self.bar(self.bots[1])

	def bar(self, bot):
		for i in range(3):
			bot.torques[i] = -bot.angles[i] * 3. - bot.angvel[i] * .01

	def foo(self, bot, time):

		bot.torques[0] = math.sin(time    ) * bot.torquesmax[0]
		bot.torques[1] = math.sin(time*1.7) * bot.torquesmax[1]
		bot.torques[2] = math.sin(time*2.3) * bot.torquesmax[2]

