Dave Zoltok wrote:
I'm trying to set up my simulator to operate robots using a simple continuous-time recurrent neural network. At the moment I'm just configuring it by setting all of the parameters by hand; the settings below should allow the robot to chase after lights similar to a Braitenburg vehicle. But, behaviour aside, it seems this code is crashing the simulator instead!

The line "self.motors(leftoutput, rightoutput)" seems to be the problem. It is meant to set the motors to the output from two of the nodes in the network. When I include this line, the simulator hangs without printing any of the statements I included below, and I have to abort the Python process. But if I comment this line out and replace it with something like "self.motors(rightinput, leftinput)," so that the light input is used directly to determine the motor output, the simulator works as expected. I can't figure out why one would work but the other wouldn't when both seem to be acceptable parameters to the method. Does anyone have an idea? I'm running version 5.0.0 on OSX 10.5.2.

Dave

Dave,

What are the values you are feeding to the motors? They are expecting values between -1 and 1.

-Doug

--- code below ---

# CTRNNBrain.py
from pyrobot.brain import Brain
from pyrobot.brain.ctrnn import *

class CTRNNBrain(Brain):
    def setup(self):
        self.robot.light[0].units = "scaled"
        self.maxvalue = self.robot.light[0].getMaxvalue()

        self.net = CTRNN(name="brain")
self.net.addNeuron(name="input_left", state=1.0, bias=-1.0, tau=0.5) self.net.addNeuron(name="input_right", state=1.0, bias=-1.0, tau=0.5) self.net.addNeuron(name="hidden", state=6.0, bias=-6.0, tau=0.5) self.net.addNeuron(name="motor_left", state=10.0, bias=-10.0, tau=0.2) self.net.addNeuron(name="motor_right", state=10.0, bias=-10.0, tau=0.2)

        self.net.setConnectionWeight("input_left",  "hidden",      1.5)
        self.net.setConnectionWeight("input_right", "hidden",      1.5)
        self.net.setConnectionWeight("hidden",      "hidden",      12.0)
        self.net.setConnectionWeight("input_right", "motor_left",  4.0)
        self.net.setConnectionWeight("hidden",      "motor_left",  4.0)
        self.net.setConnectionWeight("motor_left",  "motor_left",  7.0)
        self.net.setConnectionWeight("input_left",  "motor_right", 4.0)
        self.net.setConnectionWeight("hidden",      "motor_right", 4.0)
        self.net.setConnectionWeight("motor_right", "motor_right", 7.0)


    def step(self):
        # Get the inputs
        leftinput = max([s.value for s in self.robot.light[0]["left"]])
        rightinput = max([s.value for s in self.robot.light[0]["right"]])
        print "left input = %f, right input = %f" % (leftinput, rightinput)
        self.net.setNeuronOutput("input_left", leftinput)
        self.net.setNeuronOutput("input_right", rightinput)
        self.net.EulerStep(0.01)
        leftoutput = self.net.getNeuronOutput("motor_left")
        rightoutput = self.net.getNeuronOutput("motor_right")
print "left state = %f, right state = %f" % (self.net.getNeuronState("motor_left"),self.net.getNeuronState("motor_right")) print "left output = %f, right output = %f" % (leftoutput, rightoutput)
        #self.motors(rightinput, leftinput)
        self.motors(leftoutput, rightoutput)

def INIT(eng):
    return CTRNNBrain(engine=eng)


------------------------------------------------------------------------

_______________________________________________
Pyro-users mailing list
Pyro-users@pyrorobotics.org
http://emergent.brynmawr.edu/mailman/listinfo/pyro-users

_______________________________________________
Pyro-users mailing list
Pyro-users@pyrorobotics.org
http://emergent.brynmawr.edu/mailman/listinfo/pyro-users

Reply via email to