diff --git a/add_action_server_client.sh b/add_action_server_client.sh index ed0cf7b3063c9c15fc3981d7739f922611ca8584..2cc0a3c8935e57b469743e89f0da4a696fcf9e9f 100755 --- a/add_action_server_client.sh +++ b/add_action_server_client.sh @@ -126,3 +126,5 @@ else create_action_client ${ros_pkg} ${action_name} ${action_file%.action} ${file_pkg} ${node_h} ${node_c} ${driver_alg} fi +type="action" +fill_readme_ros_interface ${type} ${server_client} ${ros_pkg} ${action_name} ${file_pkg} ${action_file}.action \ No newline at end of file diff --git a/add_service_server_client.sh b/add_service_server_client.sh index ee94f426c954ec0d9b776b61728584dc0856394d..bae8fc583387f4d0d31ad8acd3c150023cd8fee5 100755 --- a/add_service_server_client.sh +++ b/add_service_server_client.sh @@ -124,3 +124,6 @@ then else create_client ${ros_pkg} ${service_name} ${srv_file%.srv} ${file_pkg} ${node_h} ${node_c} ${driver_alg} fi + +type="service" +fill_readme_ros_interface ${type} ${server_client} ${ros_pkg} ${service_name} ${file_pkg} ${srv_file} \ No newline at end of file diff --git a/add_topic_publisher_subscriber.sh b/add_topic_publisher_subscriber.sh index 5a0614013de49475be043239828410a3832e125f..2a27b5a3ced7b3d881d74e825f3dbcd503ef1ff7 100755 --- a/add_topic_publisher_subscriber.sh +++ b/add_topic_publisher_subscriber.sh @@ -148,3 +148,5 @@ else create_subscriber ${ros_pkg} ${topic_name} ${msg_file%.msg} ${file_pkg} ${buffer} ${node_h} ${node_c} ${driver_alg} fi +type="topic" +fill_readme_ros_interface ${type} ${pub_subs} ${ros_pkg} ${topic_name} ${file_pkg} ${msg_file} \ No newline at end of file diff --git a/common_templates/README.md b/common_templates/README.md index 61d155ef4946f953541f5ce5930347d20e4d03ad..c769329714cdb632c5734e4c0cfc6d44fbcb0e4b 100644 --- a/common_templates/README.md +++ b/common_templates/README.md @@ -7,6 +7,25 @@ The template project description Developed at Institut de Robòtica i Informà tica Industrial (IRI, CSIC-UPC) (www.iri.upc.edu) Contact: labrobotica@iri.upc.edu +# ROS Interface + +### Topic subscribers + +### Topic publishers + +### Service servers + +### Service clients + +### Action servers + +### Action clients + +### Parameters +- ~rate (Double; default: 10.0; min: 0.1; max: 1000) The main node thread loop rate in Hz. + +## Dependencies + ## Installation Clone the package inside a ROS workspace, although it will normally come within a rosinstall file. diff --git a/libraries/scripts_library.sh b/libraries/scripts_library.sh index 6ca85e7e20592aff8fdc2197f03f7b6bfe9b584b..17dba638ba1cad7e90effff05d9ebd7e212cd275 100755 --- a/libraries/scripts_library.sh +++ b/libraries/scripts_library.sh @@ -282,8 +282,113 @@ function add_pkg_to_packagexml pub="<build_depend>${file_pkg}<build_depend/>" sed -i -e "/${comment}/a\\ ${pub}" "package.xml" else - echo "Package \"${file_pkg}\" already added as dependency, skipping" + echo "Package \"${file_pkg}\" already added as dependency in package.xml, skipping" fi + + add_pkg_dependency_to_readme $ros_pkg $file_pkg +} + +# add_pkg_to_readme +# Adds $2 as dependency to README.md file. +# - $1: current ros package +# - $2: message ros package +function add_pkg_dependency_to_readme +{ + if [[ -z $1 ]] || [[ -z $2 ]] + then + kill_exit "add_pkg_to_readme: missing input parameters" + fi + + local ros_pkg=$1 + local file_pkg=$2 + + #go to package folder + roscd "${ros_pkg}" + + file=README.md + +# #look for package in package.xml and add dependency if necessary +# local pub="- ${file_pkg}" +# local pub1=$(grep "${pub}" ${file}) +# if [[ -z "${pub1}" ]] +# then +# echo "Adding package \"${file_pkg}\" as dependency..." +# local comment="##Dependencies" +# pub="- ${file_pkg}" +# sed -i -e "/${comment}/a\\ ${pub}" ${file} +# else +# echo "Package \"${file_pkg}\" already added as dependency in README, skipping" +# fi + + line="\- ${file_pkg}" + comment="## Dependencies" + add_line_to_file "${line}" "${comment}" "${file}" +} + +# fill_readme_ros_interface +# Adds ROS interface type $1/$2 to README.md from $2 package, as a $3 name and $4/$5 type +# - $1: interface type: topic, service, action +# - $2: interface subtype: publisher/subscriber, client/server, client/server +# - $3: current ros package +# - $4: interface name +# - $5: interface package +# - $6: interface message +function fill_readme_ros_interface # ${type} ${pub_subs} ${ros_pkg} ${topic_name} ${file_pkg} ${msg_file} +{ + if [[ -z $1 ]] || [[ -z $2 ]] || [[ -z $3 ]] || [[ -z $4 ]] || [[ -z $5 ]] || [[ -z $6 ]] + then + kill_exit "fill_readme_ros_interface missing input parameters" + fi + + #echo "fill_readme_ros_interface $1 $2 $3 $4 $5 $6" + local if_type=$1 + local if_subtype=$2 + local ros_pkg=$3 + local if_name=$4 + local if_pkg=$5 + local if_msg=$6 + + roscd "${ros_pkg}" + + file=README.md + line=" - ~$if_name ($if_pkg/$if_msg)" + comment="" + + case "$if_type" in + "topic") + + case "$if_subtype" in + "publisher") + comment="### Topic publishers" + ;; + "subscriber") + comment="### Topic subscribers" + ;; + esac + ;; + "service") + case "$if_subtype" in + "client") + comment="### Service clients" + ;; + "server") + comment="### Service servers" + ;; + esac + ;; + "action") + case "$if_subtype" in + "client") + comment="### Action clients" + ;; + "server") + comment="### Action servers" + ;; + esac + ;; + esac + + add_line_to_file "${line}" "${comment}" "${file}" } # find_comment_in_file @@ -344,6 +449,7 @@ function text_found_in_file # - $3: text file name function add_line_to_file { + #echo "add_line_to_file $1 $2 $3" if [[ -z $1 ]] || [[ -z $2 ]] || [[ -z $3 ]] then kill_exit "add_line_to_file: missing input parameters"