Skip to content

Commit

Permalink
feat: add rosbag logging api and fix document generator (autowarefoun…
Browse files Browse the repository at this point in the history
  • Loading branch information
isamu-takagi authored Mar 4, 2022
1 parent 36a43d7 commit 7decad9
Show file tree
Hide file tree
Showing 120 changed files with 80 additions and 309 deletions.
3 changes: 1 addition & 2 deletions docs/design/.pages
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
nav:
- index.md
- component-interfaces
- AD API: ad-api
- autoware-interface
- configuration-management
3 changes: 0 additions & 3 deletions docs/design/ad-api/.pages

This file was deleted.

5 changes: 0 additions & 5 deletions docs/design/ad-api/index.md

This file was deleted.

2 changes: 2 additions & 0 deletions docs/design/autoware-interface/.pages
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nav:
- Prototyping: prototyping
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# /api/external/get/rosbag_logging_mode

## Classification

- Behavior: Topic
- DataType: tier4_external_api_msgs/msg/RosbagLoggingMode

## Description

rosbag 記録モードを取得する。

| Mode | is_operation_mode |
| ------------- | ----------------- |
| 常時記録 | false |
| EM 発生時記録 | true |

## Requirement

現在設定されている「常時記録」または「EM 発生時記録」いずれかの rosbag 記録モードを提供すること。
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# /api/external/set/rosbag_logging_mode

## Classification

- Behavior: Service
- DataType: tier4_external_api_msgs/srv/SetRosbagLoggingMode

## Description

rosbag 記録モードを設定する。

| Mode | is_operation_mode |
| ------------- | ----------------- |
| 常時記録 | false |
| EM 発生時記録 | true |

## Requirement

現在の rosbag 記録モードを「常時記録」または「EM 発生時記録」いずれかに設定し、rosbag 記録の保存先および保存対象の制御を行うこと。
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@
| topic | [/api/external/set/command/remote/heartbeat](../../api/external/set/command/remote/heartbeat) | [tier4_external_api_msgs/msg/Heartbeat](../../type/tier4_external_api_msgs/msg/Heartbeat) |
| topic | [/api/external/get/command/selected/control](../../api/external/get/command/selected/control) | [tier4_external_api_msgs/msg/ControlCommandStamped](../../type/tier4_external_api_msgs/msg/ControlCommandStamped) |
| topic | [/api/external/get/command/selected/vehicle](../../api/external/get/command/selected/vehicle) | [tier4_external_api_msgs/msg/ControlCommandStamped](../../type/tier4_external_api_msgs/msg/ControlCommandStamped) |
| service | [/api/external/set/rosbag_logging_mode](../../api/external/set/rosbag_logging_mode) | [tier4_external_api_msgs/srv/SetRosbagLoggingMode](../../type/tier4_external_api_msgs/srv/SetRosbagLoggingMode) |
| topic | [/api/external/get/rosbag_logging_mode](../../api/external/get/rosbag_logging_mode) | [tier4_external_api_msgs/msg/RosbagLoggingMode](../../type/tier4_external_api_msgs/msg/RosbagLoggingMode) |
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# RosbagLoggingMode

```txt
# fields
bool is_operation_mode
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SetRosbagLoggingMode

```txt
bool is_operation_mode
---
tier4_external_api_msgs/ResponseStatus status
```
2 changes: 0 additions & 2 deletions docs/design/component-interfaces/.pages

This file was deleted.

5 changes: 0 additions & 5 deletions docs/design/component-interfaces/index.md

This file was deleted.

4 changes: 1 addition & 3 deletions docs/design/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

Under Construction

## Component interfaces

## AD API
## Autoware interfaces

## Configuration management
3 changes: 3 additions & 0 deletions tools/autoware_api_document/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<buildtool_depend>ament_cmake_auto</buildtool_depend>
<buildtool_depend>ament_cmake_python</buildtool_depend>

<exec_depend>autoware_external_api_msgs</exec_depend>
<exec_depend>tier4_external_api_msgs</exec_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

Expand Down
14 changes: 7 additions & 7 deletions tools/autoware_api_document/python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

def generate():
parser = argparse.ArgumentParser()
parser.add_argument('path', default='docs/design/ad-api/prototyping', nargs='?')
parser.add_argument('path', default='docs/design/autoware-interface/prototyping', nargs='?')
args = parser.parse_args()

target = pathlib.Path(args.path)
Expand All @@ -32,7 +32,7 @@ def generate():
groups = [
('external', 'autoware_api_document', 'resource/tier4.yaml'),
]
groups = [(data[0], list(AutowareAPI.Load(*data[1:]))) for data in groups]
groups = [(data[0], list(AutowareAPI.Load(target, *data[1:]))) for data in groups]

# create list
generate_list(target, groups)
Expand Down Expand Up @@ -77,19 +77,19 @@ def make_type_link(spec : AutowareAPI):


def generate_page(target, spec):
lines = [
text = spec.page.read_text().split('## Description')
text = text[0] if len(text) < 2 else text[1]
line = [
'# ' + spec.spec_name,
'',
'## Classification',
'',
'- Behavior: ' + spec.behavior.capitalize(),
'- DataType: ' + spec.data_type,
'',
spec.page,
'## Description',
]
path = target.joinpath(spec.spec_name.strip('/')).with_suffix('.md')
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text('\n'.join(lines) + '\n')
spec.page.write_text('\n'.join(line) + '\n\n' + text.strip() + '\n')


def generate_type(target, definition):
Expand Down
40 changes: 7 additions & 33 deletions tools/autoware_api_document/python/specification.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,6 @@ def __load_page(self, name):
path = path.joinpath(*name[1:]).with_suffix('.' + name[1])
return path.read_text().strip() if path.exists() else None

"""
def __load_page(self, name):
name = name.split('/')
if name[0] not in self.my_packages:
return None
path = pathlib.Path(get_package_share_directory(name[0]))
path = path.joinpath(*name[1:]).with_suffix('.' + name[1])
return self.__highlight(path.read_text().strip()) if path.exists() else None
def __highlight(self, text):
code = ''
for line in text.split('\n'):
match = re.match(R'^([\w/]*)(.*)$', line)
names = match.group(1).split('/')
other = match.group(2)
if names[0] in self.my_packages:
data = names.copy()
data.insert(-1, 'msg')
data = TypeDefinition.Get('/'.join(data))
line = '<a href="../../../{}">{}</a>{}'.format(data.path, '/'.join(names), other)
code += line + '\n'
return code
"""

@property
def name(self):
return self._path.split('/')[-1]
Expand All @@ -82,17 +58,15 @@ def Get(cls, name):

class AutowareAPI(object):

def __init__(self, name, data):
def __init__(self, target, name, data):
self._name = name.strip('/').split('/')
self._data = data
self._page = self.__load_page(name)
self._page = self.__load_page(target, name)
self._type = self.__load_type(data['type'])

def __load_page(self, name):
name = name.split('/')
path = pathlib.Path(get_package_share_directory('autoware_api_document'))
path = path.joinpath('resource/page', name[0], '-'.join(name[1:])).with_suffix('.md')
return path.read_text().strip() if path.exists() else None
def __load_page(self, target, name):
path = target.joinpath(self.spec_name.strip('/')).with_suffix('.md')
return path if path.exists() else None

def __load_type(self, name):
return TypeDefinition.Get(name)
Expand All @@ -118,8 +92,8 @@ def typedef(self):
return self._type

@staticmethod
def Load(package: str, path : str):
def Load(target, package: str, path : str):
package = get_package_share_directory(package)
path = pathlib.Path(package, path)
for name, data in yaml.safe_load(path.read_text()).items():
yield AutowareAPI(name, data)
yield AutowareAPI(target, name, data)

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions tools/autoware_api_document/resource/page/external/get-version.md

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 7decad9

Please sign in to comment.