Error 'Can only map parameters for transfer functions' (TF Loading Exception)


#1

Hi all,

What does the following mean?

service [/ros_cle_simulation/create_new_simulation] responded with an error: error processing request: keras_rl_husky_linear_twist_forward: 'Can only map parameters for transfer functions' (TF Loading Exception)

I’ve made sure that all the variables I declare above the corresponding TF are passed in as parameters. And I have t as well.

Any insights?

Thanks

P.S. I can post the TF code if need be - it’s not that long.


#2

Hi,

Please post the code, it would greatly help the debugging.


#3
"""
This module contains the transfer function which is responsible for determining the linear twist
component of the husky's movement based on the left and right wheel neuron
"""
import hbp_nrp_cle.tf_framework as nrp
from hbp_nrp_cle.robotsim.RobotInterface import Topic
import geometry_msgs.msg

@nrp.MapVariable("agent", initial_value=None, scope=nrp.GLOBAL)
@nrp.MapVariable("step", initial_value=False, scope=nrp.GLOBAL)
@nrp.MapVariable("bridge", initial_value=None, scope=nrp.GLOBAL)

#@nrp.MapSpikeSink("left_wheel_neuron", nrp.brain.actors[1], nrp.leaky_integrator_alpha)
#@nrp.MapSpikeSink("right_wheel_neuron", nrp.brain.actors[2], nrp.leaky_integrator_alpha)
#@nrp.Neuron2Robot(Topic('/husky/cmd_vel', geometry_msgs.msg.Twist))
@nrp.MapRobotPublisher("vel", Topic('/husky/cmd_vel', geometry_msgs.msg.Twist))
@nrp.MapRobotSubscriber("camera", Topic('/husky/camera', sensor_msgs.msg.Image))
def keras_rl_husky_linear_twist_forward(t, agent, step, bridge, vel, camera):
    
    if step.value is False and bridge.value is not None and agent.value is not None:
    	# convert the ROS image to an OpenCV image and Numpy array for observation
    	cv_image = bridge.value.imgmsg_to_cv2(camera.value, "rgb8")
    	observation = np.expand_dims(cv_image, axis=0)
    	
    	# get movement action from agent and publish to robot
    	action = agent.value.forward(observation)
    	vel.value.linear = geometry_msgs.msg.Vector3(x=action[0], y=0.0, z=0.0)
    	vel.value.angular = geometry_msgs.msg.Vector3(x=0.0, y=0.0, z=action[1])
    	step.value = True

The agent is a keras-rl agent, which I create in another TF.
The bridge is a CvBridge, that I also initialize in the same TF as the agent.


#4

The last decorator (i.e the one on the line just before the function definition) to be applied to a TF has to be either Neuron2Robot or Robot2Neuron.

Yours is a MapRobotSubscriber, please try something like this:

@nrp.MapRobotPublisher(“vel”, Topic(’/husky/cmd_vel’, geometry_msgs.msg.Twist))
@nrp.MapRobotSubscriber(“camera”, Topic(’/husky/camera’, sensor_msgs.msg.Image))
@nrp.Neuron2Robot()
def keras_rl_husky_linear_twist_forward(t, agent, step, bridge, vel, camera):

Actually, we are working on the implicit declaration of the TF type.
Your TF will be then valid; unfortunately, for now, it is not.


#5

Hi,

Thank you for the explanation. But this function both subscribes and publishes, though its primary effect is to publish. Does it matter which one I use (@nrp.Neuron2Robot? or nrp.Robot2Neuron()?)

Glad you guys are working on it.


#6

If you are working only with topics, there are no differences.


#7

Hi,

currently, there is not really a difference between Neuron2Robot and Robot2Neuron TFs. However, the system keeps the two of them seperate and currently executes first all Robot2Neuron TFs and then all Neuron2Robot TFs. In the future, we reserve the idea to run the two groups of TFs in parallel as we assume that they won’t interact with each other. This was also the original idea why we introduced two different types.

As a bonus, Neuron2Robot allows you to specify a default topic to which the return value of the TF should be sent.

However, we received plenty of requests to make that error you experienced to go away. Therefore, we started to make these decorators optional. This usability improvement is already merged in the development branch and will be in the Bitbucket soon.