├── .gitignore
├── CMakeLists.txt
├── launch
└── gazebo.launch
├── package.xml
├── rviz
└── urdf.rviz
├── scripts
├── Navigator.py
└── Shape Classifier.py
├── urdf
└── mybot.xacro
└── worlds
└── world.world
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | devel/
3 | logs/
4 | build/
5 | bin/
6 | lib/
7 | msg_gen/
8 | srv_gen/
9 | msg/*Action.msg
10 | msg/*ActionFeedback.msg
11 | msg/*ActionGoal.msg
12 | msg/*ActionResult.msg
13 | msg/*Feedback.msg
14 | msg/*Goal.msg
15 | msg/*Result.msg
16 | msg/_*.py
17 | build_isolated/
18 | devel_isolated/
19 |
20 | # Generated by dynamic reconfigure
21 | *.cfgc
22 | /cfg/cpp/
23 | /cfg/*.py
24 |
25 | # Ignore generated docs
26 | *.dox
27 | *.wikidoc
28 |
29 | # eclipse stuff
30 | .project
31 | .cproject
32 |
33 | # qcreator stuff
34 | CMakeLists.txt.user
35 |
36 | srv/_*.py
37 | *.pcd
38 | *.pyc
39 | qtcreator-*
40 | *.user
41 |
42 | /planning/cfg
43 | /planning/docs
44 | /planning/src
45 |
46 | *~
47 |
48 | # Emacs
49 | .#*
50 |
51 | # Catkin custom files
52 | CATKIN_IGNOREs
53 |
54 | # Model
55 | *.h5
56 |
57 | # Images
58 | *.jpg
59 | *.jpeg
60 | *.png
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.3)
2 | project(autonomous_navigation)
3 |
4 | ## Compile as C++11, supported in ROS Kinetic and newer
5 | # add_compile_options(-std=c++11)
6 |
7 | ## Find catkin macros and libraries
8 | ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
9 | ## is used, also find other catkin packages
10 | find_package(catkin REQUIRED COMPONENTS
11 | rospy
12 | std_msgs
13 | )
14 |
15 | ## System dependencies are found with CMake's conventions
16 | # find_package(Boost REQUIRED COMPONENTS system)
17 |
18 |
19 | ## Uncomment this if the package has a setup.py. This macro ensures
20 | ## modules and global scripts declared therein get installed
21 | ## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
22 | # catkin_python_setup()
23 |
24 | ################################################
25 | ## Declare ROS messages, services and actions ##
26 | ################################################
27 |
28 | ## To declare and build messages, services or actions from within this
29 | ## package, follow these steps:
30 | ## * Let MSG_DEP_SET be the set of packages whose message types you use in
31 | ## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
32 | ## * In the file package.xml:
33 | ## * add a build_depend tag for "message_generation"
34 | ## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
35 | ## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
36 | ## but can be declared for certainty nonetheless:
37 | ## * add a exec_depend tag for "message_runtime"
38 | ## * In this file (CMakeLists.txt):
39 | ## * add "message_generation" and every package in MSG_DEP_SET to
40 | ## find_package(catkin REQUIRED COMPONENTS ...)
41 | ## * add "message_runtime" and every package in MSG_DEP_SET to
42 | ## catkin_package(CATKIN_DEPENDS ...)
43 | ## * uncomment the add_*_files sections below as needed
44 | ## and list every .msg/.srv/.action file to be processed
45 | ## * uncomment the generate_messages entry below
46 | ## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
47 |
48 | ## Generate messages in the 'msg' folder
49 | # add_message_files(
50 | # FILES
51 | # Message1.msg
52 | # Message2.msg
53 | # )
54 |
55 | ## Generate services in the 'srv' folder
56 | # add_service_files(
57 | # FILES
58 | # Service1.srv
59 | # Service2.srv
60 | # )
61 |
62 | ## Generate actions in the 'action' folder
63 | # add_action_files(
64 | # FILES
65 | # Action1.action
66 | # Action2.action
67 | # )
68 |
69 | ## Generate added messages and services with any dependencies listed here
70 | # generate_messages(
71 | # DEPENDENCIES
72 | # std_msgs
73 | # )
74 |
75 | ################################################
76 | ## Declare ROS dynamic reconfigure parameters ##
77 | ################################################
78 |
79 | ## To declare and build dynamic reconfigure parameters within this
80 | ## package, follow these steps:
81 | ## * In the file package.xml:
82 | ## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
83 | ## * In this file (CMakeLists.txt):
84 | ## * add "dynamic_reconfigure" to
85 | ## find_package(catkin REQUIRED COMPONENTS ...)
86 | ## * uncomment the "generate_dynamic_reconfigure_options" section below
87 | ## and list every .cfg file to be processed
88 |
89 | ## Generate dynamic reconfigure parameters in the 'cfg' folder
90 | # generate_dynamic_reconfigure_options(
91 | # cfg/DynReconf1.cfg
92 | # cfg/DynReconf2.cfg
93 | # )
94 |
95 | ###################################
96 | ## catkin specific configuration ##
97 | ###################################
98 | ## The catkin_package macro generates cmake config files for your package
99 | ## Declare things to be passed to dependent projects
100 | ## INCLUDE_DIRS: uncomment this if your package contains header files
101 | ## LIBRARIES: libraries you create in this project that dependent projects also need
102 | ## CATKIN_DEPENDS: catkin_packages dependent projects also need
103 | ## DEPENDS: system dependencies of this project that dependent projects also need
104 | catkin_package(
105 | # INCLUDE_DIRS include
106 | # LIBRARIES autonomous_navigation
107 | # CATKIN_DEPENDS rospy std_msgs
108 | # DEPENDS system_lib
109 | )
110 |
111 | ###########
112 | ## Build ##
113 | ###########
114 |
115 | ## Specify additional locations of header files
116 | ## Your package locations should be listed before other locations
117 | include_directories(
118 | # include
119 | ${catkin_INCLUDE_DIRS}
120 | )
121 |
122 | ## Declare a C++ library
123 | # add_library(${PROJECT_NAME}
124 | # src/${PROJECT_NAME}/autonomous_navigation.cpp
125 | # )
126 |
127 | ## Add cmake target dependencies of the library
128 | ## as an example, code may need to be generated before libraries
129 | ## either from message generation or dynamic reconfigure
130 | # add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
131 |
132 | ## Declare a C++ executable
133 | ## With catkin_make all packages are built within a single CMake context
134 | ## The recommended prefix ensures that target names across packages don't collide
135 | # add_executable(${PROJECT_NAME}_node src/autonomous_navigation_node.cpp)
136 |
137 | ## Rename C++ executable without prefix
138 | ## The above recommended prefix causes long target names, the following renames the
139 | ## target back to the shorter version for ease of user use
140 | ## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
141 | # set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
142 |
143 | ## Add cmake target dependencies of the executable
144 | ## same as for the library above
145 | # add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
146 |
147 | ## Specify libraries to link a library or executable target against
148 | # target_link_libraries(${PROJECT_NAME}_node
149 | # ${catkin_LIBRARIES}
150 | # )
151 |
152 | #############
153 | ## Install ##
154 | #############
155 |
156 | # all install targets should use catkin DESTINATION variables
157 | # See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
158 |
159 | ## Mark executable scripts (Python etc.) for installation
160 | ## in contrast to setup.py, you can choose the destination
161 | # install(PROGRAMS
162 | # scripts/my_python_script
163 | # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
164 | # )
165 |
166 | ## Mark executables and/or libraries for installation
167 | # install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_node
168 | # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
169 | # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
170 | # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
171 | # )
172 |
173 | ## Mark cpp header files for installation
174 | # install(DIRECTORY include/${PROJECT_NAME}/
175 | # DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
176 | # FILES_MATCHING PATTERN "*.h"
177 | # PATTERN ".svn" EXCLUDE
178 | # )
179 |
180 | ## Mark other files for installation (e.g. launch and bag files, etc.)
181 | # install(FILES
182 | # # myfile1
183 | # # myfile2
184 | # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
185 | # )
186 |
187 | #############
188 | ## Testing ##
189 | #############
190 |
191 | ## Add gtest based cpp test target and link libraries
192 | # catkin_add_gtest(${PROJECT_NAME}-test test/test_autonomous_navigation.cpp)
193 | # if(TARGET ${PROJECT_NAME}-test)
194 | # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
195 | # endif()
196 |
197 | ## Add folders to be run by python nosetests
198 | # catkin_add_nosetests(test)
199 |
--------------------------------------------------------------------------------
/launch/gazebo.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | autonomous_navigation
4 | 0.0.0
5 | The autonomous_navigation package
6 |
7 |
8 |
9 |
10 | ros2018
11 |
12 |
13 |
14 |
15 |
16 | TODO
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | catkin
52 | rospy
53 | std_msgs
54 | rospy
55 | std_msgs
56 | rospy
57 | std_msgs
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/rviz/urdf.rviz:
--------------------------------------------------------------------------------
1 | Panels:
2 | - Class: rviz/Displays
3 | Help Height: 78
4 | Name: Displays
5 | Property Tree Widget:
6 | Expanded:
7 | - /Global Options1
8 | - /Status1
9 | - /RobotModel1
10 | - /TF1
11 | Splitter Ratio: 0.5
12 | Tree Height: 557
13 | - Class: rviz/Selection
14 | Name: Selection
15 | - Class: rviz/Tool Properties
16 | Expanded:
17 | - /2D Pose Estimate1
18 | - /2D Nav Goal1
19 | - /Publish Point1
20 | Name: Tool Properties
21 | Splitter Ratio: 0.588679
22 | - Class: rviz/Views
23 | Expanded:
24 | - /Current View1
25 | Name: Views
26 | Splitter Ratio: 0.5
27 | - Class: rviz/Time
28 | Experimental: false
29 | Name: Time
30 | SyncMode: 0
31 | SyncSource: ""
32 | Visualization Manager:
33 | Class: ""
34 | Displays:
35 | - Alpha: 0.5
36 | Cell Size: 1
37 | Class: rviz/Grid
38 | Color: 160; 160; 164
39 | Enabled: true
40 | Line Style:
41 | Line Width: 0.03
42 | Value: Lines
43 | Name: Grid
44 | Normal Cell Count: 0
45 | Offset:
46 | X: 0
47 | Y: 0
48 | Z: 0
49 | Plane: XY
50 | Plane Cell Count: 10
51 | Reference Frame:
52 | Value: true
53 | - Alpha: 0.5
54 | Class: rviz/RobotModel
55 | Collision Enabled: false
56 | Enabled: true
57 | Links:
58 | All Links Enabled: true
59 | Expand Joint Details: false
60 | Expand Link Details: false
61 | Expand Tree: false
62 | Link Tree Style: Links in Alphabetic Order
63 | base_link:
64 | Alpha: 1
65 | Show Axes: false
66 | Show Trail: false
67 | Value: true
68 | right_leg:
69 | Alpha: 1
70 | Show Axes: false
71 | Show Trail: false
72 | Value: true
73 | Name: RobotModel
74 | Robot Description: robot_description
75 | TF Prefix: ""
76 | Update Interval: 0
77 | Value: true
78 | Visual Enabled: true
79 | - Class: rviz/TF
80 | Enabled: true
81 | Frame Timeout: 15
82 | Frames:
83 | All Enabled: true
84 | base_link:
85 | Value: true
86 | right_leg:
87 | Value: true
88 | Marker Scale: 0.5
89 | Name: TF
90 | Show Arrows: true
91 | Show Axes: true
92 | Show Names: true
93 | Tree:
94 | base_link:
95 | right_leg:
96 | {}
97 | Update Interval: 0
98 | Value: true
99 | Enabled: true
100 | Global Options:
101 | Background Color: 48; 48; 48
102 | Fixed Frame: base_link
103 | Frame Rate: 30
104 | Name: root
105 | Tools:
106 | - Class: rviz/Interact
107 | Hide Inactive Objects: true
108 | - Class: rviz/MoveCamera
109 | - Class: rviz/Select
110 | - Class: rviz/FocusCamera
111 | - Class: rviz/Measure
112 | - Class: rviz/SetInitialPose
113 | Topic: /initialpose
114 | - Class: rviz/SetGoal
115 | Topic: /move_base_simple/goal
116 | - Class: rviz/PublishPoint
117 | Single click: true
118 | Topic: /clicked_point
119 | Value: true
120 | Views:
121 | Current:
122 | Class: rviz/Orbit
123 | Distance: 4.48689
124 | Enable Stereo Rendering:
125 | Stereo Eye Separation: 0.06
126 | Stereo Focal Distance: 1
127 | Swap Stereo Eyes: false
128 | Value: false
129 | Focal Point:
130 | X: 0
131 | Y: 0
132 | Z: 0
133 | Name: Current View
134 | Near Clip Distance: 0.01
135 | Pitch: 0.695397
136 | Target Frame:
137 | Value: Orbit (rviz)
138 | Yaw: 0.513582
139 | Saved: ~
140 | Window Geometry:
141 | Displays:
142 | collapsed: false
143 | Height: 882
144 | Hide Left Dock: false
145 | Hide Right Dock: false
146 | QMainWindow State: 000000ff00000000fd00000004000000000000013c000002c3fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000006400fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c0061007900730100000043000002c3000000de00fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000002c3fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a005600690065007700730100000043000002c3000000b800fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004c000000044fc0100000002fb0000000800540069006d00650100000000000004c00000025800fffffffb0000000800540069006d0065010000000000000450000000000000000000000269000002c300000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
147 | Selection:
148 | collapsed: false
149 | Time:
150 | collapsed: false
151 | Tool Properties:
152 | collapsed: false
153 | Views:
154 | collapsed: false
155 | Width: 1216
156 | X: 17
157 | Y: 28
--------------------------------------------------------------------------------
/scripts/Navigator.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os
3 | import cv2
4 | import rospy
5 | import numpy as np
6 | import tensorflow as tf
7 | from std_msgs.msg import String
8 | from std_msgs.msg import Float32
9 | from sensor_msgs.msg import Image
10 | from geometry_msgs.msg import Twist
11 | from keras.models import load_model
12 | from cv_bridge import CvBridge, CvBridgeError
13 |
14 | SPEED = 2.5
15 |
16 | DISTANCE = 2
17 | LEFT_ANGLE = 30
18 | RIGHT_ANGLE = 30
19 |
20 | TURNING_SPEED = 15
21 | PI = 3.1415926535897
22 | classes = ['Box', 'Space', 'Sphere']
23 | IMAGE_WIDTH, IMAGE_HEIGHT = 200, 200
24 |
25 | bridge = CvBridge()
26 | model = load_model(os.path.join(os.path.dirname(__file__), "shape_classifier_le_net_5.h5"))
27 | graph = tf.get_default_graph()
28 |
29 | def image_cb(data):
30 | cv_image = bridge.imgmsg_to_cv2(data, desired_encoding="passthrough")
31 | cv_image = cv2.cvtColor(cv_image, cv2.COLOR_BGR2RGB)
32 |
33 | image = preprocess_image(cv_image)
34 |
35 | global graph
36 | with graph.as_default():
37 | prediction = classes[np.squeeze(np.argmax(model.predict(image), axis=1))]
38 | move(prediction)
39 |
40 | def preprocess_image(image):
41 | resized_image = cv2.resize(image, (IMAGE_WIDTH, IMAGE_HEIGHT))
42 | return np.resize(resized_image, (1, IMAGE_WIDTH, IMAGE_WIDTH, 3))
43 |
44 | def move(prediction):
45 | print("[*] " + str(prediction) + " Detected.")
46 | velocity_publisher = rospy.Publisher("/cmd_vel", Twist, queue_size=10)
47 |
48 | if prediction == classes[1]:
49 | print("[*] Moving Straight...")
50 | move_straight(velocity_publisher)
51 |
52 | elif prediction == classes[0]:
53 | print("[*] Stop...")
54 | stop(velocity_publisher)
55 |
56 | elif prediction == classes[2]:
57 | print("[*] Turning Right...")
58 | turn_right(velocity_publisher)
59 |
60 | def move_straight(velocity_publisher):
61 | vel_msg = Twist()
62 | vel_msg.linear.x = abs(0.5)
63 | vel_msg.linear.y = 0
64 | vel_msg.linear.z = 0
65 | vel_msg.angular.x = 0
66 | vel_msg.angular.y = 0
67 | vel_msg.angular.z = 0
68 |
69 | current_distance = 0
70 | t0 = rospy.Time.now().to_sec()
71 |
72 | while (current_distance < DISTANCE):
73 | velocity_publisher.publish(vel_msg)
74 |
75 | t1 = rospy.Time.now().to_sec()
76 | current_distance = SPEED * (t1 - t0)
77 | vel_msg.linear.x = 0
78 | velocity_publisher.publish(vel_msg)
79 |
80 | def turn_right(velocity_publisher):
81 | angular_speed = TURNING_SPEED * 2 * PI / 360
82 | relative_angle = RIGHT_ANGLE* 2 * PI / 360
83 |
84 | vel_msg = Twist()
85 | vel_msg.linear.x = 0
86 | vel_msg.linear.y = 0
87 | vel_msg.linear.z = 0
88 | vel_msg.angular.x = 0
89 | vel_msg.angular.y = 0
90 |
91 | vel_msg.angular.z = -abs(angular_speed)
92 |
93 | current_angle = 0
94 | t0 = rospy.Time.now().to_sec()
95 |
96 | while (current_angle < relative_angle):
97 | velocity_publisher.publish(vel_msg)
98 |
99 | t1 = rospy.Time.now().to_sec()
100 | current_angle = angular_speed * (t1 - t0)
101 |
102 | vel_msg.linear.z = 0
103 | velocity_publisher.publish(vel_msg)
104 |
105 | def turn_left(velocity_publisher):
106 | angular_speed = TURNING_SPEED * 2 * PI / 360
107 | relative_angle = RIGHT_ANGLE* 2 * PI / 360
108 |
109 | vel_msg = Twist()
110 | vel_msg.linear.x = 0
111 | vel_msg.linear.y = 0
112 | vel_msg.linear.z = 0
113 | vel_msg.angular.x = 0
114 | vel_msg.angular.y = 0
115 |
116 | vel_msg.angular.z = abs(angular_speed)
117 |
118 | current_angle = 0
119 | t0 = rospy.Time.now().to_sec()
120 |
121 | while (current_angle < relative_angle):
122 | velocity_publisher.publish(vel_msg)
123 |
124 | t1 = rospy.Time.now().to_sec()
125 | current_angle = angular_speed * (t1 - t0)
126 |
127 | vel_msg.linear.z = 0
128 | velocity_publisher.publish(vel_msg)
129 |
130 | def stop(velocity_publisher):
131 | vel_msg = Twist()
132 | vel_msg.linear.x = 0
133 | vel_msg.linear.y = 0
134 | vel_msg.linear.z = 0
135 | vel_msg.angular.x = 0
136 | vel_msg.angular.y = 0
137 | vel_msg.angular.z = 0
138 |
139 | velocity_publisher.publish(vel_msg)
140 |
141 | def main():
142 | rospy.init_node('navigator', anonymous=True)
143 | image_subscriber = rospy.Subscriber("/mybot/camera/image_raw", Image, image_cb, queue_size=1, buff_size=2**24)
144 | try:
145 | rospy.spin()
146 | except KeyboardInterrupt as e:
147 | print "Shutting Down"
148 | cv2.destroyAllWindows()
149 |
150 | if __name__=='__main__':
151 | main()
152 |
--------------------------------------------------------------------------------
/scripts/Shape Classifier.py:
--------------------------------------------------------------------------------
1 | from keras.optimizers import Adam
2 | from keras.models import Sequential
3 | from keras.preprocessing.image import ImageDataGenerator
4 | from keras.layers import Conv2D, MaxPooling2D, Flatten, Dense, Activation
5 |
6 | # Constants
7 | NUMBER_OF_CLASSES = 3
8 | IMAGE_WIDTH, IMAGE_HEIGHT = 200, 200
9 |
10 | # Build Model
11 | model = Sequential()
12 | model.add(Conv2D(32, kernel_size=(5, 5), padding="same", input_shape=(IMAGE_WIDTH, IMAGE_HEIGHT, 3)))
13 | model.add(Activation("relu"))
14 | model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2)))
15 | model.add(Conv2D(64, kernel_size=(5, 5), padding="same"))
16 | model.add(Activation("relu"))
17 | model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2)))
18 |
19 | model.add(Flatten())
20 | model.add(Dense(128))
21 | model.add(Activation("relu"))
22 | model.add(Dense(NUMBER_OF_CLASSES))
23 | model.add(Activation("softmax"))
24 |
25 | # Optimizer
26 | optimizer = Adam()
27 |
28 | # Compile Model
29 | model.compile(optimizer=optimizer, loss="categorical_crossentropy", metrics=['accuracy'])
30 |
31 | # Fitting the Dataset
32 | train_data_generator = ImageDataGenerator(
33 | rescale=1./255,
34 | shear_range=0.2,
35 | zoom_range=0.2,
36 | horizontal_flip=True)
37 |
38 | train_generator = train_data_generator.flow_from_directory(
39 | directory="Dataset/training_set",
40 | target_size=(IMAGE_WIDTH, IMAGE_HEIGHT),
41 | batch_size=16,
42 | class_mode="categorical")
43 |
44 | test_data_generator = ImageDataGenerator(rescale=1./255)
45 |
46 | test_generator = test_data_generator.flow_from_directory(
47 | directory="Dataset/test_set",
48 | target_size=(IMAGE_WIDTH, IMAGE_HEIGHT),
49 | batch_size=16,
50 | class_mode="categorical")
51 |
52 | model.fit_generator(train_generator, steps_per_epoch=100, epochs=5, validation_data=test_generator, validation_steps=100)
53 |
54 | # Saving Model
55 | model.save("shape_classifier_le_net_5.h5")
56 |
--------------------------------------------------------------------------------
/urdf/mybot.xacro:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
41 |
42 |
43 |
44 |
46 |
47 |
48 |
49 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 | Gazebo/Blue
83 |
84 |
85 |
86 |
87 |
88 |
91 |
92 |
93 |
94 |
95 |
96 |
97 | transmission_interface/SimpleTransmission
98 |
99 | EffortJointInterface
100 |
101 |
102 | EffortJointInterface
103 | 10
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 | Gazebo/Green
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
170 |
171 |
172 |
173 |
174 |
175 |
176 | 0.0
177 | 0.0
178 | Gazebo/Green
179 |
180 |
181 |
182 |
183 |
184 |
185 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 | Gazebo/White
217 |
218 | 30.0
219 |
220 | 1.3962634
221 |
222 | 640
223 | 320
224 | R8G8B8
225 |
226 |
227 | 0.02
228 | 300
229 |
230 |
231 | gaussian
232 | 0.0
233 | 0.007
234 |
235 |
236 |
237 | true
238 | 0.0
239 | mybot/camera
240 | image_raw
241 | camera_info
242 | camera
243 | 0.07
244 | 0.0
245 | 0.0
246 | 0.0
247 | 0.0
248 | 0.0
249 |
250 |
251 |
252 |
253 |
254 |
255 | /
256 | gazebo_ros_control/DefaultRobotHWSim
257 | true
258 |
259 |
260 |
261 |
262 |
263 | true
264 | 100
265 | left_wheel_hinge
266 | right_wheel_hinge
267 | ${chassis_width+wheel_length}
268 | ${2*wheel_radius}
269 | 1
270 | 30
271 | 1.8
272 | cmd_vel
273 | odom
274 | odom
275 | Debug
276 | false
277 | /
278 | 1
279 | false
280 | base_link
281 |
282 |
283 |
--------------------------------------------------------------------------------
/worlds/world.world:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 1
6 | 0 0 10 0 -0 0
7 | 0.8 0.8 0.8 1
8 | 0.2 0.2 0.2 1
9 |
10 | 1000
11 | 0.9
12 | 0.01
13 | 0.001
14 |
15 | -0.5 0.5 -0.9
16 |
17 |
18 | model://sun
19 |
20 |
21 | model://ground_plane
22 |
23 |
24 |
--------------------------------------------------------------------------------