Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2623581
Change write.py and consequent launch files in order to record boolea…
Aug 30, 2021
69868c9
Change write.py and consequent launch files in order to record boolea…
Aug 30, 2021
cc368f1
Bug fix to run real car with velocity first
Aug 30, 2021
5a0dea5
Merge pull request #37 from AutomecUA/30_08
brunomonteiro98 Sep 8, 2021
33146b5
Show Robot View as file is recording
Sep 8, 2021
503f7b1
fix cap.release() issue
DanielCoelho112 Sep 9, 2021
54f5833
Merge pull request #39 from AutomecUA/cap_release_problem
manuelgitgomes Sep 9, 2021
ce9c486
Merge pull request #38 from AutomecUA/write_windows
manuelgitgomes Sep 9, 2021
b47dc39
issue 40 (yaml files)
inaciose Sep 15, 2021
5a55546
Changed button from press to switch
Sep 16, 2021
6a88c51
issue 45, simuation object meshes
inaciose Sep 17, 2021
28a4bed
add jpg file to kinect mesh
inaciose Sep 17, 2021
4c90589
issue 41 - start adding kinect to gazebo (wip)
inaciose Sep 17, 2021
31d592a
issue 46, gitignore jpg's
inaciose Sep 17, 2021
a6d8111
removed because i can push commits
inaciose Sep 17, 2021
663d75c
Merge branch 'dev_kinect' of https://github.com/AutomecUA/AutoMec-AD …
inaciose Sep 17, 2021
a5aafc0
add kinect jpg (due to issue 46)
inaciose Sep 17, 2021
b80ae02
Removed Pillow from requirements.txt
Sep 17, 2021
a445473
Changed .gitignore to allow images but disallow all files on cnn/data…
Sep 17, 2021
f9f60b7
Removed models from repository
Sep 17, 2021
80455e4
Merge pull request #48 from AutomecUA/bug/reqignore
inaciose Sep 17, 2021
f6e4f64
issue 41 (wip), kinect gazebo update
inaciose Sep 17, 2021
1d63f6a
issue 41, dual kinect gazebo
inaciose Sep 18, 2021
e81d05d
new dev presencital
brunomonteiro98 Sep 22, 2021
9352416
Merge pull request #44 from AutomecUA/dev_yaml
manuelgitgomes Sep 22, 2021
ab3007e
Merge branch 'dev' into dev_kinect
manuelgitgomes Sep 26, 2021
bfdf91c
Merge pull request #49 from AutomecUA/dev_kinect
manuelgitgomes Sep 26, 2021
a8d0e70
Changed bool_cmd_topic and bool_vel_topic arguments to vel_cmd_topic …
Sep 27, 2021
07f35e1
Created a new publisher on AndroidConversor.py which converts the "pr…
Sep 27, 2021
27cb186
changed camera id 0 -> 2
brunomonteiro98 Sep 28, 2021
feccd51
Merge pull request #43 from AutomecUA/btn_switch
brunomonteiro98 Sep 28, 2021
c7b6f9b
Merge pull request #54 from AutomecUA/dev
brunomonteiro98 Sep 28, 2021
b218cc3
added new version of switch topics to launch files
brunomonteiro98 Sep 28, 2021
720daa5
Updated launch files to record only when \android_input_vel is on
Sep 29, 2021
64d3a01
fix error dividing by 0 in train2a_transfer_learning.py
DanielCoelho112 Sep 30, 2021
ab7a7d8
issue 64, add checkerboard to gazebo
inaciose Sep 30, 2021
cf509e4
issue 63, change wheel color to darkgray on gazebo
inaciose Sep 30, 2021
abf1fc3
added driving launch with cnn2 + kinectic
brunomonteiro98 Oct 1, 2021
ada7e16
Merge pull request #62 from AutomecUA/cnn_tf
manuelgitgomes Oct 2, 2021
9c33e2a
Merge pull request #65 from AutomecUA/new/gazebo_misc
manuelgitgomes Oct 2, 2021
9755111
Changed name of launch and removed extra csv
Oct 2, 2021
173a8b3
Merge pull request #72 from AutomecUA/22_09
brunomonteiro98 Oct 6, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ venv/
ENV/
env.bak/
venv.bak/
automec_env/

