diff --git a/docs/tutorials/quick-start.rst b/docs/tutorials/quick-start.rst index e6cac0e8..b5baacca 100644 --- a/docs/tutorials/quick-start.rst +++ b/docs/tutorials/quick-start.rst @@ -42,7 +42,7 @@ For more details check :ref:`use-case description `. source /install/setup.bash cd / - setup-robot-description + setup-robot-description Create robot bringup package @@ -54,7 +54,7 @@ For more details check :ref:`use-case description `. source /install/setup.bash cd / - setup-robot-bringup + setup-robot-bringup Setup ros2_control control hardware diff --git a/docs/use-cases/ros2_control/setup_controller.rst b/docs/use-cases/ros2_control/setup_controller.rst index 3f3f7850..ea551157 100644 --- a/docs/use-cases/ros2_control/setup_controller.rst +++ b/docs/use-cases/ros2_control/setup_controller.rst @@ -18,7 +18,7 @@ Usage :caption: Usage of script for setting up a controller. :name: ros2_control_setup-controller-package - ros2_control_setup-controller-package FILE_NAME [CLASS_NAME] [PKG_NAME] + ros2_control_setup-controller-package FILE_NAME [CLASS_NAME] Parameters: @@ -29,10 +29,9 @@ Parameters: - ``CLASS_NAME`` optional name used for controller class. If not set, it is guessed by camel-casing the file name. - - ``PKG_NAME`` name of the controller's package. - If not set, it is guessed from the current path using the folder's name. - The script will ask for some additional input. +The package name is obtained from the 'package.xml' file. + After all files are copied and placeholders set, changes are automatically staged in git. diff --git a/docs/use-cases/ros2_control/setup_robot_hardware_interface.rst b/docs/use-cases/ros2_control/setup_robot_hardware_interface.rst index 29efd030..13f6054d 100644 --- a/docs/use-cases/ros2_control/setup_robot_hardware_interface.rst +++ b/docs/use-cases/ros2_control/setup_robot_hardware_interface.rst @@ -5,11 +5,11 @@ ros2_control: Setup robot's hardware package This use-case describes how to set up a robot's hardware interface for the ros2_control framework using scripts from ROS Team Workspace (RosTeamWS) framework. -``ros2_control_setup-hardware-interface-package`` script accepts the file name of the robot's hardware interfacea and, optionally, class name and the package name. +``ros2_control_setup-hardware-interface-package`` script accepts the file name of the robot's hardware interfacea and, optionally, class name. The file name should use standard ROS format . A ``.cpp`` and ``.hpp`` files will added using this name. If the class name is not set, it is guessed by camel-casing the file name. -If the package name is not set, it is guessed from the current path using the folder's name. +The package name is obtained from the 'package.xml' file. The script **has to be executed** from the package folder where the package should be generated. **Note**: it is recommended to setup your package using :ref:`setup-new-package ` script. @@ -21,7 +21,7 @@ The scripts adds also a plugin description and simple test checking if the plugi :caption: Usage of script for setting up the robot bringup. :name: ros2_control_setup-hardware-interface-package - ros2_control_setup-hardware-interface-package FILE_NAME [CLASS_NAME] [PKG_NAME] + ros2_control_setup-hardware-interface-package FILE_NAME [CLASS_NAME] -After all files are copied and placeholders set, a commit can be automatically created. +After all files are copied and placeholders set, changes are automatically staged in git. diff --git a/docs/use-cases/ros_packages/create_package.rst b/docs/use-cases/ros_packages/create_package.rst index 7c1c3f90..54237e09 100644 --- a/docs/use-cases/ros_packages/create_package.rst +++ b/docs/use-cases/ros_packages/create_package.rst @@ -27,11 +27,8 @@ The script supports the following options and opportunities for data entry: - If subpackage, then you will need to enter the name of its metapackage - #. License (string) - enter a full name to add into package.xml - #. Manual input of the maintainer or using data from git-config - (y/n) - - - If *yes* then you should enter the full name and email address of the maintainer - + #. License (string) - choose a license to add into package.xml - multiple choice + #. Maintainer info: name and email (user input, local git, global git) - multiple choice #. Package build type (ament_cmake, ament_python, cmake) - multiple choice #. Create/Update repository with CI configuration - (y/n) diff --git a/docs/use-cases/ros_packages/setup_robot_bringup_package.rst b/docs/use-cases/ros_packages/setup_robot_bringup_package.rst index f3de86bb..48f1991d 100644 --- a/docs/use-cases/ros_packages/setup_robot_bringup_package.rst +++ b/docs/use-cases/ros_packages/setup_robot_bringup_package.rst @@ -10,19 +10,19 @@ The package follows as far as possible best practices for `robot support package Script for Setting up Description Package ============================================ -``setup-robot-bringup`` script accepts the robot name and, optionally, the package name. -If the package name is not set, it is guessed from the current path using the folder's name. +``setup-robot-bringup`` script accepts the robot name and the robot description package name. +The package name is obtained from the 'package.xml' file. The script **has to be executed** from the folder where the bringup should be generated. .. note:: it is recommended to setup your package using :ref:`setup-new-package ` script. -The scripts copies template files from the ``templates/robot_bringup`` folder, rename the files, and replaces the placeholders. +The scripts copies template files from the ``templates/robot_bringup`` folder, renames the files, and replaces the placeholders. .. code-block:: bash :caption: Usage of script for setting up the robot bringup. :name: setup-robot-bringup - setup-robot-bringup ROBOT_NAME [PKG_NAME] + setup-robot-bringup ROBOT_NAME DESCRIPTION_PKG_NAME -After all files are copied and placeholders set, a commit is automatically created. +After all files are copied and placeholders set, changes are automatically staged in git. diff --git a/docs/use-cases/ros_packages/setup_robot_description_package.rst b/docs/use-cases/ros_packages/setup_robot_description_package.rst index 04da7e76..7d457c90 100644 --- a/docs/use-cases/ros_packages/setup_robot_description_package.rst +++ b/docs/use-cases/ros_packages/setup_robot_description_package.rst @@ -10,22 +10,22 @@ The package follows as far as possible best practices for `robot support package Script for Setting up Description Package ============================================ -``setup-robot-description`` script accepts the robot name and, optionally, the package name. -If the package name is not set, it is guessed from the current path using the folder's name. +``setup-robot-description`` script accepts the robot name. +The package name is obtained from the 'package.xml' file. The script **has to be executed** from the package folder where the description should be generated. .. note:: it is recommended to setup your package using :ref:`create-new-package ` script. -The scripts copies template files from the ``templates/robot_description`` folder, rename the files, and replaces the placeholders. +The scripts copies template files from the ``templates/robot_description`` folder, renames the files, and replaces the placeholders. .. code-block:: bash :caption: Usage of script for setting up the robot description. :name: setup-robot-description - setup-robot-description ROBOT_NAME [PKG_NAME] + setup-robot-description ROBOT_NAME -After all files are copied and placeholders set, a commit is automatically created. +After all files are copied and placeholders set, changes are automatically staged in git. To test the generated files compile and source your workspace and execute: diff --git a/scripts/ros2_control/setup-controller-package.bash b/scripts/ros2_control/setup-controller-package.bash index db608d58..f7f01bfa 100755 --- a/scripts/ros2_control/setup-controller-package.bash +++ b/scripts/ros2_control/setup-controller-package.bash @@ -14,11 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -usage="setup-controller-package.bash FILE_NAME [CLASS_NAME] [PKG_NAME]" - -# echo "" -# echo "Your path is `pwd`. Is this your package folder where to setup robot's bringup?" -# read -p "If so press otherwise +C and start the script again from the bringup folder." +usage="setup-controller-package.bash FILE_NAME [CLASS_NAME]" # Load Framework defines script_own_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )" @@ -34,6 +30,11 @@ if [ -f src/$FILE_NAME.cpp ]; then print_and_exit "ERROR:The file '$FILE_NAME' already exist! 😱!" "$usage" fi +if [ ! -f "package.xml" ]; then + print_and_exit "ERROR: 'package.xml' not found. You should execute this script at the top level of your package folder. Nothing to do 😯" "$usage" +fi +PKG_NAME="$(grep -Po '(?<=).*?(?=)' package.xml | sed -e 's/[[:space:]]//g')" + echo "" # Adds empty line CLASS_NAME=$2 @@ -49,14 +50,6 @@ if [ -z "$2" ]; then echo -e "${TERMINAL_COLOR_USER_CONFIRMATION}ClassName guessed from the '$FILE_NAME': '$CLASS_NAME'. Is this correct? If not, provide it as the second parameter.${TERMINAL_COLOR_NC}" fi -PKG_NAME=$3 -if [ -z "$3" ]; then - current=$(pwd) - PKG_NAME=$(basename "$current") - echo -e "${TERMINAL_COLOR_USER_CONFIRMATION}Package name guessed from the current path is '$PKG_NAME'. Is this correct? If not provide it as the third parameter.${TERMINAL_COLOR_NC}" -fi -read - echo -e "${TERMINAL_COLOR_USER_INPUT_DECISION}Which license-header do you want to use? [1]" echo "(0) None" echo "(1) Apache-2.0" diff --git a/scripts/ros2_control/setup-hardware-interface-package.bash b/scripts/ros2_control/setup-hardware-interface-package.bash index 7c29139c..2914e65d 100755 --- a/scripts/ros2_control/setup-hardware-interface-package.bash +++ b/scripts/ros2_control/setup-hardware-interface-package.bash @@ -14,11 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -usage="setup-robot-ros2-control-hardware.bash FILE_NAME [CLASS_NAME] [PKG_NAME]" - -# echo "" -# echo "Your path is `pwd`. Is this your package folder where to setup robot's bringup?" -# read -p "If so press otherwise +C and start the script again from the bringup folder." +usage="ros2_control_setup-hardware-interface-package FILE_NAME [CLASS_NAME]" # Load Framework defines script_own_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )" @@ -34,6 +30,11 @@ if [ -f src/$FILE_NAME.cpp ]; then print_and_exit "ERROR:The file '$FILE_NAME' already exist! 😱!" "$usage" fi +if [ ! -f "package.xml" ]; then + print_and_exit "ERROR: 'package.xml' not found. You should execute this script at the top level of your package folder. Nothing to do 😯" "$usage" +fi +PKG_NAME="$(grep -Po '(?<=).*?(?=)' package.xml | sed -e 's/[[:space:]]//g')" + echo "" # Adds empty line CLASS_NAME=$2 @@ -49,13 +50,6 @@ if [ -z "$2" ]; then echo -e "${TERMINAL_COLOR_USER_CONFIRMATION}ClassName guessed from the '$FILE_NAME': '$CLASS_NAME'. Is this correct? If not provide it as the second parameter.${TERMINAL_COLOR_NC}" fi -PKG_NAME=$3 -if [ -z "$3" ]; then - current=`pwd` - PKG_NAME=$(basename "$current") - echo -e "${TERMINAL_COLOR_USER_CONFIRMATION}Package name guessed from the current path is '$PKG_NAME'. Is this correct? If not provide it as the third parameter.${TERMINAL_COLOR_NC}" -fi - echo -e "${TERMINAL_COLOR_USER_INPUT_DECISION}Which license-header do you want to use? [1]" echo "(0) None" echo "(1) Apache 2.0 License" diff --git a/scripts/setup-robot-bringup.bash b/scripts/setup-robot-bringup.bash index 5a1059a0..6e3231db 100755 --- a/scripts/setup-robot-bringup.bash +++ b/scripts/setup-robot-bringup.bash @@ -14,11 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -usage="setup-robot-bringup.bash ROBOT_NAME DESCRIPTION_PKG [PKG_NAME]" - -# echo "" -# echo "Your path is `pwd`. Is this your package folder where to setup robot's bringup?" -# read -p "If so press otherwise +C and start the script again from the bringup folder." +usage="setup-robot-bringup ROBOT_NAME DESCRIPTION_PKG_NAME" # Load Framework defines script_own_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )" @@ -26,28 +22,25 @@ source $script_own_dir/../setup.bash check_and_set_ros_distro_and_version "${ROS_DISTRO}" ROBOT_NAME=$1 -if [ -z "$1" ]; then - echo "You should provide robot name!" - exit 0 +if [ -z "$ROBOT_NAME" ]; then + print_and_exit "ERROR: You should provide robot name! Nothing to do 😯" "$usage" fi DESCR_PKG_NAME=$2 -if [ -z "$2" ]; then - echo "You should provide description package name!" - exit 0 +if [ -z "$DESCR_PKG_NAME" ]; then + print_and_exit "ERROR: You should provide description package name! Nothing to do 😯" "$usage" fi -PKG_NAME=$3 -if [ -z "$3" ]; then - current=`pwd` - PKG_NAME=$(basename "$current") - echo "Package name guessed from the current path is '$PKG_NAME' is this correct? If not provide it as second parameter." +if [ ! -f "package.xml" ]; then + print_and_exit "ERROR: 'package.xml' not found. You should execute this script at the top level of your package folder. Nothing to do 😯" "$usage" fi +PKG_NAME="$(grep -Po '(?<=).*?(?=)' package.xml | sed -e 's/[[:space:]]//g')" + echo "" -echo "ATTENTION: Setting up bringup configuration for robot '$ROBOT_NAME' in package '$PKG_NAME' in folder '`pwd`'." -echo "" -read -p "If correct press , otherwise +C and start the script again from the package folder and/or with correct robot name." +echo -e "${TERMINAL_COLOR_USER_NOTICE}ATTENTION: Setting up bringup configuration for robot '$ROBOT_NAME' in package '$PKG_NAME' in folder '`pwd`' with robot description package '$DESCR_PKG_NAME'.${TERMINAL_COLOR_NC}" +echo -e "${TERMINAL_COLOR_USER_CONFIRMATION}If correct press , otherwise +C and start the script again from the package folder and/or with correct robot name.${TERMINAL_COLOR_NC}" +read # Remove include and src folders - in this package should be no source RM_FOLDERS=("include" "src") @@ -114,10 +107,10 @@ fi # TODO: Add license checks git add . -git commit -m "RosTeamWS: Bringup files for $ROBOT_NAME generated." +# git commit -m "RosTeamWS: Bringup files for $ROBOT_NAME generated." # Compile and add new package the to the path compile_and_source_package $PKG_NAME echo "" -echo "FINISHED: You can test the configuration by executing 'ros2 launch $PKG_NAME test_${ROBOT_NAME}_bringup.launch.py'" +echo -e "${TERMINAL_COLOR_USER_NOTICE}FINISHED: You can test the configuration by executing 'ros2 launch $PKG_NAME test_${ROBOT_NAME}_bringup.launch.py'${TERMINAL_COLOR_NC}" diff --git a/scripts/setup-robot-description.bash b/scripts/setup-robot-description.bash index e0a3a1a4..f497aacf 100755 --- a/scripts/setup-robot-description.bash +++ b/scripts/setup-robot-description.bash @@ -16,11 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -usage="setup-robot-description.bash ROBOT_NAME [PKG_NAME]" - -# echo "" -# echo "Your path is `pwd`. Is this your package folder where to setup robot's description?" -# read -p "If so press otherwise +C and start the script again from the description folder." +usage="setup-robot-description ROBOT_NAME" # Load Framework defines script_own_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )" @@ -28,28 +24,22 @@ source $script_own_dir/../setup.bash check_and_set_ros_distro_and_version ${ROS_DISTRO} ROBOT_NAME=$1 -if [ -z "$1" ]; then - echo "You should provide robot name!" - exit 0 +if [ -z "$ROBOT_NAME" ]; then + print_and_exit "ERROR: You should provide robot name! Nothing to do 😯" "$usage" fi -PKG_NAME=$2 -if [ -z "$2" ]; then - current=$(pwd) - PKG_NAME=$(basename "$current") - user_decision "Package name guessed from the current path is '$PKG_NAME' is this correct?" - if [[ " ${negative_answers[*]} " =~ " ${user_answer} " ]]; then - print_and_exit "Please provide the package name as second parameter." - fi +if [ ! -f "package.xml" ]; then + print_and_exit "ERROR: 'package.xml' not found. You should execute this script at the top level of your package folder. Nothing to do 😯" "$usage" fi +PKG_NAME="$(grep -Po '(?<=).*?(?=)' package.xml | sed -e 's/[[:space:]]//g')" echo "" -echo "ATTENTION: Setting up description configuration for robot '$ROBOT_NAME' in package '$PKG_NAME' in folder '`pwd`'." -echo "" -read -p "If correct press , otherwise +C and start the script again from the package folder and/or with correct robot name." +echo -e "${TERMINAL_COLOR_USER_NOTICE}ATTENTION: Setting up description configuration for robot '$ROBOT_NAME' in package '$PKG_NAME' in folder '`pwd`'.${TERMINAL_COLOR_NC}" +echo -e "${TERMINAL_COLOR_USER_CONFIRMATION}If correct press , otherwise +C and start the script again from the package folder and/or with correct robot name.${TERMINAL_COLOR_NC}" +read # Create folders for meshes -F_NAME="meshes/${ROBOT_NAME}/visual" +F_NAME="meshes/${ROBOT_NAME}/collision" mkdir -p $F_NAME touch $F_NAME/.gitkeep @@ -124,4 +114,4 @@ git commit -m "RosTeamWS: Description files for $ROBOT_NAME generated." compile_and_source_package $PKG_NAME echo "" -echo "FINISHED: You can test the configuration by executing 'ros2 launch $PKG_NAME view_${ROBOT_NAME}.launch.py'" +echo -e "${TERMINAL_COLOR_USER_NOTICE}FINISHED: You can test the configuration by executing 'ros2 launch $PKG_NAME view_${ROBOT_NAME}.launch.py'${TERMINAL_COLOR_NC}"