Skip to content

Commit

Permalink
Merge pull request #89 from AutomecUA/dev
Browse files Browse the repository at this point in the history
Release 0.2.0
  • Loading branch information
manuelgitgomes authored Oct 19, 2021
2 parents 1d9cf86 + 08fd779 commit 657e8d9
Show file tree
Hide file tree
Showing 150 changed files with 5,041 additions and 273 deletions.
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: 2 additions & 2 deletions cnn/launch/driving1.launch
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<arg name="image_raw_topic" default="/ackermann_vehicle/camera/rgb/image_raw" />
<arg name="twist_cmd_topic" default="/cmd_vel" />
<arg name="twist_linear_x" default="1" />
<arg name="signal_cmd_topic" default=""/>
<arg name="vel_cmd_topic" default="" /> <!-- /android_input_vel -->
<arg name="float_cmd_topic" default="" /> <!-- /flt_cmd -->
<arg name="model" default=""/>

<group if="$(eval arg('model') != '')">
Expand All @@ -13,7 +13,7 @@
<param name="twist_cmd_topic" value="$(arg twist_cmd_topic)" />
<param name="twist_linear_x" value="$(arg twist_linear_x)" />
<param name="vel_cmd_topic" value="$(arg vel_cmd_topic)" />
<param name="float_cmd_topic" value="$(arg float_cmd_topic)" />
<param name="signal_cmd_topic" value="$(arg signal_cmd_topic)"/>
<param name="modelname" value="$(arg model)" />
</node>
</group>
Expand Down
9 changes: 4 additions & 5 deletions cnn/launch/driving2a.launch
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
<arg name="image_raw_topic" default="/ackermann_vehicle/camera/rgb/image_raw" />
<arg name="twist_cmd_topic" default="/cmd_vel" />
<arg name="twist_linear_x" default="1" />
<arg name="float_cmd_topic" default="" /> <!-- /flt_cmd -->
<arg name="signal_cmd_topic" default=""/>
<arg name="vel_cmd_topic" default="" />
<arg name="model" default=""/>
<arg name="vel_cmd_topic" default="android_input_vel" />


<group if="$(eval arg('model') != '')">
<node name="driving" pkg="cnn" type="drive2a.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="twist_linear_x" value="$(arg twist_linear_x)" />
<param name="float_cmd_topic" value="$(arg float_cmd_topic)" />
<param name="modelname" value="$(arg model)" />
<param name="vel_cmd_topic" value="$(arg vel_cmd_topic)" />
<param name="signal_cmd_topic" value="$(arg signal_cmd_topic)"/>
<param name="modelname" value="$(arg model)" />
</node>
</group>

Expand Down
5 changes: 5 additions & 0 deletions cnn/launch/training1.launch
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<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 +20,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.

68 changes: 43 additions & 25 deletions cnn/scripts/cnn1/driving1.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
global begin_img

def preProcess(img):
# Define Region of intrest- Perguntar ao Daniel se corto ou não , problema do angulo da camera
# Define Region of interest
#img = img[60:135, :, :]
img = cv2.cvtColor(img, cv2.COLOR_RGB2YUV)
img = cv2.GaussianBlur(img, (3, 3), 0)
Expand All @@ -40,33 +40,48 @@ def message_RGB_ReceivedCallback(message):

begin_img = True

def signal_Callback(message):
global vel

vel = message.data
def signalCallback(message):
global vel
global velbool
global twist_linear_x

# If we receive a positive message from the signal topic, we should go. If not, we should stop.
if message.data:
vel = twist_linear_x
velbool = True
else:
vel = 0
velbool = False


def main():

# Global variables
global vel
global vel, velbool
global img_rbg
global bridge
global begin_img
begin_img = False
global twist_linear_x

# Defining starting values
begin_img = False
vel = 0
velbool = False
twist = Twist()

# Init Node
rospy.init_node('driving', anonymous=False)

image_raw_topic = rospy.get_param('~image_raw_topic', '/ackermann_vehicle/camera/rgb/image_raw')
twist_cmd_topic = rospy.get_param('~twist_cmd_topic', '/cmd_vel')
vel_cmd_topic = rospy.get_param('~vel_cmd_topic', '')
# Getting parameters
image_raw_topic = rospy.get_param('~image_raw_topic', '/ackermann_vehicle/camera/rgb/image_raw')
twist_cmd_topic = rospy.get_param('~twist_cmd_topic', '')
vel_cmd_topic = rospy.get_param('~vel_cmd_topic', '')
twist_linear_x = rospy.get_param('~twist_linear_x', 1)
float_cmd_topic = rospy.get_param('~float_cmd_topic', '')
signal_cmd_topic = rospy.get_param('~signal_cmd_topic', '')
modelname = rospy.get_param('~modelname', 'model1.h5')

# Defining path to model
s = str(pathlib.Path(__file__).parent.absolute())
path = s + '/../../models/cnn1_' + modelname

Expand All @@ -75,25 +90,27 @@ def main():

# Subscribe and publish topics
rospy.Subscriber(image_raw_topic, Image, message_RGB_ReceivedCallback)

# does we need to check float_cmd_topic ?
if float_cmd_topic != '':
vel = 0
rospy.Subscriber(float_cmd_topic, Float32, signal_Callback)

vel = twist_linear_x

pub = rospy.Publisher(twist_cmd_topic, Twist, queue_size=10)
# If there is the signal topic, it should subscribe to it and act accordingly.
# If not, the velocity should be max.
if signal_cmd_topic == '':
vel = twist_linear_x
velbool = True
else:
rospy.Subscriber(signal_cmd_topic, Bool, signalCallback)

# Differentiation between gazebo and real car
if twist_cmd_topic != '':
pub = rospy.Publisher(twist_cmd_topic, Twist, queue_size=10)

# does we need to publish vel_cmd_topic ?
if vel_cmd_topic != '':
pub_velocity = rospy.Publisher(vel_cmd_topic, Bool, queue_size=10)
print('Boolean is on')


# Create an object of the CvBridge class
bridge = CvBridge()

#Frames per second
#Frames per second
rate = rospy.Rate(30)

while not rospy.is_shutdown():
Expand All @@ -114,17 +131,18 @@ def main():

# Send twist
twist.linear.x = vel
#twist.linear.x = 1
twist.linear.y = 0
twist.linear.z = 0
twist.angular.x = 0
twist.angular.y = 0
twist.angular.z = angle

pub.publish(twist)
# To avoid any errors
if twist_cmd_topic != '':
pub.publish(twist)

if vel_cmd_topic != '':
pub_velocity.publish(True)
pub_velocity.publish(velbool)

rate.sleep()

Expand Down
Loading

0 comments on commit 657e8d9

Please sign in to comment.