Skip to content
Snippets Groups Projects
Select Git revision
  • e4f712e078910f5d73dc058c4ec5d72d8cabefb4
  • master default
  • feature_scripts
  • develop
  • feature_without_logging
  • feature_opc_server
  • feature_seperate_apps
  • fix_raspi_cmake
  • ss19 protected
  • ss20
10 results

SmartOpcServer.hpp

Blame
  • main_test.py 1.13 KiB
    # -*- coding: utf-8 -*-
    """
    Created on Tue Jan 12 17:17:49 2021
    
    @author: theob
    """
    
    import asyncio
    import Gym_new
    import time
    import nest_asyncio
    import show_image as si
    
        
    
    async def main():
        image_mode = 'L'
        
        
        env = Gym_new.Gym()
        await env.connect_websocket()
        
        # Resets the enviroment
        observation, reward, done, info = await env.reset("",0.01)
        print(observation)
        print(reward)
        print(done)
        
        # Makes 1 step only driving straight
        observation, reward, done, info = await env.step("accelerate,screen_on", 0.17) 
        print(observation) 
        # Obeservation is an array with the following information: 
        # [speed, steering-angle, [length of all sensors (starting straight and then clockwise around the car)]]
        print(reward)
        print(done)
        
        try:
        # Test show Image
            si.show_image(image_mode,info['thumbnail']['width'],info['thumbnail']['height'],info['thumbnail']['image'])
        except Exception as e:
            print("failed showing image: " + str(e))
    
    if __name__ == "__main__":
        nest_asyncio.apply()
        loop = asyncio.get_event_loop()
        loop.run_until_complete(main())