classes = np.array(classes)

    return boxes, classes


if __name__ == "__main__":

    DEBUG = False
    NPZ_INDEX = 0
    DATA_TO_COLLECT = 1000  # we want to get 1000 data points

    seed(123)
    environment = launch_env()

    policy = PurePursuitPolicy(environment)

    MAX_STEPS = 500

    SAMPLE_FREQ = 10

    while NPZ_INDEX < DATA_TO_COLLECT:
        obs = environment.reset()
        environment.render(segment=True)
        rewards = []

        nb_of_steps = 0

        while NPZ_INDEX < DATA_TO_COLLECT:
            action = policy.predict(np.array(obs))
Exemple #2
0
                mask[pos[0],pos[1],:] = segmented_im[pos[0],pos[1],:]
    return boxes, labels, mask

def plotWithBoundingBoxes(seg_im,boxes,labels):
    for i in range(len(labels)):
        cv.rectangle(seg_im, (boxes[i][0],boxes[i][1]), (boxes[i][2],boxes[i][3]), (255,255,255),1)
        cv.rectangle(seg_im,(boxes[i][0],boxes[i][1]),(boxes[i][0]+10,boxes[i][1]-12),(255,255,255),cv.FILLED)
        cv.putText(seg_im,str(labels[i]),(boxes[i][0],boxes[i][1]),cv.FONT_HERSHEY_COMPLEX,0.5,(0,0,0),1)
    return seg_im
        


seed(123)
environment = launch_env()

policy = PurePursuitPolicy(environment)

MAX_STEPS = 500

while True:
    obs = environment.reset() # create first segmented image
    environment.render(segment=True) # visualize first segmented image
    rewards = []

    nb_of_steps = 0

    while True:
        action = policy.predict(np.array(obs)) # predicts action (v and omega using purepursuit controller)

        obs, rew, done, misc = environment.step(action) # Gives non-segmented obs as numpy array
        segmented_obs = environment.render_obs(True)  # Gives segmented obs as numpy array