# Spyder project settings
.spyderproject
Expand All @@ -132,8 +133,9 @@ dmypy.json
.vscode


# images
*.jpg
# databases and models
cnn/data/**
cnn/models/**

# csv
*.csv
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,9 @@ And add the previous line to the end of your file. Same procedure if you use zsh
To Save press Cntrl+O , Enter . Cntrl+X to exit

# Ackerman dependencies
sudo apt install ros-noetic-ros-controllers
sudo apt-get install ros-noetic-ackermann-msgs
sudo apt-get install ros-noetic-ros-controllers ros-noetic-ackermann-msgs

# Launch woth ackerman
# Launch with ackerman
roslaunch ackermann_vehicle_gazebo ackermann_robot_with_arena_conversion.launch

# Running the simulation enviroment
Expand Down
4 changes: 4 additions & 0 deletions cnn/launch/training1.launch
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<arg name="batch_size" default="32"/>
<arg name="folder" default="set1"/>
<arg name="model" default="model1.h5"/>
<arg name="width" default="320"/>
<arg name="height" default="160"/>

<!--
<arg name="folder" default=""/>
Expand All @@ -17,6 +19,8 @@
<param name="base_folder" value="$(arg folder)"/>
<param name="modelname" value="$(arg model)"/>
<param name="batch_size" value="$(arg batch_size)"/>
<param name="width" value="$(arg width)"/>
<param name="height" value="$(arg height)"/>
</node>
<!--</group>-->

Expand Down
11 changes: 11 additions & 0 deletions cnn/launch/write.launch
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,29 @@

<arg name="image_raw_topic" default="/ackermann_vehicle/camera/rgb/image_raw"/>
<arg name="twist_cmd_topic" default="/cmd_vel"/>
<arg name="vel_cmd_topic" default=""/>
<arg name="folder" default="set1"/>
<arg name="rate" default="30"/>
<arg name="width" default="320"/>
<arg name="height" default="160"/>
<!-- only for yaml file -->
<arg name="cam_height" default=""/>
<arg name="cam_angle" default=""/>
<arg name="env" default=""/>
<arg name="vel" default="0"/>

<node name="cnn_write" pkg="cnn" type="write.py" output="screen" required="true">
<param name="image_raw_topic" value="$(arg image_raw_topic)"/>
<param name="twist_cmd_topic" value="$(arg twist_cmd_topic)"/>
<param name="vel_cmd_topic" value="$(arg vel_cmd_topic)"/>
<param name="folder" value="$(arg folder)"/>
<param name="rate" value="$(arg rate)"/>
<param name="width" value="$(arg width)"/>
<param name="height" value="$(arg height)"/>
<param name="cam_height" value="$(arg cam_height)"/>
<param name="cam_angle" value="$(arg cam_angle)"/>
<param name="env" value="$(arg env)"/>
<param name="vel" value="$(arg vel)"/>
</node>

</launch>
Binary file removed cnn/models/cnn1_14_08.h5
Binary file not shown.
11 changes: 0 additions & 11 deletions cnn/models/cnn1_14_08.yml

This file was deleted.

Binary file removed cnn/models/cnn2a_14_08_normal.h5
Binary file not shown.
10 changes: 0 additions & 10 deletions cnn/models/cnn2a_14_08_normal.yml

This file was deleted.

Binary file removed cnn/models/cnn2a_tf_14_08_tf2.h5
Binary file not shown.
10 changes: 0 additions & 10 deletions cnn/models/cnn2a_tf_14_08_tf2.yml

This file was deleted.

103 changes: 100 additions & 3 deletions cnn/scripts/cnn1/training1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import rospy
from tensorflow.keras.models import load_model

import yaml
import sys

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'

def main():
Expand All @@ -24,6 +27,11 @@ def main():
batch_yval = rospy.get_param('~batch_yval', 0)
validation_steps = rospy.get_param('~validation_steps', 50)

image_width = rospy.get_param('~width', 320)
image_height = rospy.get_param('~height', 160)
# params only used in yaml file
#env = rospy.get_param('~env', 'gazebo')

print('base_folder: ', base_folder)
print('modelname: ', modelname)
print('epochs: ', epochs)
Expand All @@ -44,6 +52,41 @@ def main():
#print('\ndata load from ' + base_folder)
rospy.loginfo('Train with data load from:\n %s', base_folder)

# yaml
if not os.path.isfile(path_data + '/info.yaml'):
have_dataset_yaml = False
# we may allow to continue processing with default data
print("no yaml info file found. exit.")
sys.exit()
else:
have_dataset_yaml = True

# dataset yaml defaults
ds_cam_angle = ''
ds_cam_height = ''
ds_developer = ''
ds_environment = ''
ds_frequency = 0
ds_image_size = ''
ds_linear_velocity = 0

if have_dataset_yaml:
with open(path_data + '/info.yaml') as file:
# The FullLoader parameter handles the conversion from YAML
# scalar values to Python the dictionary format
info_loaded = yaml.load(file, Loader=yaml.FullLoader)

ds_cam_angle = info_loaded['dataset']['cam_angle']
ds_cam_height = info_loaded['dataset']['cam_height']
ds_developer = info_loaded['dataset']['developer']
ds_environment = info_loaded['dataset']['environment']
ds_frequency = info_loaded['dataset']['frequency']
ds_image_size = info_loaded['dataset']['image_size']
ds_linear_velocity = info_loaded['dataset']['linear_velocity']


#sys.exit()

# Step 2 - Vizualize and Balance data
balanceData(data, display=True)

Expand All @@ -69,24 +112,78 @@ def main():

print("\n" + "Create a new model from scratch? [Y/N]")
if input().lower() == "y":
model = createModel()
model = createModel(image_width, image_height)
is_newmodel = True
else:
print('\n Model load from ' + modelname)
model = load_model(path)
is_newmodel = False


# yaml
if is_newmodel:
imgsize_list = [image_width, image_height]
string_ints = [str(int) for int in imgsize_list]
imgsize_str = ",".join(string_ints)
# dataset yaml defaults
model_developer = os.getenv('automec_developer')
model_image_size = imgsize_str
model_frequency = ds_frequency
model_linear_velocity = ds_linear_velocity
model_environment = ds_environment
model_cam_angle = ds_cam_angle
model_cam_height = ds_cam_height
model_cnn_number = '1'
else:
with open(path + '_info.yaml') as file:
# The FullLoader parameter handles the conversion from YAML
# scalar values to Python the dictionary format
info_loaded = yaml.load(file, Loader=yaml.FullLoader)

model_developer = info_loaded['model']['developer']
model_image_size = info_loaded['model']['image_size']
model_frequency = info_loaded['model']['frequency']
model_linear_velocity = info_loaded['model']['linear_velocity']
model_environment = info_loaded['model']['environment']
model_cam_angle = info_loaded['model']['cam_angle']
model_cam_height = info_loaded['model']['cam_height']
model_cnn_number = info_loaded['model']['cnn_number']


model.summary()

# Step 9 -Training
history = model.fit(batchGen(xTrain, yTrain, batch_xtrain, batch_ytrain), steps_per_epoch=steps_per_epoch, epochs=epochs,
validation_data=batchGen(xVal, yVal, batch_xval, batch_yval), validation_steps=validation_steps)
history = model.fit(batchGen(xTrain, yTrain, batch_xtrain, batch_ytrain, image_width, image_height), steps_per_epoch=steps_per_epoch, epochs=epochs,
validation_data=batchGen(xVal, yVal, batch_xval, batch_yval, image_width, image_height), validation_steps=validation_steps)

# Step 10 - Saving and plotting
#model.save('models_files/' + modelname)
model.save(path)

print('\n Model Saved to ' + path)
print('\n Model Saved to ' + modelname)
rospy.loginfo('Model Saved to: %s', path)

# yaml
info_data = dict(

model = dict(
developer = os.getenv('automec_developer'),
image_size = model_image_size,
frequency = model_frequency,
linear_velocity = model_linear_velocity,
environment = model_environment,
cam_height = model_cam_height,
cam_angle = model_cam_angle,
cnn_number = model_cnn_number
)
)

with open(path + '_info.yaml', 'w') as outfile:
yaml.dump(info_data, outfile, default_flow_style=False)

rospy.loginfo('yaml Saved')

plt.plot(history.history['loss'])
plt.plot(history.history['val_loss'])
plt.legend(['Training', 'Validation'])
Expand Down
12 changes: 6 additions & 6 deletions cnn/scripts/cnn1/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ def augmentImage(imgPath, steering):
return img, steering


def preProcessing(img):
def preProcessing(img, imgwidth, imgheight):
# Cropping Region of intrest, Ajust with Gazebo and use Andre Code in the Future
# img = img[60:135, :, :]
img = cv2.cvtColor(img, cv2.COLOR_RGB2YUV) # For better jornalization
img = cv2.GaussianBlur(img, (3, 3), 0)
img = cv2.resize(img, (320, 160)) # NIVIDA uses 200x66
img = cv2.resize(img, (imgwidth, imgheight)) # NIVIDA uses 200x66
img = img/255

return img
Expand All @@ -139,7 +139,7 @@ def preProcessing(img):
# plt.show()


def batchGen(imagesPath, steeringList, batchSize, trainFlag):
def batchGen(imagesPath, steeringList, batchSize, trainFlag, imgwidth, imgheight):
# Creates a batch and applies augmentation
while True:
imgBatch = []
Expand All @@ -154,18 +154,18 @@ def batchGen(imagesPath, steeringList, batchSize, trainFlag):
else:
img = mpimg.imread(imagesPath[index])
steering = steeringList[index]
img = preProcessing(img)
img = preProcessing(img, imgwidth, imgheight)

imgBatch.append(img)
steeringBatch.append(steering)

yield(np.asarray(imgBatch), np.asarray(steeringBatch))


def createModel():
def createModel(imgwidth, imgheight):
model = Sequential()
model.add(Convolution2D(24, (5, 5), (2, 2),
input_shape=(160, 320, 3), activation='elu'))
input_shape=(imgheight, imgwidth, 3), activation='elu'))
model.add(Convolution2D(36, (5, 5), (2, 2), activation='elu'))
model.add(Convolution2D(48, (5, 5), (2, 2), activation='elu'))
model.add(Convolution2D(64, (3, 3), activation='elu'))
Expand Down
19 changes: 16 additions & 3 deletions cnn/scripts/cnn2/train2a_transfer_learning.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def main():

# Change image and store the same angle, with some distortion, both in image and in angle (to increase robustness)
# flipped
center_image_temp = np.expand_dims(cv2.flip(center_image, 1), axis=2)
#center_image_temp = np.expand_dims(cv2.flip(center_image, 1), axis=2)

# images.append(center_image_temp)
# angles.append(-float(line[1]))
Expand All @@ -118,8 +118,21 @@ def main():
csvfile.close()


left_to_straight_ratio = total_straight_angles/total_left_angles
right_to_straight_ratio = total_straight_angles/total_right_angles
if total_left_angles == 0:
left_to_straight_ratio = None
else:
left_to_straight_ratio = total_straight_angles/total_left_angles

if total_right_angles == 0:
right_to_straight_ratio = None
else:
right_to_straight_ratio = total_straight_angles/total_right_angles







#print('angles are: ' + str(list(angles)))

Expand Down
Loading