ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
for c in config
iterates over the keys of the config, not the values. I think you want:
host = rospy.get_param("~host", None)
sock = nxt.locator.find_one_brick(host)
b = sock.connect()
config = rospy.get_param("~"+ns)
components = []
for k, c in config.items():
# do something with k - it might be useful
rospy.loginfo("Creating %s with name %s on %s",c['type'],c['name'],c['port'])
if c['type'] == 'motor':
components.append(Motor(c, b))
elif c['type'] == 'touch':
components.append(TouchSensor(c, b))
elif c['type'] == 'ultrasonic':
components.append(UltraSonicSensor(c, b))
elif c['type'] == 'color':
components.append(ColorSensor(c, b))
elif c['type'] == 'intensity':
components.append(IntensitySensor(c, b))
elif c['type'] == 'gyro':
components.append(GyroSensor(c, b))
elif c['type'] == 'accelerometer':
components.append(AccelerometerSensor(c, b))
else:
rospy.logerr('Invalid sensor/actuator type %s'%c['type'])