Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate ROS nodes on Windows #361

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions open-codegen/opengen/builder/optimizer_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,11 @@ def build(self):
self.__build_python_bindings()

if self.__build_config.ros_config is not None:
if self.__generate_not_build:
self.__logger.fatal(
"Do not use with_ros and with_generate_not_build_flag simultaneously")
raise ValueError(
"Unless the optimiser has been built, a ROS package cannot be generated")
ros_builder = RosBuilder(
self.__meta,
self.__build_config,
Expand Down
27 changes: 26 additions & 1 deletion open-codegen/opengen/builder/ros_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ class RosBuilder:
"""

def __init__(self, meta, build_config, solver_config):
if os.name == 'nt':
self.__logger.warning(
"You're on Windows; you will not be able to run ROS!")
self.__logger.info(
"The ROS code will be generated, but without the static library")
self.__meta = meta
self.__build_config = build_config
self.__solver_config = solver_config
Expand Down Expand Up @@ -120,7 +125,27 @@ def __copy__ros_files(self):
'target',
self.__build_config.build_mode,
lib_file_name))
shutil.copyfile(original_lib_file, target_lib_file_name)

if not os.path.exists(original_lib_file):
# No static library file (most likely, because the user is on Windows)
# otherwise an error would have been produced earlier. Windows produces
# a DLL file, however it doesn't make sense to move it to the target
# directory (extern_lib) because ROS doesn't run on Windows anyway
self.__logger.warning(
f"File {original_lib_file} not found; proceeding without")
if os.name == 'nt':
self.__logger.warning(
"File {lib_file_name} not found because you're running on Windows")
# Create a LIBRARY_MISSING_README.md file in the target directory
warning_file_name = \
os.path.abspath(os.path.join(
target_ros_dir, 'extern_lib', 'LIBRARY_MISSING_README.md'))
with open(warning_file_name, 'w') as wfh:
wfh.write(f"""WARNING!\n\n
Library file {lib_file_name} is missing. You will need to compile
on the target device and copy the library file here by yourself.""")
else:
shutil.copyfile(original_lib_file, target_lib_file_name)

# 3. --- copy msg file OptimizationParameters.msg
original_params_msg = os.path.abspath(
Expand Down
Loading