Skip to content

Commit 1d106a8

Browse files
author
Borja Outerelo
committed
Merge branch 'developJ' into 'develop'
Develop j See merge request eProsima/micro-ros-agent!1
2 parents 7f3931f + 463dcb8 commit 1d106a8

7 files changed

Lines changed: 499 additions & 0 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright 2018 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
# Set CMake version
17+
cmake_minimum_required(VERSION 3.5)
18+
19+
20+
# Set proyect name
21+
project(micro_ros_agent)
22+
23+
24+
# Find packages depencences
25+
find_package(ament_cmake REQUIRED)
26+
find_package(fastcdr REQUIRED CONFIG)
27+
find_package(fastrtps REQUIRED CONFIG)
28+
find_package(micrortps_agent REQUIRED CONFIG)
29+
find_package(ament_cmake_python REQUIRED)
30+
31+
32+
# Export dependencies to downstream packages
33+
ament_export_dependencies(fastcdr)
34+
ament_export_dependencies(fastrtps)
35+
ament_export_dependencies(micrortps_agent)
36+
37+
38+
# Install python files
39+
ament_python_install_package(${PROJECT_NAME})
40+
41+
42+
# Register package resource in order to be called when a new msg package is generated
43+
ament_index_register_resource("rosidl_typesupport_c")
44+
45+
46+
# Install the package.xml file, and generate code for ``find_package`` so that other packages can get information about this package.
47+
ament_package(
48+
CONFIG_EXTRAS "micro_ros_agent-extras.cmake.in"
49+
)
50+
51+
52+
install(
53+
PROGRAMS bin/micro_ros_agent
54+
DESTINATION lib/micro_ros_agent
55+
)
56+
57+
install(
58+
DIRECTORY cmake resource
59+
DESTINATION share/${PROJECT_NAME}
60+
)

‎bin/micro_ros_agent‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python3
2+
3+
import argparse
4+
import os
5+
import sys
6+
7+
from rosidl_cmake import read_generator_arguments
8+
from rosidl_parser import UnknownMessageType
9+
from micro_ros_agent import generate_micro_ros_agent_xml_support
10+
11+
def is_valid_file(parser, file_name):
12+
if not os.path.exists(file_name):
13+
parser.error("File does not exist: '{0}'".format(file_name))
14+
file_name_abs = os.path.abspath(file_name)
15+
if not os.path.isfile(file_name_abs):
16+
parser.error("Path exists but is not a file: '{0}'".format(file_name_abs))
17+
return file_name
18+
19+
20+
def main(argv=sys.argv[1:]):
21+
parser = argparse.ArgumentParser(
22+
description='Generate xml files for micrortps agent.',
23+
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
24+
parser.add_argument(
25+
'--generator-arguments-file',
26+
required=True,
27+
help='The location of the file containing the generator arguments')
28+
args = parser.parse_args(argv)
29+
30+
generator_args = read_generator_arguments(args.generator_arguments_file)
31+
32+
try:
33+
rc = generate_micro_ros_agent_xml_support(generator_args)
34+
35+
return 0
36+
except UnknownMessageType as e:
37+
print(str(e), file=sys.stderr)
38+
return 1
39+
if rc:
40+
return rc
41+
return 0
42+
43+
44+
if __name__ == '__main__':
45+
sys.exit(main())
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Copyright 2016-2018 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
# list msg files
17+
set(_ros_idl_files "")
18+
foreach(_idl_file ${rosidl_generate_interfaces_IDL_FILES})
19+
get_filename_component(_extension "${_idl_file}" EXT)
20+
# Skip .srv files
21+
if(_extension STREQUAL ".msg")
22+
list(APPEND _ros_idl_files "${_idl_file}")
23+
endif()
24+
endforeach()
25+
26+
27+
# Set output dir
28+
set(_output_path "${CMAKE_CURRENT_BINARY_DIR}/../micro_ros_agent/xml_gen")
29+
30+
31+
# check if all templates exits
32+
set(target_dependencies
33+
"${micro_ros_agent_BIN}"
34+
"${micro_ros_agent_GENERATOR_FILES}"
35+
${rosidl_generate_interfaces_IDL_FILES}
36+
${_dependency_files})
37+
foreach(dep ${target_dependencies})
38+
if(NOT EXISTS "${dep}")
39+
message(FATAL_ERROR "Target dependency '${dep}' does not exist")
40+
endif()
41+
endforeach()
42+
43+
44+
# generate script argument file
45+
set(generator_arguments_file "${CMAKE_CURRENT_BINARY_DIR}/micro_ros_agent__arguments.json")
46+
rosidl_write_generator_arguments(
47+
"${generator_arguments_file}"
48+
PACKAGE_NAME "${PROJECT_NAME}"
49+
ROS_INTERFACE_FILES "${rosidl_generate_interfaces_IDL_FILES}"
50+
ROS_INTERFACE_DEPENDENCIES "${_dependencies}"
51+
OUTPUT_DIR "${_output_path}"
52+
TEMPLATE_DIR "${micro_ros_agent_DEFAULT_PROFILES_DIR}"
53+
TARGET_DEPENDENCIES ${target_dependencies}
54+
ADDITIONAL_FILES ${_dds_idl_files}
55+
)
56+
57+
58+
# Execute python script
59+
execute_process(
60+
COMMAND ${PYTHON_EXECUTABLE} ${micro_ros_agent_BIN}
61+
--generator-arguments-file "${generator_arguments_file}"
62+
)
63+
64+
65+
#Install
66+
install(
67+
DIRECTORY "${_output_path}/"
68+
DESTINATION "../micrortps_agent/bin"
69+
)

‎micro_ros_agent-extras.cmake.in‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
find_package(ament_cmake_core QUIET REQUIRED)
2+
ament_register_extension(
3+
"rosidl_generate_interfaces"
4+
"micro_ros_agent"
5+
"micrortps_agent_xml_generator.cmake")
6+
7+
set(micro_ros_agent_BIN "${micro_ros_agent_DIR}/../../../lib/micro_ros_agent/micro_ros_agent")
8+
normalize_path(micro_ros_agent_BIN "${micro_ros_agent_BIN}")
9+
10+
set(micro_ros_agent_GENERATOR_FILES "${micro_ros_agent_DIR}/../../../@PYTHON_INSTALL_DIR@/micro_ros_agent/__init__.py")
11+
normalize_path(micro_ros_agent_GENERATOR_FILES "${micro_ros_agent_GENERATOR_FILES}")
12+
13+
set(micro_ros_agent_DEFAULT_PROFILES_DIR "${micro_ros_agent_DIR}/../resource")
14+
normalize_path(micro_ros_agent_DEFAULT_PROFILES_DIR "${micro_ros_agent_DEFAULT_PROFILES_DIR}")

0 commit comments

Comments
 (0)