From 406d41be3b564cf3a6067b34ad1c118a31d0f64b Mon Sep 17 00:00:00 2001 From: fherrero <fherrero@iri.upc.edu> Date: Tue, 2 Jun 2020 10:42:11 +0200 Subject: [PATCH] Add ROS Interfaces sections to Readme as they are added with scripts. Add also tf interfaces. Allow adding absolute namespace interfaces, for tf (/tf vs ~topic) --- add_action_server_client.sh | 2 +- add_service_server_client.sh | 2 +- add_tf_listener_broadcaster.sh | 5 ++++- add_topic_publisher_subscriber.sh | 2 +- common_templates/README.md | 12 ------------ libraries/scripts_library.sh | 31 +++++++++++++++++++++++++------ 6 files changed, 32 insertions(+), 22 deletions(-) diff --git a/add_action_server_client.sh b/add_action_server_client.sh index f0c0583..ac6639e 100755 --- a/add_action_server_client.sh +++ b/add_action_server_client.sh @@ -123,4 +123,4 @@ else 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 +fill_readme_ros_interface ${type} ${server_client} ${ros_pkg} ${action_name} ${file_pkg} ${action_file}.action "false" \ No newline at end of file diff --git a/add_service_server_client.sh b/add_service_server_client.sh index bfb820f..8d19a9f 100755 --- a/add_service_server_client.sh +++ b/add_service_server_client.sh @@ -122,4 +122,4 @@ else fi type="service" -fill_readme_ros_interface ${type} ${server_client} ${ros_pkg} ${service_name} ${file_pkg} ${srv_file} \ No newline at end of file +fill_readme_ros_interface ${type} ${server_client} ${ros_pkg} ${service_name} ${file_pkg} ${srv_file} "false" \ No newline at end of file diff --git a/add_tf_listener_broadcaster.sh b/add_tf_listener_broadcaster.sh index 263bff1..dbf4b91 100755 --- a/add_tf_listener_broadcaster.sh +++ b/add_tf_listener_broadcaster.sh @@ -96,4 +96,7 @@ then create_tf_broadcaster ${ros_pkg} ${node_h} ${node_c} ${driver_alg} else create_tf_listener ${ros_pkg} ${node_h} ${node_c} ${driver_alg} -fi \ No newline at end of file +fi + +type="topic" +fill_readme_ros_interface ${type} ${pub_subs} ${ros_pkg} "tf" "tf" "tfMessage" "true" \ No newline at end of file diff --git a/add_topic_publisher_subscriber.sh b/add_topic_publisher_subscriber.sh index 17a4461..5504b8b 100755 --- a/add_topic_publisher_subscriber.sh +++ b/add_topic_publisher_subscriber.sh @@ -145,4 +145,4 @@ else fi type="topic" -fill_readme_ros_interface ${type} ${pub_subs} ${ros_pkg} ${topic_name} ${file_pkg} ${msg_file} \ No newline at end of file +fill_readme_ros_interface ${type} ${pub_subs} ${ros_pkg} ${topic_name} ${file_pkg} ${msg_file} "false" \ No newline at end of file diff --git a/common_templates/README.md b/common_templates/README.md index c769329..fdc7a68 100644 --- a/common_templates/README.md +++ b/common_templates/README.md @@ -8,18 +8,6 @@ Developed at Institut de Robòtica i Informà tica Industrial (IRI, CSIC-UPC) (ww 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. diff --git a/libraries/scripts_library.sh b/libraries/scripts_library.sh index 5b0d3a1..ad17483 100755 --- a/libraries/scripts_library.sh +++ b/libraries/scripts_library.sh @@ -279,13 +279,13 @@ function add_pkg_dependency_to_readme # - $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} +function fill_readme_ros_interface # ${type} ${pub_subs} ${ros_pkg} ${topic_name} ${file_pkg} ${msg_file} ${absolute_ns} { if [[ -z $1 ]] || [[ -z $2 ]] || [[ -z $3 ]] || [[ -z $4 ]] || [[ -z $5 ]] || [[ -z $6 ]] then kill_exit "ERROR: 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 @@ -293,12 +293,22 @@ function fill_readme_ros_interface # ${type} ${pub_subs} ${ros_pkg} ${topic_name local if_name=$4 local if_pkg=$5 local if_msg=$6 + local absolute_ns=$7 roscd "${ros_pkg}" - file=README.md - line=" - ~$if_name ($if_pkg/$if_msg)" - comment="" + local file=README.md + local line="" + local comment="" + + echo "Filling $file with ROS Interfaces information..." + + if [ "$absolute_ns" = true ] + then + line=" - /$if_name ($if_pkg/$if_msg)" + else + line=" - ~$if_name ($if_pkg/$if_msg)" + fi case "$if_type" in "topic") @@ -310,6 +320,12 @@ function fill_readme_ros_interface # ${type} ${pub_subs} ${ros_pkg} ${topic_name "subscriber") comment="### Topic subscribers" ;; + "broadcaster") + comment="### Topic publishers" + ;; + "listener") + comment="### Topic subscribers" + ;; esac ;; "service") @@ -333,6 +349,8 @@ function fill_readme_ros_interface # ${type} ${pub_subs} ${ros_pkg} ${topic_name esac ;; esac + + add_line_to_file "${comment}" "# ROS Interface" "${file}" add_line_to_file "${line}" "${comment}" "${file}" } @@ -417,7 +435,8 @@ function add_line_to_file if [[ -z "${line_found}" ]] then - sed -i -e "/${comment}/a\\${line_to_add}" "${file}" + #echo "Adding line after comment: ${line_to_add} after ${comment_to_find}" + sed -i -e "/${comment_to_find}/a\\${line_to_add}" "${file}" else #skip line echo "File ${file} already included the line, skipping..." -- GitLab