Commit dc2a3c71 authored by Larkin Heintzman's avatar Larkin Heintzman

first custom working ros cluster!

parent 42538d7d
FROM python:3.7
RUN mkdir /app
WORKDIR /app
ADD . /app/
RUN pip install -r requirements.txt
EXPOSE 5000
CMD ["python", "/app/main.py"]
...@@ -30,13 +30,13 @@ RUN catkin config \ ...@@ -30,13 +30,13 @@ RUN catkin config \
catkin build \ catkin build \
roscpp_tutorials roscpp_tutorials
COPY check_roscore.py /usr/local/bin/check_roscore.py COPY bashCheckRoscore.sh /usr/local/bin/bashCheckRoscore.sh
COPY ros_entrypoint.sh /usr/local/bin/ros_entrypoint.sh COPY ros_entrypoint.sh /usr/local/bin/ros_entrypoint.sh
RUN chmod 755 /usr/local/bin/check_roscore.py &&\ RUN chmod 755 /usr/local/bin/bashCheckRoscore.sh && chmod 755 /usr/local/bin/ros_entrypoint.sh
chmod 755 /usr/local/bin/ros_entrypoint.sh
ENTRYPOINT ["/usr/local/bin/ros_entrypoint.sh"] ENTRYPOINT ["/usr/local/bin/ros_entrypoint.sh"]
# CMD [""]
CMD ["bash"] CMD ["bash"]
# run ros package launch file # run ros package launch file
......
#!/bin/bash
# set -e
# make sure to source ros work space so we can use the rostopic command
FILE="./resp.txt"
OUT="confirm"
until [[ $OUT != "confirm" ]]
do
rostopic list &> $FILE
echo $OUT
OUT=$(awk '/ERR/ { print "confirm" }' $FILE)
sleep 1
done
echo "found roscore!"
rm $FILE
# exit 1
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys import sys
import rosgraph import rospy
if not rosgraph.is_master_online(): if rospy.is_shutdown():
print("Waiting roscore ...") print("Waiting roscore ...")
sys.exit(1) sys.exit(1)
# if not rosgraph.is_master_online():
# print("Waiting roscore ...")
# sys.exit(1)
print("roscore found!") print("roscore found!")
...@@ -24,24 +24,22 @@ spec: ...@@ -24,24 +24,22 @@ spec:
# and tries to connect to the rocore which is running in # and tries to connect to the rocore which is running in
# a container in the master pod deployment. # a container in the master pod deployment.
# https://kubernetes.io/docs/concepts/workloads/pods/init-containers/ # https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
initContainers: # initContainers:
- name: init-service-listener # - name: init-service-listener
image: llhcluster/node:v0 # image: llh/node:v0
args: # args:
- check_roscore.py # - bashCheckRoscore.sh
env: # env:
- name: ROS_MASTER_URI # - name: ROS_MASTER_URI
value: http://service-master:11311 # value: http://service-master:11311
- name: ROS_HOSTNAME # - name: ROS_HOSTNAME
value: service-listener # value: service-listener
containers: containers:
# The real node container # The real node container
- name: llhclusterpublisher - name: llhclusterpublisher
image: llhcluster/node:v0 image: llh/node:v0
args: command: ["/bin/bash"]
- rostopic args: ["-c", "source /opt/ros_ws/devel/setup.bash && /usr/local/bin/bashCheckRoscore.sh && rostopic echo /chatter"]
- echo
- chatter
env: env:
- name: ROS_MASTER_URI - name: ROS_MASTER_URI
value: http://service-master:11311 value: http://service-master:11311
...@@ -55,15 +53,12 @@ spec: ...@@ -55,15 +53,12 @@ spec:
# This is required because the node doesn't fail automatically # This is required because the node doesn't fail automatically
# when roscore stops / restarts. # when roscore stops / restarts.
# https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/ # https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/
livenessProbe: # livenessProbe:
exec: # exec:
command: # command: ["/bin/bash -c 'ros_entrypoint.sh && rostopic info /chatter'"]
- entrypoint.sh # # args: ["-c", "ros_entrypoint.sh && rostopic info /chatter"]
- /opt/ros/melodic/bin/rostopic # initialDelaySeconds: 3
- info # periodSeconds: 3
- chatter
initialDelaySeconds: 5
periodSeconds: 1
--- ---
......
...@@ -20,8 +20,8 @@ spec: ...@@ -20,8 +20,8 @@ spec:
node: roscore node: roscore
spec: spec:
containers: containers:
- name: llhclustermaster - name: roscore
image: llhcluster/master:v0 image: llh/master:v0
args: args:
- roscore - roscore
ports: ports:
......
...@@ -24,27 +24,22 @@ spec: ...@@ -24,27 +24,22 @@ spec:
# and tries to connect to the rocore which is running in # and tries to connect to the rocore which is running in
# a container in the master pod deployment. # a container in the master pod deployment.
# https://kubernetes.io/docs/concepts/workloads/pods/init-containers/ # https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
initContainers: # initContainers:
- name: init-service-talker # - name: init-service-talker
image: llhcluster/node:v0 # image: llh/node:v0
args: # args:
- check_roscore.py # - bashCheckRoscore.sh
env: # env:
- name: ROS_MASTER_URI # - name: ROS_MASTER_URI
value: http://service-master:11311 # value: http://service-master:11311
- name: ROS_HOSTNAME # - name: ROS_HOSTNAME
value: service-talker # value: service-talker
containers: containers:
# The real node container # The real node container
- name: llhclusterpublisher - name: llhclusterpublisher
image: llhcluster/node:v0 image: llh/node:v0
args: command: ["/bin/bash"]
- "rostopic" args: ["-c", "source /opt/ros_ws/devel/setup.bash && /usr/local/bin/bashCheckRoscore.sh && rostopic pub -r 1 chatter std_msgs/String 'hello worl'"]
- "pub"
- "-r 1"
- "chatter"
- "std_msgs/String"
- "Hello, world"
env: env:
- name: ROS_MASTER_URI - name: ROS_MASTER_URI
value: http://service-master:11311 value: http://service-master:11311
...@@ -58,15 +53,16 @@ spec: ...@@ -58,15 +53,16 @@ spec:
# This is required because the node doesn't fail automatically # This is required because the node doesn't fail automatically
# when roscore stops / restarts. # when roscore stops / restarts.
# https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/ # https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/
livenessProbe: # livenessProbe:
exec: # exec:
command: # command: ["/bin/bash -c 'ros_entrypoint.sh && rostopic info /chatter'"]
- entrypoint.sh # # command:
- /opt/ros/melodic/bin/rostopic # # - ros_entrypoint.sh
- info # # - /opt/ros/melodic/bin/rostopic
- chatter # # - info
initialDelaySeconds: 5 # # - chatter
periodSeconds: 1 # initialDelaySeconds: 3
# periodSeconds: 3
--- ---
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment