Skip to content

Commit

Permalink
add app_manager_utils in jsk_common
Browse files Browse the repository at this point in the history
  • Loading branch information
knorth55 committed Apr 2, 2023
1 parent dbefb4c commit daacb55
Show file tree
Hide file tree
Showing 93 changed files with 2,706 additions and 0 deletions.
42 changes: 42 additions & 0 deletions app_manager_utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# app_manager_utils

## Dependency

- [PR2/app_manager kinetic-devel branch](https://github.com/PR2/app_manager)
- [python-dateutil >= 2.7.0](https://github.com/dateutil/dateutil)

## app_scheduler

Scheduler for `app_manager`

For detailed information, please read [app_scheduler](app_scheduler/README.md).

## app_recorder

Recorder plugin for `app_manager`

For detailed information, please read [app_recorder](app_recorder/README.md).

## app_uploader

Uploader plugin for `app_manager`

For detailed information, please read [app_uploader](app_uploader/README.md).

## app_notifier

Notifier plugin for `app_manager`

For detailed information, please read [app_notifier](app_notifier/README.md).

## app_notification_saver

Notification saver plugin for `app_manager`

For detailed information, please read [app_notification_saver](app_notification_saver/README.md).

## app_publisher

Publisher plugin for `app_manager`

For detailed information, please read [app_publisher](app_publisher/README.md).
4 changes: 4 additions & 0 deletions app_manager_utils/app_manager_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 2.8.3)
project(app_manager_utils)
find_package(catkin REQUIRED)
catkin_metapackage()
21 changes: 21 additions & 0 deletions app_manager_utils/app_manager_utils/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<package format="2">
<name>app_manager_utils</name>
<version>2.2.12</version>
<description>The app_manager_utils meta package</description>
<maintainer email="[email protected]">Shingo Kitagawa</maintainer>
<author email="[email protected]">Shingo Kitagawa</author>
<license>BSD</license>

<buildtool_depend>catkin</buildtool_depend>
<exec_depend>app_notification_saver</exec_depend>
<exec_depend>app_notifier</exec_depend>
<exec_depend>app_publisher</exec_depend>
<exec_depend>app_recorder</exec_depend>
<exec_depend>app_scheduler</exec_depend>
<exec_depend>app_uploader</exec_depend>

<export>
<metapackage />
</export>
</package>
19 changes: 19 additions & 0 deletions app_manager_utils/app_notification_saver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 2.8.3)
project(app_notification_saver)

find_package(catkin REQUIRED COMPONENTS
message_generation
rospy
)

add_service_files(
FILES SaveAppNotification.srv
)

catkin_python_setup()

generate_messages()

catkin_package(
CATKIN_DEPENDS message_runtime
)
180 changes: 180 additions & 0 deletions app_manager_utils/app_notification_saver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
# app_notification_saver

Plugins and nodes to save notification to json file and pass it to `app_notifier`

## `app_manager` plugins

### `app_notification_saver/service_notification_saver`: General notification saver plugin

This plugin saves notification via service call.

#### `plugin_args`: Plugin arguments

`None`

#### `launch_args`: Plugin launch arguments

- `json_path` : JSON path

#### Sample plugin description

```yaml
plugins:
- name: service_notification_saver
type: app_notification_saver/service_notification_saver
launch_args:
json_path: /tmp/app_notification.json
```
#### Save app notification
You can save app notification with service call.
```bash
rosservice call /service_notification_saver/save_app_notification "title: 'object recognition'
stamp:
secs: 1627467479
nsecs: 13279914
location: 'kitchen'
message: 'Dish is found'"
```
#### Clear app notification
You can also clear app notification.
```bash
rosservice call /service_notification_saver/clear_app_notification "{}"
```
### `app_notification_saver/smach_notification_saver`: SMACH notification saver plugin

This plugin saves notification via service call.

#### `plugin_args`: Plugin arguments

`None`

#### `launch_args`: Plugin launch arguments

- `json_path` : JSON path
- `smach_status_topic`: SMACH status topic name

#### Sample plugin description

```yaml
plugins:
- name: smach_notification_saver
type: app_notification_saver/smach_notification_saver
launch_args:
json_path: /tmp/app_notification.json
smach_status_topic: /server_name/smach/container_status
```

## Nodes

### `service_notification_saver_node.py`: Node for general notification saver

Save notification node via service call.

#### Services

- `~save_app_notification` (`app_notification_saver/SaveAppNotification`)

Service to save app notification to JSON.

- `~clear_app_notification` (`std_srvs/Empty`)

Service to clear app notification in JSON.

#### Parameters

- `~json_path` (`String`, default: `/tmp/app_notification.json`)

Path to json file which contains app notification

#### Sample

##### Launch service_notification_saver node

```bash
roslaunch app_notification_saver service_notification_saver.launch
```

##### Save app notification

You can save app notification with service call.

