-
Notifications
You must be signed in to change notification settings - Fork 20
Häfner edited this page Oct 11, 2018
·
12 revisions
This page gathers commands and examples on how to setup and use ROS Melodic with PolyVR.
ROS package installation under Ubuntu
WARNING: You can put the following lines in a script, but Do NOT execute it 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
PolyVR python example
You can use the following code in polyvr to subscribe to a ROS topic
import VR, sys
# change path accordingly!
sys.path.append('/opt/ros/melodic/lib/python2.7/dist-packages')
import rospy, std_msgs
def callback(data):
print data
return
rospy.init_node('polyvr')
def initROS():
rospy.Subscriber('/listener', std_msgs.msg.String, callback)
rospy.spin()
tID = VR.startThread(initROS)
publish a topic
- write in a terminal roscore
- write in another terminal: rostopic pub /listener std_msgs/String "Hello, World"
Web example
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