Skip to content

Commit

Permalink
Code files added
Browse files Browse the repository at this point in the history
  • Loading branch information
PranaliBadge committed Apr 4, 2017
1 parent e1caf7d commit be456d4
Show file tree
Hide file tree
Showing 229 changed files with 40,702 additions and 0 deletions.
99 changes: 99 additions & 0 deletions Chapter06/capture_board_big_5x3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Chapter06/capture_board_big_5x3.svg.pdf
Binary file not shown.
9 changes: 9 additions & 0 deletions Chapter06/find_object_2d.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<launch>
<!-- Nodes -->
<node name="find_object_2d" pkg="find_object_2d" type="find_object_2d" output="screen">
<remap from="image" to="image"/>
<param name="gui" value="false" type="bool"/>
<param name="objects_path" value="~/objects" type="str"/>
<param name="settings_path" value="~/.ros/find_object_2d.ini" type="str"/>
</node>
</launch>
13 changes: 13 additions & 0 deletions Chapter06/find_object_2d_gui.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<launch>


<!-- Nodes -->
<node name="find_object_2d" pkg="find_object_2d" type="find_object_2d" output="screen">
<remap from="image" to="image"/>
<param name="gui" value="true" type="bool"/>
<param name="objects_path" value="~/objects" type="str"/>
<param name="settings_path" value="~/.ros/find_object_2d.ini" type="str"/>
</node>


</launch>
29 changes: 29 additions & 0 deletions Chapter06/find_object_3d.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<launch>
<!-- Example finding 3D poses of the objects detected -->
<!-- $roslaunch openni_launch openni.launch depth_registration:=true -->

<node name="find_object_3d" pkg="find_object_2d" type="find_object_2d" output="screen">
<param name="gui" value="true" type="bool"/>
<param name="settings_path" value="~/.ros/find_object_2d.ini" type="str"/>
<param name="subscribe_depth" value="true" type="bool"/>
<param name="objects_path" value="" type="str"/>
<param name="object_prefix" value="object" type="str"/>

<remap from="rgb/image_rect_color" to="camera/rgb/image_rect_color"/>
<remap from="depth_registered/image_raw" to="camera/depth_registered/image_raw"/>
<remap from="depth_registered/camera_info" to="camera/depth_registered/camera_info"/>
</node>

<!-- Example of tf synchronisation with the objectsStamped message -->
<node name="tf_example" pkg="find_object_2d" type="tf_example" output="screen">
<param name="map_frame_id" value="/map" type="string"/>
<param name="object_prefix" value="object" type="str"/>
</node>
<!-- fake some tf frames for the example /map -> /odom -> /base_link -> /camera_link -->
<node pkg="tf" type="static_transform_publisher" name="base_to_camera_tf"
args="0.1 0.0 0.3 0.0 0.0 0.0 /base_link /camera_link 100" />
<node pkg="tf" type="static_transform_publisher" name="odom_to_base_tf"
args="1.0 0.0 0.1 1.5707 0.0 0.0 /odom /base_link 100" />
<node pkg="tf" type="static_transform_publisher" name="map_to_odom_tf"
args="0.0 0.5 0.0 0.7853 0.0 0.0 /map /odom 100" />
</launch>
12 changes: 12 additions & 0 deletions Chapter07/basic_svm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from sklearn import svm
import numpy as np

X = np.array([[-1, -1], [-2, -1], [1, 1], [2, 1]])
y = np.array([1, 1, 2, 2])


model = svm.SVC(kernel='linear',C=1,gamma=1)

model.fit(X,y)

print(model.predict([[-0.8,-1]]))
21 changes: 21 additions & 0 deletions Chapter07/basic_tf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import tensorflow as tf

sess = tf.Session()

matrix1 = tf.constant([[3., 3.],[4., 4.]])
matrix2 = tf.constant([[3., 3.],[4., 4.]])

message = tf.constant('Results of matrix operations')

product = tf.matmul(matrix1, matrix2)
det = tf.matrix_determinant(matrix1)

result1 = sess.run(product)
result2 = sess.run(det)

print(sess.run(message))
print(result1)
print("\n")
print(result2)

sess.close()
51 changes: 51 additions & 0 deletions Chapter07/basic_tf_code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env python

import tensorflow as tf
import time

matrix_1 = tf.Variable([[1,2,3],[4,5,6],[7,8,9]],name="mat1")
matrix_2 = tf.Variable([[1,2,3],[4,5,6],[7,8,9]],name="mat2")

scalar = tf.constant(5)
number = tf.Variable(1, name="counter")

add_msg = tf.constant("\nResult of matrix addition\n")
mul_msg = tf.constant("\nResult of matrix multiplication\n")
scalar_mul_msg = tf.constant("\nResult of scalar multiplication\n")
number_mul_msg = tf.constant("\nResult of Number multiplication\n")


mat_add = tf.add(matrix_1,matrix_2)
mat_mul = tf.matmul(matrix_1,matrix_2)
mat_scalar_mul = tf.mul(scalar,mat_mul)
mat_number_mul = tf.mul(number,mat_mul)


init_op = tf.initialize_all_variables()
sess = tf.Session()
tf.device("/cpu:0")
sess.run(init_op)

for i in range(1,100):

print "\nFor i =",i

print(sess.run(add_msg))
print(sess.run(mat_add))

print(sess.run(mul_msg))
print(sess.run(mat_mul))

print(sess.run(scalar_mul_msg))
print(sess.run(mat_scalar_mul))

update = tf.assign(number,tf.constant(i))
sess.run(update)

print(sess.run(number_mul_msg))
print(sess.run(mat_number_mul))

time.sleep(0.1)


sess.close()
Binary file added Chapter07/inception-2015-12-05.tgz
Binary file not shown.
188 changes: 188 additions & 0 deletions Chapter07/ros_ml/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
cmake_minimum_required(VERSION 2.8.3)
project(ros_ml)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
)

## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)


## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See https://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
# catkin_python_setup()

################################################
## Declare ROS messages, services and actions ##
################################################

## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
## * add a build_depend tag for "message_generation"
## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET
## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
## but can be declared for certainty nonetheless:
## * add a run_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
## * add "message_generation" and every package in MSG_DEP_SET to
## find_package(catkin REQUIRED COMPONENTS ...)
## * add "message_runtime" and every package in MSG_DEP_SET to
## catkin_package(CATKIN_DEPENDS ...)
## * uncomment the add_*_files sections below as needed
## and list every .msg/.srv/.action file to be processed
## * uncomment the generate_messages entry below
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)

## Generate messages in the 'msg' folder
# add_message_files(
# FILES
# Message1.msg
# Message2.msg
# )

## Generate services in the 'srv' folder
# add_service_files(
# FILES
# Service1.srv
# Service2.srv
# )

## Generate actions in the 'action' folder
# add_action_files(
# FILES
# Action1.action
# Action2.action
# )

## Generate added messages and services with any dependencies listed here
# generate_messages(
# DEPENDENCIES
# std_msgs
# )

################################################
## Declare ROS dynamic reconfigure parameters ##
################################################

## To declare and build dynamic reconfigure parameters within this
## package, follow these steps:
## * In the file package.xml:
## * add a build_depend and a run_depend tag for "dynamic_reconfigure"
## * In this file (CMakeLists.txt):
## * add "dynamic_reconfigure" to
## find_package(catkin REQUIRED COMPONENTS ...)
## * uncomment the "generate_dynamic_reconfigure_options" section below
## and list every .cfg file to be processed

## Generate dynamic reconfigure parameters in the 'cfg' folder
# generate_dynamic_reconfigure_options(
# cfg/DynReconf1.cfg
# cfg/DynReconf2.cfg
# )

###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if you package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES ros_ml
# CATKIN_DEPENDS roscpp rospy std_msgs
# DEPENDS system_lib
)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
${catkin_INCLUDE_DIRS}
)

## Declare a C++ library
# add_library(ros_ml
# src/${PROJECT_NAME}/ros_ml.cpp
# )

## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure
# add_dependencies(ros_ml ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Declare a C++ executable
# add_executable(ros_ml_node src/ros_ml_node.cpp)

## Add cmake target dependencies of the executable
## same as for the library above
# add_dependencies(ros_ml_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Specify libraries to link a library or executable target against
# target_link_libraries(ros_ml_node
# ${catkin_LIBRARIES}
# )

#############
## Install ##
#############

# all install targets should use catkin DESTINATION variables
# See https://ros.org/doc/api/catkin/html/adv_user_guide/variables.html

## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# install(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

## Mark executables and/or libraries for installation
# install(TARGETS ros_ml ros_ml_node
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

## Mark cpp header files for installation
# install(DIRECTORY include/${PROJECT_NAME}/
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
# FILES_MATCHING PATTERN "*.h"
# PATTERN ".svn" EXCLUDE
# )

## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
# # myfile1
# # myfile2
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )

#############
## Testing ##
#############

## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_ros_ml.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()

## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
34 changes: 34 additions & 0 deletions Chapter07/ros_ml/data/pos_readings.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
5125,5125,1
6210,6210,1
3125,3125,1
2210,2210,1
3125,3125,1
2340,2340,1
3455,3455,1
2232,2232,1
1231,1231,1
1213,1213,1

10125,10125,2
6410,6410,2
5845,5845,2
6570,6570,2
8375,8375,2
9545,9545,2
3460,3460,2
8678,8678,2
6800,6800,2
12403,12403,2


14325,14325,3
16304,16304,3
18232,18232,3
11233,11233,3
23232,23232,3
22223,22223,3
15360,15360,3
17120,17120,3
15302,15302,3
12303,12303,3

Loading

0 comments on commit be456d4

Please sign in to comment.