```bash
rosservice call /service_notification_saver/save_app_notification "title: 'object recognition'
stamp:
secs: 1627467479
nsecs: 13279914
location: 'kitchen'
message: 'Dish is found'"
```

##### Clear app notification

You can also clear app notification.

```bash
rosservice call /service_notification_saver/clear_app_notification "{}"
```

##### Check output JSON

The sample output of the json file is like below:

```json
{
"object recognition": [
{
"date": "2021-07-28T19:17:59",
"message": "Dish is found",
"location": "kitchen"
},
{
"date": "2021-07-28T19:18:09",
"message": "Cup is found",
"location": "kitchen"
}
],
"navigation failure": [
{
"date": "2021-07-28T19:18:29",
"message": "Stucked in front of the chair",
"location": "living room"
}
]
}
```

### `smach_notification_saver_node.py`: Node for SMACH notification saver

Save notification of smach state.

#### Subscribe topics

- `~smach/container_status` (`smach_msgs/SmachContainerStatus`, default: `/server_name/smach/container_status`)

Smach status topic

#### Parameters

- `~json_path` (`String`, default: `/tmp/app_notification.json`)

Path to json file which contains app notification

#### Sample

##### Launch smach_notification_saver node

```bash
# Launch only smach_notification_saver node
roslaunch app_notification_saver smach_notification_saver.launch
# Sample
# Launch smach_notification_saver node and rosbag
roslaunch app_notification_saver sample_smach_notification_saver.launch --screen
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- name: app_notification_saver/service_notification_saver
launch: app_notification_saver/service_notification_saver.launch
module: null
- name: app_notification_saver/smach_notification_saver
launch: app_notification_saver/smach_notification_saver.launch
module: null
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<launch>
<!-- start: arguments -->
<arg name="json_path" default="/tmp/app_notification.json" />
<!-- end: arguments -->

<node name="service_notification_saver" pkg="app_notification_saver"
type="service_notification_saver_node.py">
<rosparam subst_value="true">
json_path: $(arg json_path)
</rosparam>
</node>
</launch>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<launch>
<!-- start: arguments -->
<arg name="json_path" default="/tmp/app_notification.json" />
<arg name="smach_status_topic" default="/server_name/smach/container_status" />
<!-- end: arguments -->

<node name="smach_notification_saver" pkg="app_notification_saver"
type="smach_notification_saver_node.py" >
<remap from="~smach/container_status" to="$(arg smach_status_topic)" />
<rosparam subst_value="true">
json_path: $(arg json_path)
</rosparam>
</node>
</launch>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python

import rospy

from app_notification_saver import ServiceNotificationSaver


if __name__ == '__main__':
rospy.init_node('service_notification_saver_node')
ServiceNotificationSaver()
rospy.spin()
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python

import rospy

from app_notification_saver import SmachNotificationSaver

if __name__ == '__main__':
rospy.init_node('smach_notification_saver_node')
SmachNotificationSaver()
rospy.spin()
24 changes: 24 additions & 0 deletions app_manager_utils/app_notification_saver/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<package format="3">
<name>app_notification_saver</name>
<version>2.2.12</version>
<description>The app_notification_saver package</description>

<maintainer email="[email protected]">Shingo Kitagawa</maintainer>
<author email="[email protected]">Naoya Yamaguchi</author>
<license>BSD</license>

<buildtool_depend>catkin</buildtool_depend>
<buildtool_depend condition="$ROS_PYTHON_VERSION == 2">python-setuptools</buildtool_depend>
<buildtool_depend condition="$ROS_PYTHON_VERSION == 3">python3-setuptools</buildtool_depend>

<build_depend>message_generation</build_depend>
<exec_depend>app_manager</exec_depend>
<exec_depend>message_runtime</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>smach_msgs</exec_depend>

<export>
<app_manager plugin="${prefix}/app_notification_saver_plugin.yaml" />
</export>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<launch>
<node name="rosbag_play" pkg="rosbag" type="play"
args="$(find app_notification_saver)/data/smach.bag --clock"
output="screen" required="true" />

<include file="$(find app_notification_saver)/launch/smach_notification_saver.launch" >
<arg name="smach_status_topic" value="/server_name/smach/container_status" />
</include>
</launch>
11 changes: 11 additions & 0 deletions app_manager_utils/app_notification_saver/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from catkin_pkg.python_setup import generate_distutils_setup
from setuptools import find_packages
from setuptools import setup


d = generate_distutils_setup(
packages=find_packages('src'),
package_dir={'': 'src'},
)

setup(**d)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from app_notification_saver.app_notification_saver_base import AppNotificationSaver # NOQA
from app_notification_saver.service_notification_saver import ServiceNotificationSaver # NOQA
from app_notification_saver.smach_notification_saver import SmachNotificationSaver # NOQA
Loading

0 comments on commit daacb55

Please sign in to comment.