예제 #1
0
    def __init__(self):
        rospy.init_node('constant_feature_publisher')

        stream_name = rospy.get_param('~stream_name')
        description = rospy.get_param('~description')
        self.features = rospy.get_param('~features')
        self.mode = rospy.get_param('~mode')

        opt_args = {}
        if self.mode == 'push':
            opt_args['queue_size'] = rospy.get_param('~queue_size', 0)
            self.publish_rate = rospy.Rate(rospy.get_param('~publish_rate'))
        elif self.mode == 'pull':
            opt_args['cache_time'] = float('inf')
        else:
            raise ValueError('Mode must be pull or push')

        rate = rospy.get_param('~publish_rate', 1.0)
        self.publish_rate = rospy.Rate(rate)

        self.feat_tx = broadcast.Transmitter(stream_name=stream_name,
                                             namespace='~',
                                             feature_size=len(self.features),
                                             description=description,
                                             mode=self.mode,
                                             **opt_args)
예제 #2
0
    def __init__(self):
        self.mode = rospy.get_param('dim_mode')
        if self.mode == '2d':
            dim = 3
        elif self.mode == '3d':
            dim = 6
        else:
            raise ValueError('Unknown mode %s' % self.mode)

        topic = rospy.get_param('~stream_name')
        self.tx = broadcast.Transmitter(stream_name=topic,
                                        feature_size=dim,
                                        description='Velocity components',
                                        mode='push')

        self.velsub = rospy.Subscriber('twist', TwistStamped,
                                       self.twist_callback)
예제 #3
0
    def __init__(self):
        self.dim = rospy.get_param('~dim')
        self.params = []

        self._critique_server = rospy.Service('~get_critique', GetCritique,
                                              self.critique_callback)

        self.err_cutoff = rospy.get_param('~err_cutoff')
        self.action_bias = np.random.uniform(-0.5, 0.5, self.dim)
        rospy.loginfo('Action bias: %s', np.array_str(self.action_bias))

        # Set up state generator and transmitter
        self.state = None
        self.state_tx = broadcast.Transmitter(
            stream_name='next_bandit_state',
            feature_size=self.dim,
            description='Test bandit problem context/state',
            mode='pull',
            queue_size=10)
        self.__update_state()
예제 #4
0
    def __init__(self):

        self.scale = rospy.get_param('~scale')

        self.lap_k = rospy.get_param('~laplacian_k', 1)
        self.bridge = CvBridge()

        self.num_pyrs = rospy.get_param('~pyramid_levels', 0)

        stream_name = rospy.get_param('~stream_name')
        self.feat_tx = broadcast.Transmitter(stream_name=stream_name,
                                             namespace='~',
                                             feature_size=self.num_pyrs + 1,
                                             description=['laplacian_std'],
                                             mode='push',
                                             queue_size=0)

        buff_size = rospy.get_param('~buffer_size', 1)
        self.image_sub = rospy.Subscriber('image', Image,
                                          self.ImageCallback,
                                          queue_size=buff_size)
예제 #5
0
    def __init__(self):

        dt = rospy.get_param('~cart_dt')
        max_acc = rospy.get_param('~cart_max_acc')
        max_steps = rospy.get_param('~cart_max_steps')
        self.cart = CartSystem(dt=dt, max_acc=max_acc, max_steps=max_steps)

        # Initialize cart parameters
        self.parameters = []
        for i in range(self.cart.pos_dim):
            param = paraset.RuntimeParamGetter(param_type=float,
                                               name='acc_%d' % i,
                                               init_val=0,
                                               description='cart acceleration')
            self.parameters.append(param)

        update_rate = rospy.get_param('~tick_rate')
        self.timer = rospy.Timer(period=rospy.Duration(1.0 / update_rate),
                                 callback=self.timer_callback)

        self.last_acc = np.zeros(2)
        self.rew_pub = rospy.Publisher('~reward', RewardStamped, queue_size=10)
        self.break_pub = rospy.Publisher('~breaks',
                                         EpisodeBreak,
                                         queue_size=10)

        # Set up state generator and transmitter
        self.state_tx = broadcast.Transmitter(
            stream_name='cart_state',
            feature_size=self.cart.state_dim,
            description='Test continuous problem state',
            mode='push',
            queue_size=10)

        reward = self.cart.reset()
        self.__publish_cart(time=rospy.Time.now(), reward=reward)
예제 #6
0
#!/usr/bin/env python

import rospy
import broadcast

if __name__ == '__main__':
    rospy.init_node('test_transmitter')

    push_tx = broadcast.Transmitter(stream_name='test_push_stream',
                                    feature_size=1,
                                    description='A test push stream',
                                    mode='push',
                                    queue_size=10)
    pull_tx = broadcast.Transmitter(stream_name='test_pull_stream',
                                    feature_size=1,
                                    description='A test pull stream',
                                    mode='pull',
                                    cache_time=1.0)

    counter = 0
    rate = rospy.Rate(1.0)
    while not rospy.is_shutdown():

        now = rospy.Time.now()
        data = [counter]

        rospy.loginfo('Publishing %s at %s', str(data), str(now))

        push_tx.publish(now, data)
        pull_tx.publish(now, data)
        counter += 1