Commit 367e9364 by Sebastian Stern

refs #2271

parent 2d9a8957
......@@ -101,12 +101,57 @@ Das Python-Script kann über die Konsole gestartet werden. Man landet danach zun
<img src="./documentation/pics/main.gif" alt="main"/>
### Settings
Bei ersten Start wird man dazu aufgefordert einige Einstellungen anzupassen.
Diese sind unter dem Menü (5) Settings zu finden. Nach dem anpassen bzw. ergänzen der Parameter kann das Script genutzt werden.
<img src="./documentation/pics/settings.PNG" alt="settings"/>
Das Script bietet zwei Grundfunktionen.
**ros_path:**
Hier ist das root-Verzeichnis der lokalen ROS2-Installation anzugeben zB. `C:\ros2`. Wichtig bitte keine Overlays angeben.
Das Script benötigt den Pfad zur kompletten Installation.
**adtf_path:**
Diese Einstellung definiert den Pfad zur ADTF-Installation zB. `C:\adtf\3.3.1`
**adtf_plugin_install_path:**
Mit dieser Einstellung wird der Pfad definiert in den die generierten Plugins installiert werden zB. `C:\adtf_plugins`
**visual_studio_path:**
Diese Einstellung sollte den aboluten Pfad zur VisualStudio-Commandline-Batch wiederspiegeln.
Als Beispiel `"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat"`
Diese Einstellung muss nur unter Windows defniert sein.
**ros_subscriber_pkg:**
Hier wird der Name des ROS2 Paketes definiert unter dem die generierten Subscriber installiert werden.
Diese Einstellugn steht standardmäßig auf `adtf_generated_subscriber` und kann so belassen werden.
**ros_publisher_pkg:**
Hier wird der Name des ROS2 Paketes definiert unter dem die generierten Publisher installiert werden.
Diese Einstellung steht standardmäßig auf `adtf_generated_publisher` und kann so belassen werden.
**ros_msg_pkg:**
Hier wird der Name des ROS2 Paketes definiert unter dem die generierten Messages installiert werden.
Diese Einstellung steht standardmäßig auf `adtf_generated_msgs` und kann so belassen werden.
**ros_build_command:**
Mit dieser Einstellung wird das Kommando definiert mit dem die ROS2-Pakete mit dem entsprechenden ROS2-Buildsystem
gebaut und installiert werden. Hier können auch eigene Kommandos an das Buildsystem úbergeben werden.
Das Kommando `colcon build --merge-install --packages-select` nutzt zum Beispiel das Buildsystem `colcon`
mit einer Merge-Installation von ROS2. Der Befehl `--packages-select` sorgt dafür das nur das nur ein Paket gebaut wird.
Ohne diesen Befehl würden immer alle Pakete erneut gebaut und installiert.
Für das Buildsystem `ament` würde dieses Kommando `ament build --only-packages`
ein einziges Paket für eine nicht Merge-Installation bauen und installieren.
Eigene CMake-Argumente können mit dem Befehl `--cmake-args` übergeben werden zB. ` --cmake-args -DCMAKE_BUILD_TYPE=Debug`.
[ROS2 Ament](https://github.com/ros2/ros2/wiki/Ament-Tutorial)
[ROS2 Colcon](https://github.com/ros2/ros2/wiki/Colcon-Tutorial)
### Create Subscriber
......
import stat
import subprocess
import sys
from glob import glob
......@@ -49,13 +48,11 @@ class GLOBAL(ValueEnum):
XML_BUILD_DEPEND_TAG = "build_depend"
XML_EXEC_DEPEND_TAG = "exec_depend"
COGFILES_TXT = "cogfiles.txt"
VISUAL_STUDIO_CMD_BAT = "Common7\\Tools\\VsDevCmd.bat"
SETUP_BATCH = "setup.bat"
SETUP_BASH = "setup.bash"
STANDARD_BUILD_DEPENDS = ["rclcpp", "rcutils", "rmw_implementation_cmake", "rmw", "std_msgs"]
STANDARD_EXEC_DEPENDS = ["rclcpp", "rcutils", "rmw_implementation_cmake", "rmw", "rosidl_default_runtime", "std_msgs"]
MSG_BUILD_DEPENDS_IGNORE = ["ament_cmake", "rosidl_default_generators"]
SUPPORTED_ROS_BUILD_SYSTEMS = [ROS2.AMENT, ROS2.COLCON]
def close():
......@@ -852,17 +849,17 @@ def make_and_run_batch(pkg_name):
# make file
if os.name == "nt":
vs_batch = os.path.join(current_settings[SETTINGS_CONST.VISUAL_STUDIO_PATH], GLOBAL.VISUAL_STUDIO_CMD_BAT)
vs_batch = current_settings[SETTINGS_CONST.VISUAL_STUDIO_BAT]
ros_setup = os.path.join(current_settings[SETTINGS_CONST.ROS_SRC_PATH], ROS2.LOCAL_SETUP_WIN)
ros_src_dir = current_settings[SETTINGS_CONST.ROS_SRC_PATH]
ros_build_system = current_settings[SETTINGS_CONST.ROS_BUILD_SYSTEM]
content = get_batch(ros_setup, ros_src_dir, pkg_name, ros_build_system, get_build_args(ros_build_system), vs_cmd_bat=vs_batch)
ros_build_system = current_settings[SETTINGS_CONST.ROS_BUILD_COMMAND]
content = get_batch(ros_setup, ros_src_dir, ros_build_system, pkg_name, vs_cmd_bat=vs_batch)
path = os.path.join(working_dir, GLOBAL.TMP_DIR, GLOBAL.SETUP_BATCH)
else:
ros_setup = os.path.join(current_settings[SETTINGS_CONST.ROS_SRC_PATH], ROS2.LOCAL_SETUP_UNX)
ros_src_dir = current_settings[SETTINGS_CONST.ROS_SRC_PATH]
ros_build_system = current_settings[SETTINGS_CONST.ROS_BUILD_SYSTEM]
content = get_batch(ros_setup, ros_src_dir, pkg_name, ros_build_system, get_build_args(ros_build_system))
ros_build_system = current_settings[SETTINGS_CONST.ROS_BUILD_COMMAND]
content = get_batch(ros_setup, ros_src_dir, ros_build_system, pkg_name)
path = os.path.join(working_dir, GLOBAL.TMP_DIR, GLOBAL.SETUP_BASH)
try:
......@@ -1050,6 +1047,7 @@ if __name__ == "__main__":
with Settings(os.path.dirname(os.path.realpath(__file__))) as settings:
# we make the current settings and the cwd global for easy use
# we just overwrite over defined global vars at the top
globals()["current_settings"] = settings
globals()["working_dir"] = os.path.dirname(os.path.realpath(__file__))
......@@ -1080,7 +1078,7 @@ if __name__ == "__main__":
str(i + 1),
"Edit " + s,
edit_setting,
[s, lambda item: True if item in GLOBAL.SUPPORTED_ROS_BUILD_SYSTEMS else False]))
[s]))
else:
settings_submenus.append(Cli.Menu(
str(i + 1),
......@@ -1114,10 +1112,10 @@ if __name__ == "__main__":
TempFileDistributor.clean_up()
print(Fore.YELLOW + "\nPressed CTRL+C")
#except IOError:
# print(Fore.RED + "\nCould not open settings file, or settings file is corrupted")
except IOError:
print(Fore.RED + "\nCould not open settings file, or settings file is corrupted")
#except BaseException as ex:
# TempFileDistributor.clean_up()
# print(Fore.RED + "\nUnkown error")
# print(ex.args)
except BaseException as ex:
TempFileDistributor.clean_up()
print(Fore.RED + "\nUnkown error")
print(ex.args)
......@@ -16,10 +16,6 @@ class ROS2(ValueEnum):
LOCAL_SETUP_WIN = "install" + os.sep + "local_setup.bat"
LOCAL_SETUP_UNX = "install" + os.sep + "local_setup.bash"
BUILD = "build"
AMENT = "ament"
COLCON = "colcon"
AMENT_ONLY_PACKAGE = "--only-package"
COLCON_PACKAGE_SELECT = "--packages-select"
class DDL_TAGS(ValueEnum):
......
......@@ -5,26 +5,6 @@ from pathlib import Path
import xml.etree.ElementTree as Et
import re
def get_build_args(build_system: str):
"""
With given build system this function returns the corresponding args
to force a build with only the current package
:param build_system: name of the ros2 build system
:type build_system: str
:return: args to build only the current package
:rtype: str or None
"""
if build_system == ROS2.COLCON:
return ROS2.COLCON_PACKAGE_SELECT
elif build_system == ROS2.AMENT:
return ROS2.AMENT_ONLY_PACKAGE
else:
return None
def file_is_cString(file):
"""
Checks whether a the file content is likly to be encoded like a c-Style String
......
......@@ -11,20 +11,20 @@ class SETTINGS_CONST(ValueEnum):
ROS_SRC_PATH = "ros_path"
ADTF_SRC_PATH = "adtf_path"
VISUAL_STUDIO_PATH = "visual_studio_path"
VISUAL_STUDIO_BAT = "visual_studio_path"
ADTF_PLUGIN_INSTALL_PATH = "adtf_plugin_install_path"
ROS_SUBSCRIBER_PKG = "ros_subscriber_pkg"
ROS_PUBLISHER_PKG = "ros_publisher_pkg"
ROS_MSG_PKG = "ros_msg_pkg"
ROS_BUILD_SYSTEM = "ros_build_system"
ROS_BUILD_COMMAND = "ros_build_command"
INIT_SETTINGS = {ROS_SRC_PATH: "path to your ros2 workspace",
ADTF_SRC_PATH: "path to your adtf installation",
ADTF_PLUGIN_INSTALL_PATH: "path to the dir where your adtf plugins will be installed to",
VISUAL_STUDIO_PATH: "path to your visual studio installation(only for windows0)",
VISUAL_STUDIO_BAT: "path to your visual studio command line batch(only for windows)",
ROS_SUBSCRIBER_PKG: "adtf_generated_subscriber",
ROS_PUBLISHER_PKG: "adtf_generated_publisher",
ROS_MSG_PKG: "adtf_generated_msgs",
ROS_BUILD_SYSTEM: "select (ament, colcon)"}
ROS_BUILD_COMMAND: "the command with arguments to build a ros2 pkg"}
class Settings(dict, metaclass=Singleton):
......
......@@ -5,7 +5,7 @@ CONTENT_UNIX = \
cd /
. %s
cd %s
%s build %s %s
%s %s
"""
CONTENT_WIN = \
......@@ -13,11 +13,11 @@ CONTENT_WIN = \
call \"%s\"
call \"%s\"
cd /d \"%s\"
%s build %s %s
%s %s
"""
def get_batch(ros_setup, ros_src_path, ros_pkg_name, ros_build_system, ros_build_arg, vs_cmd_bat=None):
def get_batch(ros_setup, ros_src_path, ros_build_command, ros_pkg_name, vs_cmd_bat=None):
"""
With given vars this function returns the content of a batch file
......@@ -29,15 +29,13 @@ def get_batch(ros_setup, ros_src_path, ros_pkg_name, ros_build_system, ros_build
:type ros_src_path: str, pathlike
:param ros_pkg_name: name of the package to build
:type ros_pkg_name: str
:param ros_build_system: name of ros2 build system like ament, catkin, colcon
:type ros_build_system: str
:param ros_build_arg: arguments for the build system to build only one package
:type ros_build_arg: str
:param ros_build_command: name of ros2 build system like ament, catkin, colcon
:type ros_build_command: str
:return: content of bash/batch
:rtype: str
"""
if os.name == "nt":
return CONTENT_WIN % (vs_cmd_bat, ros_setup, ros_src_path, ros_build_system, ros_build_arg, ros_pkg_name)
return CONTENT_WIN % (vs_cmd_bat, ros_setup, ros_src_path, ros_build_command, ros_pkg_name)
else:
return CONTENT_UNIX % (ros_setup, ros_src_path, ros_build_system, ros_build_arg, ros_pkg_name)
return CONTENT_UNIX % (ros_setup, ros_src_path, ros_build_command, ros_pkg_name)
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