time.sleep(1) #do a random move to not get stuck around an "island" j=j+1 if j=10000: random() j=0 ########## ########## if __name__ == "__main__": plt.ion() # Initialize and start the environment environment = VrepEnvironment(settings.SCENES + '/room_static.ttt') # Open the file containing our scene (robot and its environment) environment.connect() # Connect python to the simulator's remote API agent = Pioneer(environment) display = Display(agent, False) print('\nDemonstration of Simultaneous Localization and Mapping using CoppeliaSim robot simulation software. \nPress "CTRL+C" to exit.\n') start = time.time() step = 0 done = False environment.start_simulation() time.sleep(1) try: while step < settings.simulation_steps and not done: display.update() # Update the SLAM display loop(agent) # Control loop
def get_and_save_data(): for scene, angle in zip(["0", "l90", "r90"], [(90, 180), (0, 90), (180, 270)]): environment = VrepEnvironment(settings.SCENES + '/room_calib_' + scene + '.ttt') # environment.start_vrep() environment.connect() environment.load_scene(settings.SCENES + '/room_calib_' + scene + '.ttt') environment.start_simulation() agent = Pioneer(environment) time.sleep(1) sample = agent.read_lidars() ranges = np.array(sample)[angle[0]:angle[1]] for _ in range(0, 29): sample = agent.read_lidars() ranges += np.array(sample)[angle[0]:angle[1]] ranges = ranges / 10 np.savetxt("ranges_" + scene + ".txt", ranges) environment.stop_simulation() environment.disconnect() del environment
4. agent.pos ---- Current x,y position of the agent (derived from SLAM data) 5. agent.position_history A deque containing N last positions of the agent (200 by default, can be changed in settings.py) """ if __name__ == "__main__": # Initialize and start the environment # Open the file containing our scene (robot and its environment) environment = VrepEnvironment(settings.SCENES + '/room_static.ttt') environment.connect() # Connect python to the simulator's remote API agent = Pioneer(environment) print('\nDemonstration of Simultaneous Localization and Mapping using ' 'CoppeliaSim robot simulation software. \nPress "CTRL+C" to exit.\n') start = time.time() step = 0 done = False environment.start_simulation() time.sleep(1) state = bot.State() try: while step < settings.simulation_steps and not done: # display.update() # Update the SLAM display