simondlevy / airsimtensorflow Goto Github PK
View Code? Open in Web Editor NEWA simple example of using Microsoft AirSim to train a TensorFlow neural net on collision avoidance
License: Other
A simple example of using Microsoft AirSim to train a TensorFlow neural net on collision avoidance
License: Other
Hi, help please update collision_testing. py. All working, but arrors in lines 71 and 74.
import airsim
#from AirSimClient import CarClient, CarControls, ImageRequest, AirSimImageType, AirSimClientBase
import os
import time
import tensorflow as tf
import pickle
import sys
from image_helper import loadgray, IMAGEDIR
from tf_softmax_layer import inference
TMPFILE = IMAGEDIR + '/active.png'
PARAMFILE = 'params.pkl'
IMGSIZE = 1032
INITIAL_THROTTLE= 0.65
BRAKING_DURATION = 15
client = airsim.CarClient()
client.confirmConnection()
print('Connected')
client.enableApiControl(True)
car_controls = airsim.CarControls()
client.reset()
car_controls.throttle = INITIAL_THROTTLE
car_controls.steering = 0
client.setCarControls(car_controls)
W,b = pickle.load(open('params.pkl', 'rb'))
with tf.Graph().as_default():
# Placeholder for an image
x = tf.placeholder('float', [None, IMGSIZE])
# Our inference engine, intialized with weights we just loaded
output = inference(x, IMGSIZE, 2, W, b)
# TensorFlow initialization boilerplate
sess = tf.Session()
init_op = tf.global_variables_initializer()
sess.run(init_op)
# Once the brakes come on, we need to keep them on for a while before exiting; otherwise,
# the vehicle will resume moving.
brakingCount = 0
# Loop until we detect a collision
while True:
# Get RGBA camera images from the car
responses = client.simGetImages([airsim.ImageRequest("1", airsim.ImageType.Scene)])
# Save it to a temporary file
image = responses[0].image_data_uint8
AirSimClientBase.write_file(os.path.normpath(TMPFILE), image) ### NameError: name 'AirSimClientBase' is not defined
# Read-load the image as a grayscale array
image = loadgray(TMPFILE) ### FileNotFoundError: [Errno 2] No such file or directory: './carpix/active.png'
# Run the image through our inference engine.
# Engine returns a softmax output inside a list, so we grab the first
# element of the list (the actual softmax vector), whose second element
# is the absence of an obstacle.
safety = sess.run(output, feed_dict={x:[image]})[0][1]
# Slam on the brakes if it ain't safe!
if safety < 0.5:
if brakingCount > BRAKING_DURATION:
print('BRAKING TO AVOID COLLISSION')
sys.stdout.flush()
break
car_controls.brake = 1.0
client.setCarControls(car_controls)
brakingCount += 1
# Wait a bit on each iteration
time.sleep(0.1)
client.enableApiControl(False)
@simondlevy Every time the sim initialized with image_collection.py the 10 images leading to the crash are stored removing the images for the previous crash. My understanding is we need to collect as many "crash"images as we can to train the network. So is this an issue and a bug need to be fixed in the code or am I missing something?
Thanks!
Hello, I download the AirSimNH 1.2.0 environment from the github, but when I run the run.bat and image_colleection.py the cmd shows as follow:
WARNING:tornado.general:Connect error on fd 284: WSAECONNREFUSED
WARNING:tornado.general:Connect error on fd 284: WSAECONNREFUSED
WARNING:tornado.general:Connect error on fd 284: WSAECONNREFUSED
WARNING:tornado.general:Connect error on fd 284: WSAECONNREFUSED
WARNING:tornado.general:Connect error on fd 284: WSAECONNREFUSED
Waiting for connection: Traceback (most recent call last):
File ".\image_collection.py", line 30, in
client.confirmConnection()
File "C:\Users\Asus\Desktop\AirSimTensorFlow\AirSimClient.py", line 160, in confirmConnection
home = self.getHomeGeoPoint()
File "C:\Users\Asus\Desktop\AirSimTensorFlow\AirSimClient.py", line 169, in getHomeGeoPoint
return GeoPoint.from_msgpack(self.client.call('getHomeGeoPoint'))
File "F:\Python3.5.4\lib\site-packages\msgpackrpc\session.py", line 41, in call
return self.send_request(method, args).get()
File "F:\Python3.5.4\lib\site-packages\msgpackrpc\future.py", line 43, in get
raise self._error
msgpackrpc.error.TransportError: Retry connection over the limit
I do know the airsim does not work, but I can not fix it. Could you help me please?
Congratulations on your project. Have you tested something with the drone mode?
I am now doing the final thesis of my bachelor degree related to Machine Learning in drone simulations and I'm starting with something like what you did but with the drone mode, and some advices would be useful.
Thanks!
hi, I am facing crashing of the unreal engine 4 as I try to execute the file named run.don't know why it is happening can you guide me, please. also I wanted to ask which version of the unreal engine have you used in making the environment? bellow have attached the error that I am facing any help will be very helpful.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.