Exemplo n.º 1
0
    def testRender(self):

        env = BasicEnvironment("0004d52d1aeeb8ae6de39d6bd993e992",
                               suncgDatasetRoot=TEST_SUNCG_DATA_DIR,
                               depth=True)

        env.agent.setPos(LVector3f(42, -39, 1))
        env.agent.setHpr(LVector3f(60.0, 0.0, 0.0))

        env.step()

        image = env.renderWorld.getRgbImages()['agent-0']
        depth = env.renderWorld.getDepthImages(mode='distance')['agent-0']

        fig = plt.figure(figsize=(16, 8))
        plt.axis("off")
        ax = plt.subplot(121)
        ax.imshow(image)
        ax = plt.subplot(122)
        ax.imshow(depth / np.max(depth), cmap='binary')
        plt.show(block=False)
        time.sleep(1.0)
        plt.close(fig)

        env.destroy()
Exemplo n.º 2
0
        def worker():

            env = BasicEnvironment("0004d52d1aeeb8ae6de39d6bd993e992",
                                   suncgDatasetRoot=TEST_SUNCG_DATA_DIR,
                                   depth=False,
                                   debug=True)

            env.agent.setPos(LVector3f(45, -42, 1))
            env.agent.setHpr(LVector3f(45.0, 0.0, 0.0))

            # Simulation loop
            for _ in range(nbSteps):
                env.step()
                _ = env.getObservation()

            env.destroy()
Exemplo n.º 3
0
    def testStep(self):

        try:
            env = BasicEnvironment(houseId="0004d52d1aeeb8ae6de39d6bd993e992",
                                   suncgDatasetRoot=TEST_SUNCG_DATA_DIR,
                                   realtime=True)
            env.setAgentOrientation((60.0, 0.0, 0.0))
            env.setAgentPosition((42, -39, 1.1))

            controller = Controller(env.scene, showPosition=True)

            for _ in range(10):
                controller.step()
            time.sleep(1.0)

        finally:
            env.destroy()
            controller.destroy()
Exemplo n.º 4
0
    def testGenerateSpawnPositions(self):

        env = BasicEnvironment("0004d52d1aeeb8ae6de39d6bd993e992",
                               suncgDatasetRoot=TEST_SUNCG_DATA_DIR,
                               depth=False)

        occupancyMap, occupancyMapCoord, positions = env.generateSpawnPositions(
            n=10)

        xmin, ymin = np.min(occupancyMapCoord, axis=(0, 1))
        xmax, ymax = np.max(occupancyMapCoord, axis=(0, 1))

        fig = plt.figure()
        plt.axis("on")
        ax = plt.subplot(111)
        ax.imshow(occupancyMap, cmap='gray', extent=[xmin, xmax, ymin, ymax])
        ax.scatter(positions[:, 0], positions[:, 1], s=40, c=[1.0, 0.0, 0.0])
        plt.show(block=False)
        time.sleep(1.0)
        plt.close(fig)

        env.destroy()