def __init__(self,
              env,
              max_episodes,
              max_steps,
              log_file=None,
              downscale=False,
              playback=True,
              filter_bad_data=False):
     if not log_file:
         log_file = f"dataset.log"
     self.env = env
     self.env.reset()
     self.datagen = Logger(self.env, log_file=log_file)
     self.episode = 1
     self.max_episodes = max_episodes
     self.filter_bad_data = filter_bad_data
     #! Temporary Variable Setup:
     self.last_reward = 0
     self.playback_buffer = []
     #! Enter main event loop
     pyglet.clock.schedule_interval(self.update,
                                    1.0 / self.env.unwrapped.frame_rate,
                                    self.env)
     #! Get Joystick
     self.joysticks = pyglet.input.get_joysticks()
     assert self.joysticks, 'No joystick device is connected'
     self.joystick = self.joysticks[0]
     self.joystick.open()
     self.joystick.push_handlers(self.on_joybutton_press)
     pyglet.app.run()
     #! Log and exit
     self.datagen.close()
     self.env.close()
예제 #2
0
    def __init__(self,
                 env,
                 max_episodes,
                 max_steps,
                 log_file=None,
                 downscale=False):
        if not log_file:
            log_file = f"dataset.log"
        self.env = env
        self.env.reset()
        self.logger = Logger(self.env, log_file=log_file)
        self.episode = 1
        self.max_episodes = max_episodes
        self.downscale = downscale

        #! Enter main event loop
        print("Starting data generation")

        pyglet.clock.schedule_interval(self.update,
                                       1.0 / self.env.unwrapped.frame_rate,
                                       self.env)

        pyglet.app.run()

        print("App exited, closing file descriptors")
        self.logger.close()
        self.env.close()
import collections
import rosbag
import cv_bridge
from copy import copy
from extract_data_functions import image_preprocessing, synchronize_data
from log_util import Logger
from log_schema import Episode, Step
import cv2

VEHICLE_NAME = 'avlduck2'

# A collection of ros messages coming from a single topic.
MessageCollection = collections.namedtuple(
    "MessageCollection", ["topic", "type", "messages"])

frank_logger = Logger(log_file='converted/dataset.log')


def extract_messages(path, requested_topics):

    # check if path is string and requested_topics a list
    assert isinstance(path, str)
    assert isinstance(requested_topics, list)

    bag = rosbag.Bag(path)

    _, available_topics = bag.get_type_and_topic_info()

    # print(available_topics)

    # check if the requested topics exist in bag's topics and if yes extract the messages only for them
import rosbag
import cv_bridge
from copy import copy
from extract_data_functions import image_preprocessing, synchronize_data
from log_util import Logger
from log_schema import Episode, Step
import cv2

# Change this based on the bag files being used.
VEHICLE_NAME = 'maserati'

# A collection of ros messages coming from a single topic.
MessageCollection = collections.namedtuple(
    "MessageCollection", ["topic", "type", "messages"])

frank_logger = Logger(log_file=f'converted/{VEHICLE_NAME}')


def extract_messages(path, requested_topics):

    # check if path is string and requested_topics a list
    assert isinstance(path, str)
    assert isinstance(requested_topics, list)

    bag = rosbag.Bag(path)

    _, available_topics = bag.get_type_and_topic_info()
    # check if the requested topics exist in bag's topics and if yes extract the messages only for them
    extracted_messages = {}
    for topic in requested_topics:
        if topic in available_topics: