Exemple #1
0
class WallCreator(threading.Thread):
    def __init__(self, data, wall_data):
        super(WallCreator, self).__init__()
        self.coppelia = CoppeliaSimAPI(['./scenes/'])
        self.data = data
        self.wall_data = wall_data

    def run(self):
        if len(self.wall_data) > 2:
            for wall in self.wall_data:
                wall_object = self.coppelia.create_wall(wall[0], wall[1])
                self.data['walls_mutex'].acquire()
                self.data['walls'].append(wall_object)
                self.data['walls_mutex'].release()

        else:
            wall_object = self.coppelia.create_wall(self.wall_data[0],
                                                    self.wall_data[1])
            self.data['walls_mutex'].acquire()
            self.data['walls'].append(wall_object)
            self.data['walls_mutex'].release()
Exemple #2
0
 def __init__(self, data, wall_data):
     super(WallCreator, self).__init__()
     self.coppelia = CoppeliaSimAPI(['./scenes/'])
     self.data = data
     self.wall_data = wall_data
Exemple #3
0
from coppeliasimapi import CoppeliaSimAPI, YouBot, Pioneer_p3dx
import threading
import setproctitle
setproctitle.setproctitle('coppeliaExample1')

from math import pi

pygame.display.init()
pygame.joystick.init()
pygame.joystick.Joystick(0).init()

# The CoppeliaSimAPI constructor receives a list of paths that the object will use to find models.
# Don't worry about the models in the CoppeliaSim path, the object will automatically append
# $COPPELIASIM_ROOT to the list, so there is no need to provide any parameter if you are only using
# the models provided by the simulator.
coppelia = CoppeliaSimAPI(['./scenes/'])

# Stop the simulator and close the scene, just in case.
coppelia.stop()
coppelia.close()
coppelia.stop()
coppelia.close()

# Load a basic scene
coppelia.load_scene('dataset.ttt')

children = coppelia.get_objects_children('sim.handle_scene',
                                         children_type='sim.all_type',
                                         filter_children=1 + 2)
for child in children:
    name = coppelia.get_object_name(child)
Exemple #4
0
        if intersected or room_contained_in_prev or prev_contained_in_room:
            print('room intersects with existing room')
            valid_room = False
            break

    if valid_room:
        random_qrect_list.append(random_room)
        dict_rooms_per_side[random_side] += 1

    return valid_room


# ----------------------------------------------------------------
setproctitle.setproctitle('Coppelia_random_appartment')
pygame.display.init()
coppelia = CoppeliaSimAPI(['./models/'])

# Stop the simulator and close the scene, just in case.
coppelia.stop()
coppelia.close()
coppelia.stop()
coppelia.close()

# Move the floor downwards, as we want to use a prettier floor.
print('Getting floor name')
floor = coppelia.get_object_handle('ResizableFloor_5_25')
# print('ret:', floor)
coppelia.set_object_transform('ResizableFloor_5_25', 0.0, 0.0, -1.0, 0)
coppelia.scale_object('ResizableFloor_5_25', 0.1, 0.1, 0.1)
coppelia.set_object_position('DefaultCamera', 0, 0, 25.)
coppelia.set_object_orientation('DefaultCamera', 3.14, 0, 3.14)
Exemple #5
0
        if valid_object:
            print('adding sofa ')
            objects_in_room.append(sofa)


def get_point_inside_room(r):
    margin = 0.5
    return QPointF(random.uniform(r.left() + margin,
                                  r.right() - margin),
                   random.uniform(r.bottom() + margin,
                                  r.top() - margin))


if '__main__':

    coppelia = CoppeliaSimAPI(['./models/'])

    # Stop the simulator and close the scene, just in case.
    coppelia.stop()
    coppelia.close()

    # Move the floor downwards, as we want to use a prettier floor.
    print('Getting floor name')
    floor = coppelia.get_object_handle('ResizableFloor_5_25')
    # print('ret:', floor)
    coppelia.set_object_transform('ResizableFloor_5_25', 0.0, 0.0, -2.0, 0)
    coppelia.scale_object('ResizableFloor_5_25', 0.1, 0.1, 0.1)
    coppelia.set_object_position('DefaultCamera', 0, 0, 30.)
    coppelia.set_object_orientation('DefaultCamera', 3.14, 0, 3.14)

    num_rooms = 1
Exemple #6
0
import random
import pygame
from coppeliasimapi import CoppeliaSimAPI, YouBot

import setproctitle
setproctitle.setproctitle('coppeliaExample1')

pygame.display.init()
pygame.joystick.init()
pygame.joystick.Joystick(0).init()

# The CoppeliaSimAPI constructor receives a list of paths that the object will use to find models.
# Don't worry about the models in the CoppeliaSim path, the object will automatically append
# $COPPELIASIM_ROOT to the list, so there is no need to provide any parameter if you are only using
# the models provided by the simulator.
coppelia = CoppeliaSimAPI(['./models/'])

# Stop the simulator and close the scene, just in case.
coppelia.stop()
coppelia.close()
coppelia.stop()
coppelia.close()

# Move the floor downwards, as we want to use a prettier floor.
print('Getting floor name')
floor = coppelia.get_object_handle('ResizableFloor_5_25')
print('ret:', floor)
coppelia.set_object_transform('ResizableFloor_5_25', 0.0, 0.0, -1.0, 0)

# We are going to put our floor 10 metres up, just because we can, so we better move the camera too.
coppelia.set_object_position('DefaultCamera', 5.0, -7.0, 14.)
import json
import os.path
import re
import time
from math import pi
from random import randint, uniform
import numpy as np
import pygame
from coppeliasimapi import CoppeliaSimAPI, YouBot, PointPair

# joystick setup
pygame.display.init()
pygame.joystick.init()
pygame.joystick.Joystick(0).init()
# find the models from coppelia
coppelia = CoppeliaSimAPI(['./scenes/'])
# ensure coppelia is not running
coppelia.stop()
coppelia.close()
# scene constants
# HEIGHT is the wall height
HEIGHT = 0.3
# MAX_Y is the highest y for the walls
MAX_Y = 4.0
# Variable to store the data for json in
json_dictionary = {}
# Load the scene
coppelia.load_scene('dataset.ttt')
# Access scene children
children = coppelia.get_objects_children('sim.handle_scene',
                                         children_type='sim.all_type',