コード例 #1
0
ファイル: rosbag_to_sample.py プロジェクト: Jackustc/probcoll
        image_msg = image_time_msg[1]
        cmd_vel_msg = cmd_vel_time_msg[1]

        ### image
        im = AgentBebop2d.process_image(image_msg, cvb)
        sample.set_O(im.ravel(), t=t, sub_obs='camera')

        ### collision
        sample.set_O([0], t=t, sub_obs='collision')

        ### linearvel
        sample.set_X([cmd_vel_msg.linear.x, cmd_vel_msg.linear.y], t=t)
        sample.set_U([cmd_vel_msg.linear.x, cmd_vel_msg.linear.y], t=t)
    sample.set_O([int(is_coll)], t=-1, sub_obs='collision')
    # sample.set_O([int(np.random.random() > 0.5)], t=-1, sub_obs='collision') # tmp

    assert(sample.isfinite())

    return sample

if __name__ == '__main__':
    rospy.init_node('rosbag_to_sample', anonymous=True)

    yaml_path = os.path.join(FOLDER, 'params_bebop2d.yaml')
    load_params(yaml_path)

    samples = [rosbag_to_sample(os.path.join(FOLDER, f))
               for f in sorted(os.listdir(FOLDER)) if os.path.splitext(f)[1] == '.bag']
    samples = filter(lambda x: x is not None, samples)
    Sample.save(os.path.join(FOLDER, 'samples.npz'), samples)
コード例 #2
0
ファイル: probcoll.py プロジェクト: Jackustc/probcoll
 def _itr_save_samples(self, itr, samples, prefix=''):
     Sample.save(self._itr_samples_file(itr, prefix=prefix), samples)