Junzhuodu / Object_Recognition

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Object Recognition with Python, ROS and PCL

Setup

  • First copy/move the sensor_stick folder to the ~/catkin_ws/src directory of your active ros workspace.

  • Make sure you have all the dependencies resolved by using the rosdep install tool and running catkin_make:

$ cd ~/catkin_ws
$ rosdep install --from-paths src --ignore-src --rosdistro=kinetic -y
$ catkin_make
  • If it's not already there, add the following lines to your .bashrc file
export GAZEBO_MODEL_PATH=~/catkin_ws/src/sensor_stick/models
source ~/catkin_ws/devel/setup.bash

Preparing for training

Launch the training.launch file to bring up the Gazebo environment:

$ roslaunch sensor_stick training.launch

You should see an empty scene in Gazebo with only the sensor stick robot.

Capturing Features

Next, in a new terminal, run the capture_features.py script to capture and save features for each of the objects in the environment. This script spawns each object in random orientations (default 5 orientations per object) and computes features based on the point clouds resulting from each of the random orientations.

$ rosrun sensor_stick capture_features.py

The features will now be captured and you can watch the objects being spawned in Gazebo. It should take 5-10 sec. for each random orientations (depending on your machine's resources) so with 7 objects total it takes awhile to complete. When it finishes running you should have a training_set.sav file.

Training

Once your feature extraction has successfully completed, you're ready to train your model. First, however, if you don't already have them, you'll need to install the sklearn and scipy Python packages. You can install these using pip:

pip install sklearn scipy

After that, you're ready to run the train_svm.py model to train an SVM classifier on your labeled set of features.

$ rosrun sensor_stick train_svm.py

Classifying Segmented Objects

If everything went well you now have a trained classifier and you're ready to do object recognition!

$ rosrun sensor_stick robot_spawn.launch

In another terminal

$ chmod +x object_recognition.py
$ ./object_recognition.py

image

About


Languages

Language:Python 99.4%Language:C++ 0.3%Language:PowerShell 0.2%Language:CMake 0.1%Language:Makefile 0.0%Language:C 0.0%