Skip to content

Commit

Permalink
Merge pull request #1 from ruffsl/sros
Browse files Browse the repository at this point in the history
Sros
  • Loading branch information
codebot committed May 16, 2016
2 parents da9bde6 + bdb2b81 commit 57b3f5a
Show file tree
Hide file tree
Showing 12 changed files with 189 additions and 1 deletion.
11 changes: 11 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Dependences
* Docker
* https://docs.docker.com/linux/step_one/
* Compose
* https://docs.docker.com/compose/install/

# Running Demo
``` bash
cd <path_to>/ros_comm/docker/sdemo
docker-compose up
```
58 changes: 58 additions & 0 deletions docker/sdemo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
FROM ubuntu:xenial

# setup environment
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8

# setup keys
RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 421C365BD9FF1F717815A3895523BAEEB01FA116

# setup sources.list
RUN echo "deb http://packages.ros.org/ros/ubuntu xenial main" > /etc/apt/sources.list.d/ros-latest.list

# install bootstrap tools
RUN apt-get update && apt-get install --no-install-recommends -y \
python-rosdep \
python-rosinstall \
python-vcstools \
&& rm -rf /var/lib/apt/lists/*

# tempfix for https://github.com/ros-infrastructure/rosdep/pull/454
RUN apt-get update && apt-get install --no-install-recommends -y \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

# bootstrap rosdep
RUN rosdep init \
&& rosdep update

# install build/run tools
# installing sudo and not removing apt cache for rosdep install later on
RUN apt-get update && apt-get install --no-install-recommends -y \
build-essential \
byobu \
openssh-server \
python-catkin-tools \
python-wstool \
wget \
sudo

# build ros packages
ENV ROS_DISTRO kinetic
ENV WORKSPACE /root/sros
WORKDIR $WORKSPACE
RUN wget https://gist.github.com/codebot/874494b34f5d02af2b24a5a312847b9c/raw -O kinetic-sros.rosinstall \
&& wstool init src kinetic-sros.rosinstall -j8 \
&& rosdep install -y --from-paths src --ignore-src --rosdistro kinetic \
&& catkin config --install \
&& catkin build

RUN ssh-keygen -t rsa -f /root/.ssh/id_rsa -P ""
# && service ssh start \
# && ssh-copy-id localhost

# setup entrypoint
COPY ./ros_entrypoint.sh /

ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["bash"]
31 changes: 31 additions & 0 deletions docker/sdemo/docker-compose.old.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '2'

services:
master:
build: .
environment:
- "ROS_HOSTNAME=master.sdemo_default"
- "ROS_SECURITY=ssl"
command: srosmaster

talker:
build: .
environment:
- "ROS_HOSTNAME=talker.sdemo_default"
- "ROS_MASTER_URI=http://master.sdemo_default:11311"
- "ROS_SECURITY=ssl"
command: rosrun rospy_tutorials talker

listener:
build: .
environment:
- "ROS_HOSTNAME=listener.sdemo_default"
- "ROS_MASTER_URI=http://master.sdemo_default:11311"
- "ROS_SECURITY=ssl"
command: rosrun rospy_tutorials listener

# resolvable:
# image: mgood/resolvable
# volumes:
# - /var/run/docker.sock:/tmp/docker.sock
# - /etc/resolv.conf:/tmp/resolv.conf
14 changes: 14 additions & 0 deletions docker/sdemo/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '2'

services:
master:
build: .
environment:
- "ROS_SECURITY=ssl"
command: bash -c "sroscore & rosrun rospy_tutorials listener & rosrun rospy_tutorials talker"

# resolvable:
# image: mgood/resolvable
# volumes:
# - /var/run/docker.sock:/tmp/docker.sock
# - /etc/resolv.conf:/tmp/resolv.conf
7 changes: 7 additions & 0 deletions docker/sdemo/ros_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e

# setup ros environment
# source "/opt/ros/$ROS_DISTRO/setup.bash"
source $WORKSPACE/install/setup.bash
exec "$@"
3 changes: 2 additions & 1 deletion tools/roslaunch/resources/roscore.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<group ns="/">
<param name="rosversion" command="rosversion roslaunch" />
<param name="rosdistro" command="rosversion -d" />
<node pkg="rosout" type="rosout" name="rosout" respawn="true"/>
<!-- <node pkg="rosout" type="rosout" name="rosout" respawn="true"/> -->
<node pkg="rosoutpy" type="rosoutpy" name="rosoutpy" respawn="true"/>
</group>
</launch>
20 changes: 20 additions & 0 deletions tools/rosoutpy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 2.8.3)
project(rosoutpy)

find_package(catkin REQUIRED)

catkin_package(CATKIN_DEPENDS rospy rosgraph_msgs)

catkin_install_python(PROGRAMS
scripts/rosoutpy
scripts/rosoutpy.py
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/scripts
)
install(FILES
launch/rosoutpy.launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
)
install(FILES
README
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/
)
3 changes: 3 additions & 0 deletions tools/rosoutpy/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# rosoutpy
A minimal rosout implementation in python
(no logging currently)
3 changes: 3 additions & 0 deletions tools/rosoutpy/launch/rosoutpy.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<launch>
<node pkg="rosoutpy" type="rosoutpy" name="rosoutpy" respawn="true" output="screen"/>
</launch>
17 changes: 17 additions & 0 deletions tools/rosoutpy/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<package>
<name>rosoutpy</name>
<version>0.0.1</version>
<description>
A minimal rosout implementation in python
</description>
<maintainer email="roxfoxpox@gmail.com">Ruffin White</maintainer>
<license>BSD</license>

<author email="roxfoxpox@gmail.com">Ruffin White</author>

<buildtool_depend version_gte="0.5.68">catkin</buildtool_depend>

<run_depend>rospy</run_depend>
<run_depend>rosgraph_msgs</run_depend>
</package>
1 change: 1 addition & 0 deletions tools/rosoutpy/scripts/rosoutpy
22 changes: 22 additions & 0 deletions tools/rosoutpy/scripts/rosoutpy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python

import rospy
import rosgraph_msgs

class Rosout:
'The rosout node subscribes to /rosout, logs the messages to file, and re-broadcasts the messages to /rosout_agg'
def __init__(self):
rospy.init_node('rosoutpy')
self.pub = rospy.Publisher("/rosout_agg", rosgraph_msgs.msg.Log, queue_size=0)
self.sub = rospy.Subscriber("/rosout", rosgraph_msgs.msg.Log, self.rosoutCallback, queue_size=1)

def rosoutCallback(self, msg):
self.pub.publish(msg)

# Main function.
if __name__ == '__main__':
try:
rosout = Rosout()
rospy.spin()
except rospy.ROSInterruptException:
pass

0 comments on commit 57b3f5a

Please sign in to comment.