Python demo now runs
This commit is contained in:
parent
b12aaaa1ac
commit
692e708490
41
copier.yml
41
copier.yml
@ -1,16 +1,33 @@
|
|||||||
_subdirectory: src
|
_subdirectory: src
|
||||||
_answers_file: .copier/answers.service-ros1-catkin.yml
|
_answers_file: .copier/answers.service-ros1-catkin.yml
|
||||||
PACKAGE_NAME: myproject
|
PACKAGE_NAME:
|
||||||
PACKAGE_DESCRIPTION: The myproject package
|
default: myproject
|
||||||
MAINTAINER_NAME: Spiri
|
type: str
|
||||||
MAINTAINER_EMAIL: noreply@spirirobotics.com
|
help: The folder your package lives in. Please avoid spaces.
|
||||||
|
|
||||||
|
PACKAGE_DESCRIPTION:
|
||||||
|
default: The {{PACKAGE_NAME}} package
|
||||||
|
type: str
|
||||||
|
multiline: true
|
||||||
|
|
||||||
|
MAINTAINER_NAME: No Reply
|
||||||
|
MAINTAINER_EMAIL: "{{MAINTAINER_NAME|slugify}}@spirirobotics.com"
|
||||||
LICENSE: BSD
|
LICENSE: BSD
|
||||||
#We use a custom launch script to ensure that rosrun logs to console and have it not accidently launch the master node itself, which can be hard to diagnose
|
#We use a custom launch script to ensure that rosrun logs to console and have it not accidently launch the master node itself, which can be hard to diagnose
|
||||||
RUN_COMMAND: /launch myproject mycommand
|
LANGUAGES:
|
||||||
#Source can be either a local folder or a git repo, if you path starts with `git+`
|
type: str
|
||||||
SOURCE: ./
|
multiselect: true
|
||||||
PROJECT_NAME: My sample project
|
help: Which langauges do you want to use?
|
||||||
#This just checks if it can contact the ROS master, ideally we'd check for something specific to your ROS node.
|
choices:
|
||||||
#This can be tricky when you set ROS node paramaters from environment variables or the like, you may need to write a shell script.
|
- Python
|
||||||
# I'll try to make auto-generating health checks a bit easier in the future.
|
- CPP
|
||||||
HEALTHCHECK: --start-period=60s --start-interval=1s CMD /ros_entrypoint.sh rostopic list
|
|
||||||
|
RUN_COMMAND: rosrun {{PACKAGE_NAME}} {{"main.py" if 'Python' in LANGUAGES elif "CPP" in LANGAUGES "main"}}
|
||||||
|
|
||||||
|
HEALTHCHECK:
|
||||||
|
defualt: --start-period=60s --start-interval=1s CMD /ros_entrypoint.sh rostopic list
|
||||||
|
type: str
|
||||||
|
help: |
|
||||||
|
This health check command should return 0 when your service is running properly.
|
||||||
|
The default healthcheck just checks to see if we can reach the ROS master.
|
||||||
|
Providing a good health check is left as an excersize to the reader.
|
||||||
|
@ -192,6 +192,12 @@ include_directories(
|
|||||||
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
|
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
|
||||||
# )
|
# )
|
||||||
|
|
||||||
|
{%if "Python" in LANGUAGES%}
|
||||||
|
catkin_install_python(PROGRAMS scripts/main.py
|
||||||
|
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
|
||||||
|
)
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
#############
|
#############
|
||||||
## Testing ##
|
## Testing ##
|
||||||
#############
|
#############
|
||||||
|
@ -10,12 +10,7 @@ RUN apt-get install --yes python3-rosdep python3-rosinstall python3-rosinstall-g
|
|||||||
|
|
||||||
WORKDIR /root/catkin_ws/src
|
WORKDIR /root/catkin_ws/src
|
||||||
|
|
||||||
#Copy source into the docker image
|
COPY ./ .
|
||||||
{% if SOURCE.startswith("git+") %}
|
|
||||||
RUN git clone {{SOURCE}}
|
|
||||||
{% elif SOURCE %}
|
|
||||||
COPY {{SOURCE}} .
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
WORKDIR /root/catkin_ws
|
WORKDIR /root/catkin_ws
|
||||||
RUN /bin/bash -c "source /opt/ros/noetic/setup.bash && rosdep init"
|
RUN /bin/bash -c "source /opt/ros/noetic/setup.bash && rosdep init"
|
||||||
@ -30,4 +25,4 @@ RUN apt-get clean
|
|||||||
HEALTHCHECK {{HEALTHCHECK}}
|
HEALTHCHECK {{HEALTHCHECK}}
|
||||||
|
|
||||||
# Command to run your application
|
# Command to run your application
|
||||||
CMD {{RUN_COMMAND}}
|
CMD {{RUN_COMMAND}} --wait --screen
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<package format="2">
|
<package format="2">
|
||||||
<name>{{PACKAGE_NAME}}</name>
|
<name>{{PACKAGE_NAME}}</name>
|
||||||
<version>0.0.0</version>
|
<version>0.0.0</version>
|
||||||
<description>{{PACKAGE_DECRIPTION}}</description>
|
<description>{{PACKAGE_DESCRIPTION}}</description>
|
||||||
|
|
||||||
<!-- One maintainer tag required, multiple allowed, one person per tag -->
|
<!-- One maintainer tag required, multiple allowed, one person per tag -->
|
||||||
<!-- Example: -->
|
<!-- Example: -->
|
20
src/src/{%if 'Python' in LANGUAGES%}scripts{%endif%}/main.py
Normal file
20
src/src/{%if 'Python' in LANGUAGES%}scripts{%endif%}/main.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import rospy
|
||||||
|
from std_msgs.msg import String
|
||||||
|
|
||||||
|
def talker():
|
||||||
|
pub = rospy.Publisher('chatter', String, queue_size=10)
|
||||||
|
rospy.init_node('talker', anonymous=True)
|
||||||
|
rate = rospy.Rate(10) # 10hz
|
||||||
|
while not rospy.is_shutdown():
|
||||||
|
hello_str = "hello world %s" % rospy.get_time()
|
||||||
|
rospy.loginfo(hello_str)
|
||||||
|
pub.publish(hello_str)
|
||||||
|
rate.sleep()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
try:
|
||||||
|
talker()
|
||||||
|
except rospy.ROSInterruptException:
|
||||||
|
pass
|
Loading…
Reference in New Issue
Block a user