Skip to content
☕️ Integrate Caffe model into ROS
C++ Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
caffe @ f1cc905 Add caffe as submodule Aug 25, 2015
src Type in README Aug 31, 2015
.gitmodules Add caffe as submodule Aug 25, 2015
CMakeLists.txt Add topics to recievie cv::Mat and publish result Aug 31, 2015 include astra launch instructions Jan 16, 2017
package.xml Add topics to recievie cv::Mat and publish result Aug 31, 2015



Integrate Caffe model into ROS


Grab the source

$ cd [CATKIN_WS]/src

$ git clone --recursive

$ cd [CATKIN_WS]/src/ros_caffe


Build Caffe

cd [CATKIN_WS]/src/ros_caffe/caffe

cp Makefile.config.example Makefile.config

$ vi Makefile.config

For CPU-only Caffe, uncomment CPU_ONLY := 1 in Makefile.config.

$ make all ; make distribute

Build ros package

$ cd [CATKIN_WS]

$ catkin_make

$ source ./devel/setup.bash


You can download default caffenet's model. It will be located at data folder

cd data; sh

Open a terminal, execute

$ roscore

Open another terminal, execute $ roslaunch turtlebot_bringup 3dsensor.launch

if you dont have turtlebot, you could use astra's camera: $ roslaunch astra_launch astra.launch

Open another terminal, execute

$ rosrun ros_caffe ros_caffe_test


Test default image under /data/cat.jpg
0.1384 - "n02123159 tiger cat"
0.1302 - "n02123045 tabby, tabby cat"
0.1138 - "n02085620 Chihuahua"
0.1076 - "n02094433 Yorkshire terrier"
0.0914 - "n02123394 Persian cat"

You can echo a topic to receive the string message.

$ rostopic echo /caffe_ret

data: [0.138446 - n02123159 tiger cat]
[0.130182 - n02123045 tabby, tabby cat]
[0.113755 - n02085620 Chihuahua]
[0.107584 - n02094433 Yorkshire terrier]
[0.0913549 - n02123394 Persian cat]

ROS Topics

Publish a topic after classifiction


Receive an image :


Optional settting

You can change your Caffe's include and lib path in CMakeLists.txt.

set(CAFFE_INCLUDEDIR caffe/include caffe/distribute/include)
set(CAFFE_LINK_LIBRARAY caffe/lib)
You can’t perform that action at this time.