Beispiel #1
0
    def create_table(self, dtype):
        filters = tables.Filters(complevel=9, complib='zlib',
                                 fletcher32=True)
        # TODO: CONSTANTS
        group = '/boot_olympics/streams/%s' % self.id_stream
        self.table = self.hf.createTable(
                        where=group,
                        name='boot_stream',
                        description=dtype,
                        filters=filters,
                        createparents=True
                    )
        structure = self.boot_spec.to_yaml()
        yaml_spec = yaml_dump(structure)

        filters_text = tables.Filters(complevel=1, shuffle=False,
                                      fletcher32=False, complib='zlib')

        self.extra = self.hf.createVLArray(group, 'extra',
                                           tables.VLStringAtom(),
                                           filters=filters_text)

        if False:
            # old version
            self.table.attrs['boot_spec'] = yaml_spec
        else:
            boot_spec_table = self.hf.createVLArray(group, 'boot_spec',
                                                tables.VLStringAtom(),
                                                filters=filters_text)
            boot_spec_table.append(yaml_spec)
Beispiel #2
0
def main():
    from vehicles_cairo import (cairo_ref_frame, cairo_rototranslate,
                                vehicles_cairo_display_png)
    # Instance robot object
    id_robot = 'r_cam_A'
    filename = 'test.png'
    resolution = 0.5

    config = get_boot_config()

    cd1 = '/Users/andrea/scm/boot11_env/src/vehicles/src/vehicles/configs'
    cd2 = '/Users/andrea/scm/boot11_env/src/bvapps/bo_app1/config'
    
    GlobalConfig.global_load_dir('default')
    GlobalConfig.global_load_dir(cd1)
    GlobalConfig.global_load_dir(cd2)

    robot = config.robots.instance(id_robot)  # @UndefinedVariable
    robot.new_episode()

    locations = get_grid(robot=robot, debug=True,
                        world=robot.world,
                        vehicle=robot.vehicle, resolution=resolution)
    poses = [f['pose'] for f in locations]

#    poses = elastic(poses, alpha=0.1, num_iterations=20)

    print('Converting to yaml...')
    robot.vehicle.set_pose(poses[0])
    state = robot.to_yaml()

    pprint(state)
    print(yaml_dump(state))

    def extra_draw_world(cr):
        for pose in poses:
            with cairo_rototranslate(cr, SE2_from_SE3(pose)):
                cairo_ref_frame(cr, l=0.5,
                            x_color=[0, 0, 0], y_color=[0, 0, 0])

    plotting_params = {}
    plotting_params['extra_draw_world'] = extra_draw_world

    print('Writing to: %r' % filename)
    vehicles_cairo_display_png(filename, width=800, height=800,
                                sim_state=state,
                               **plotting_params)

    print('... done')
Beispiel #3
0
    def push_observations(self, observations, extra={}):
        if self.table is None:
            self.table_dtype = remove_fields(observations.dtype, ['extra'])
            self.create_table(self.table_dtype)
            # TODO: check that the boot_spec is satisfied

        # TODO: what about extra?
        row = np.zeros((), self.table_dtype)
        copy_from(row, observations)

        row = row.copy().reshape((1,))
        self.table.append(row)

        assert isinstance(extra, dict)
        extras = yaml_dump(extra)
        extras_gz = compress(extras)
        # ratio = 100.0 * len(extras_gz) / len(extras)
        # print('Compressed %.1f%%' % (ratio))
        self.extra.append(extras_gz)