I am new to Python. Can someone explain where the functor value is coming from. Functor = msg.functor, but there is no explanation for the word functor, I've tried googling it and came up with nothing. Also the .val keyword isn't explained anywhere, I'm probably being dim but i cannot find any examples.
def process_action(self, msg, sender):
assert msg.get_type() == pedroclient.PObject.structtype
functor = msg.functor
assert functor.get_type() == pedroclient.PObject.atomtype
cmd_type = functor.val
cmd = msg.args[0]
if cmd_type == 'stop_':
assert cmd.get_type() == pedroclient.PObject.structtype
cmd_functor = cmd.functor.val
#if cmd_functor in ['pickup', 'putdown']:
self.stop_arm(cmd.args[0].val)
#else:
# self.stop_arm(cmd.args[0].val)
elif cmd_type in ['start_', 'mod_']:
self.start_animate()
assert cmd.get_type() == pedroclient.PObject.structtype
cmd_functor = cmd.functor.val
if cmd_functor == 'pickup':
self.pickup(cmd.args[0].val, cmd.args[1].val, sender)
elif cmd_functor == 'putdown':
if cmd.args[1].get_type() == pedroclient.PObject.inttype:
self.putdown_on_block(cmd.args[0].val, cmd.args[1].val,
sender)
else:
self.putdown_on_table(cmd.args[0].val, cmd.args[1].val,
sender)
elif cmd_functor == 'go_home':
self.go_home(cmd.args[0].val)
Edit: Sorry there is a lot more code, I have skimmed it as much as i could.
def process_msg(self, term):
msg = term.args[2]
sender_process = term.args[1].args[0].args[1].val
robotID = int(sender_process[-1])-1
#print msg
if str(msg) == "initialise_":
robotID = int(sender_process[-1])-1
def data_cb(self, event):
self.env.process_msg(event.notification)
The best I can understand it is that the functor is an attribute of msg, which in turn is the argument of system input, where system input is a event notification. Am i correct or completely going of in the wrong direction.
Basic stuff - msg & functor might be in these places:
.val - this is most likely an attribute containing data. It is not a Python keyword of any kind that I can find. I'm sure you thought that it is probably short for "value". It is either defined in the objects it is a part of (functor, cmd.args[]) or in some superior object that they import and thus inherit val from.