tools module

Various functions and objects that we found useful to place here so all files can share its functionality.

Authors:
Michele Albach, Parash Rahman, Niko Yasui.
tools.action_state_rep(action_space)[source]

Creates a function that generates phi (feature rep of state) based on all other aspects of state (e.g. camera, ir, etc.) and action.

Parameters:action_space – a list of all possible actions
tools.constant(base)[source]

Yields a constant value.

Used for constant parameters (e.g. constant alpha)

tools.decay(base)[source]

Yields the base value divided by t each timestep.

Used for decaying parameters (e.g. decaying alpha)

tools.dock_ir_parse(dock_ir)[source]
tools.equal_twists(t1, t2)[source]

Determines if two Twist actions are equal

Parameters:t2 (t1,) – the Twist actions in question
tools.get_next_pow2(number)[source]

Gets the next highest power of two for number

tools.image_parse(img, enc='passthrough')[source]

Converts a ros image to a numpy array

tools.imu_parse(data)[source]
tools.overrides(interface_class)[source]

Decorator that ensures overriden methods are valid.

Parameters:interface_class – the respective super class

Example:

class ConcreteImplementer(MySuperInterface):
    @overrides(MySuperInterface)
    def my_method(self):
        print 'hello kitty!'
tools.pc2_parse(data)[source]

PointCloud2 parser pc2.read_points returns a generator of (x,y,z) tuples

tools.sensor_state_parse(data)[source]

Formats all the sensorimotor data into an appropriate dictionary with appropriate types

tools.softmax(q)[source]
tools.timing(f)[source]

Decorator that print how long a function takes to execute.

tools.topic_format = {'/camera/depth/image': <class 'sensor_msgs.msg._Image.Image'>, '/camera/rgb/image_raw': <class 'sensor_msgs.msg._Image.Image'>, '/mobile_base/sensors/dock_ir': <class 'kobuki_msgs.msg._DockInfraRed.DockInfraRed'>, '/mobile_base/sensors/core': <class 'kobuki_msgs.msg._SensorState.SensorState'>, '/camera/ir/image': <class 'sensor_msgs.msg._Image.Image'>, '/camera/rgb/image_rect_color': <class 'sensor_msgs.msg._Image.Image'>, '/mobile_base/sensors/imu_data': <class 'sensor_msgs.msg._Imu.Imu'>, '/odom': <class 'nav_msgs.msg._Odometry.Odometry'>, '/camera/rgb/image_rect_color/compressed': <class 'sensor_msgs.msg._CompressedImage.CompressedImage'>, '/camera/depth/points': <class 'sensor_msgs.msg._PointCloud2.PointCloud2'>, '/turtle1/pose': <class 'turtlesim.msg._Pose.Pose'>}

features mapped to their corresponding ROS topic