Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit e42c96a

Browse files
author
Dmitry Rozhkov
committed
meta-refkit-extra: add ROS helloworld example package
Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
1 parent 353f9d9 commit e42c96a

8 files changed

Lines changed: 139 additions & 0 deletions

File tree

meta-refkit-extra/conf/distro/include/refkit-extra-supported-recipes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ python3-protobuf@refkit-extra
99
python3-pycparser@meta-python
1010
python3-pyrealsense@refkit-extra
1111
python3-six@core
12+
refkit-ros-tests@refkit-extra
1213
snappy@refkit-extra
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
Introduction
2+
============
3+
4+
The core of the ROS project is a XMLRPC-based publisher-subscriber
5+
middleware. This instruction documents how to run a simple ROS
6+
application in IoT Refkit. The application is documented in
7+
the `Writing a Simple Publisher and Subscriber`_ tutorial.
8+
9+
How to run
10+
==========
11+
12+
1. Create an image containing the package `refkit-ros-tests`, e.g. by putting
13+
this line in your `local.conf`::
14+
15+
IMAGE_INSTALL_append = " refkit-ros-tests"
16+
17+
and running::
18+
19+
$ bitbake refkit-image-common
20+
21+
2. Start up a QEMU VM with the built image::
22+
23+
$ runqemu ovmf refkit-image-common wic slirp serial nographic
24+
25+
3. Set up ROS environment in the VM::
26+
27+
export ROS_ROOT=/opt/ros
28+
export ROS_DISTRO=indigo
29+
export ROS_PACKAGE_PATH=/opt/ros/indigo/share
30+
export PATH=$PATH:/opt/ros/indigo/bin
31+
export LD_LIBRARY_PATH=/opt/ros/indigo/lib
32+
export PYTHONPATH=/opt/ros/indigo/lib/python3.5/site-packages
33+
export ROS_MASTER_URI=http://localhost:11311
34+
export CMAKE_PREFIX_PATH=/opt/ros/indigo
35+
touch /opt/ros/indigo/.catkin
36+
37+
4. Launch all the needed ROS nodes with the command::
38+
39+
roslaunch refkit_ros_tests helloworld.launch
40+
41+
If everything is correct then two nodes get launched:
42+
43+
- a publisher node sending standard string messages "hello world" to a ROS
44+
topic and
45+
- a subscriber node listening to the topic and exiting upon the
46+
message.
47+
48+
As soon as the subscriber node exits all the other nodes should
49+
exit successfully.
50+
51+
.. _Writing a Simple Publisher and Subscriber: http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28python%29
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cmake_minimum_required(VERSION 2.8.3)
2+
project(refkit_ros_tests)
3+
4+
find_package(catkin REQUIRED)
5+
6+
catkin_package()
7+
8+
install(DIRECTORY launch
9+
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
10+
install(PROGRAMS scripts/talker.py
11+
scripts/listener.py
12+
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0"?>
2+
<launch>
3+
<node name="refkit_ros_tests_talker" pkg="refkit_ros_tests" type="talker.py" output="screen" required="true" />
4+
<node name="refkit_ros_tests_listener" pkg="refkit_ros_tests" type="listener.py" output="screen" required="true" />
5+
</launch>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<package>
2+
3+
<name>refkit_ros_tests</name>
4+
<version>0.1.0</version>
5+
<description>
6+
Test ROS nodes for Refkit
7+
</description>
8+
<author email="dmitry.rozhkov@intel.com">Dmitry Rozhkov</author>
9+
<maintainer email="dmitry.rozhkov@intel.com">Dmitry Rozhkov</maintainer>
10+
11+
<license>MIT</license>
12+
13+
<url type="website">http://todo/</url>
14+
<url type="bugtracker">https://todo/issues</url>
15+
<url type="repository">https://todo/</url>
16+
17+
<buildtool_depend>catkin</buildtool_depend>
18+
</package>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python
2+
3+
import rospy
4+
from std_msgs.msg import String
5+
6+
def callback(data):
7+
rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.data)
8+
rospy.signal_shutdown("Success")
9+
10+
def listener():
11+
12+
rospy.init_node('listener', anonymous=True)
13+
14+
rospy.Subscriber("chatter", String, callback)
15+
16+
rospy.spin()
17+
18+
if __name__ == '__main__':
19+
listener()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python
2+
3+
import rospy
4+
from std_msgs.msg import String
5+
6+
def talker():
7+
pub = rospy.Publisher('chatter', String, queue_size=10)
8+
rospy.init_node('talker', anonymous=True)
9+
rate = rospy.Rate(1) # 1hz
10+
while not rospy.is_shutdown():
11+
hello_str = "hello world"
12+
rospy.loginfo(hello_str)
13+
pub.publish(hello_str)
14+
rate.sleep()
15+
16+
if __name__ == '__main__':
17+
try:
18+
talker()
19+
except rospy.ROSInterruptException:
20+
pass
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
DESCRIPTION = "Test ROS nodes for Refkit"
2+
SECTION = "devel"
3+
LICENSE = "MIT"
4+
LIC_FILES_CHKSUM = "file://package.xml;beginline=11;endline=11;md5=58e54c03ca7f821dd3967e2a2cd1596e"
5+
6+
SRC_URI = "file://${PN}-${PV}/scripts/talker.py \
7+
file://${PN}-${PV}/scripts/listener.py \
8+
file://${PN}-${PV}/launch/helloworld.launch \
9+
file://${PN}-${PV}/CMakeLists.txt \
10+
file://${PN}-${PV}/package.xml \
11+
"
12+
13+
inherit catkin

0 commit comments

Comments
 (0)