Skip to content
Häfner edited this page Oct 10, 2018 · 12 revisions

This is an atempt to use the ROS Melodic ubuntu packages and python bindings to setup a ROS node in PolyVR and access information from another node via network.

ROS packages under Ubuntu

Do NOT execute this in a script as sudo

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net --recv-key 0xB01FA116
sudo apt-get update
sudo apt-get install ros-melodic-ros-base ros-melodic-rospy ros-melodic-rosbridge-server ros-melodic-common-tutorials ros-melodic-rospy-tutorials
sudo rosdep init
rosdep update
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc

Python service and client tutorial

import rospy
from sensor_msgs.msg import *

def callback(data):
    print data
    return

if __name__ == '__main__':
    rospy.init_node('polyvr')
    rospy.Subscriber('/my/topic', JointState, callback)
    rospy.spin()

Web example

Usefull commands

Start a master

roscore

Listen to topic

rostopic echo /my/topic

make a dump of the network traffic

rosbag record -a

play back the network dump (open a master in another console)

rosbag play 2015-06-29-16-40-23.bag

list all available topics

rostopic list
Clone this wiki locally