Skip to content

Commit

Permalink
Merge pull request #17 from robotpilot/develop
Browse files Browse the repository at this point in the history
Bump to 0.3.0
  • Loading branch information
routiful authored Jan 27, 2021
2 parents c5f48b3 + 3ed37c8 commit c581c4d
Show file tree
Hide file tree
Showing 36 changed files with 565 additions and 52 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ jobs:
distribution: foxy
linter: ${{ matrix.linter }}
package-name: |
time_rclcpp_example
my_first_ros_rclcpp_pkg
my_first_ros_rclpy_pkg
msg_srv_action_interface_example
topic_service_action_rclpy_example
topic_service_action_rclcpp_example
ros2env
64 changes: 26 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,70 +23,58 @@ $ git clone https://github.com/robotpilot/ros2-seminar-examples.git
$ cd ~/robot_ws && colcon build --symlink-install
```

## Run (my_first_ros_rclpy_pkg)
## Run time_rclcpp_example package
```
$ ros2 run my_first_ros_rclpy_pkg helloworld_subscriber
$ ros2 run time_rclcpp_example time_example
```

## Run my_first_ros_rclpy_pkg package
```
$ ros2 run my_first_ros_rclpy_pkg helloworld_subscriber
$ ros2 run my_first_ros_rclpy_pkg helloworld_publisher
```

## Run (my_first_ros_rclcpp_pkg)
## Run my_first_ros_rclcpp_pkg package
```
$ ros2 run my_first_ros_rclcpp_pkg helloworld_subscriber
```

```
$ ros2 run my_first_ros_rclcpp_pkg helloworld_publisher
```

## Run (topic_service_action_rclpy_example)
### Topic Publisher (argument node)
## Run topic_service_action_rclpy_example package
```
$ ros2 run topic_service_action_rclpy_example argument
```
### Service Client (operator node)
```
$ ros2 run topic_service_action_rclpy_example operator
```
### Topic Subscriber, Service Server, Action Server (calculator node)
```
$ ros2 run topic_service_action_rclpy_example calculator
```
### Action Client (checker node)
```
$ ros2 run topic_service_action_rclpy_example checker
```
```
$ ros2 run topic_service_action_rclpy_example checker -g 100
```
### Run using launch (argument and calculator nodes)
```
$ ros2 launch topic_service_action_rclpy_example arithmetic.launch.py
```

## Run (topic_service_action_rclcpp_example)
### Topic Publisher (argument node)
## Run topic_service_action_rclcpp_example package
```
$ ros2 run topic_service_action_rclcpp_example argument
```
### Service Client (operator node)
```
$ ros2 run topic_service_action_rclcpp_example operator
```
### Topic Subscriber, Service Server, Action Server (calculator node)
```
$ ros2 run topic_service_action_rclcpp_example calculator
```
### Action Client (checker node)
```
$ ros2 run topic_service_action_rclcpp_example checker
```
```
$ ros2 run topic_service_action_rclcpp_example checker -g 100.0
```
### Run using launch (argument and calculator nodes)
```
$ ros2 launch topic_service_action_rclcpp_example arithmetic.launch.py
```

## Run ros2env package
```
$ ros2 env
usage: ros2 env [-h] Call `ros2 env <command> -h` for more detailed usage. ...
Various env related sub-commands
optional arguments:
-h, --help show this help message and exit
Commands:
list Output a list of ROS environment variables
set Set ROS environment variables
$ ros2 env list -a
ROS_VERSION = 2
ROS_DISTRO = foxy
ROS_PYTHON_VERSION = 3
ROS_DOMAIN_ID = 7
RMW_IMPLEMENTATION = rmw_fastrtps_cpp
```
3 changes: 3 additions & 0 deletions msg_srv_action_interface_example/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Changelog for package msg_srv_action_interface_example
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.3.0 (2021-01-28)
------------------

0.2.0 (2021-01-06)
------------------
* Added new ROS 2 interface package using msg, srv and action for ROS 2 seminar
Expand Down
2 changes: 1 addition & 1 deletion msg_srv_action_interface_example/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>msg_srv_action_interface_example</name>
<version>0.2.0</version>
<version>0.3.0</version>
<description>
ROS 2 example for message, service and action interface
</description>
Expand Down
3 changes: 3 additions & 0 deletions my_first_ros_rclcpp_pkg/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Changelog for package my_first_ros_rclcpp_pkg
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.3.0 (2021-01-28)
------------------

0.2.0 (2021-01-06)
------------------
* Added ROS 2 basic package using rclcpp for ROS 2 seminar
Expand Down
2 changes: 1 addition & 1 deletion my_first_ros_rclcpp_pkg/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>my_first_ros_rclcpp_pkg</name>
<version>0.2.0</version>
<version>0.3.0</version>
<description>ROS 2 rclcpp basic package for the ROS 2 seminar</description>
<maintainer email="[email protected]">Pyo</maintainer>
<license>Apache License 2.0</license>
Expand Down
3 changes: 3 additions & 0 deletions my_first_ros_rclpy_pkg/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Changelog for package my_first_ros_rclpy_pkg
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.3.0 (2021-01-28)
------------------

0.2.0 (2021-01-06)
------------------
* Added ROS 2 basic package using rclpy for ROS 2 seminar
Expand Down
2 changes: 1 addition & 1 deletion my_first_ros_rclpy_pkg/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>my_first_ros_rclpy_pkg</name>
<version>0.2.0</version>
<version>0.3.0</version>
<description>ROS 2 rclpy basic package for the ROS 2 seminar</description>
<maintainer email="[email protected]">Pyo</maintainer>
<license>Apache License 2.0</license>
Expand Down
2 changes: 1 addition & 1 deletion my_first_ros_rclpy_pkg/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name=package_name,
version='0.2.0',
version='0.3.0',
packages=find_packages(exclude=['test']),
data_files=[
('share/ament_index/resource_index/packages',
Expand Down
8 changes: 8 additions & 0 deletions ros2env/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package ros2env
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.3.0 (2021-01-28)
------------------
* Added ros2cli command and verbs for example of roc2cli
* Contributors: Pyo
20 changes: 20 additions & 0 deletions ros2env/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>ros2env</name>
<version>0.3.0</version>
<description>ROS 2 example package for the ROS 2 command line tools.</description>
<maintainer email="[email protected]">Pyo</maintainer>
<license>Apache License 2.0</license>
<author email="[email protected]">Jeremie Deray</author>
<author email="[email protected]">Pyo</author>
<author email="[email protected]">Darby Lim</author>
<depend>ros2cli</depend>
<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>ament_xmllint</test_depend>
<export>
<build_type>ament_python</build_type>
</export>
</package>
Empty file added ros2env/resource/ros2env
Empty file.
Empty file added ros2env/ros2env/__init__.py
Empty file.
48 changes: 48 additions & 0 deletions ros2env/ros2env/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2018 Open Source Robotics Foundation, Inc.
# Copyright 2019 Canonical Ldt.
# Copyright 2021 OROCA
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os


def get_ros_env_list():
ros_version = os.getenv('ROS_VERSION', 'None')
ros_distro = os.getenv('ROS_DISTRO', 'None')
ros_python_version = os.getenv('ROS_PYTHON_VERSION', 'None')
ros_env_list = 'ROS_VERSION = {0}\n\
ROS_DISTRO = {1}\n\
ROS_PYTHON_VERSION = {2}\n'.format(ros_version, ros_distro, ros_python_version)
return ros_env_list


def get_dds_env_list():
ros_domain_id = os.getenv('ROS_DOMAIN_ID', 'None')
rmw_implementation = os.getenv('RMW_IMPLEMENTATION', 'None')
dds_env_list = 'ROS_DOMAIN_ID = {0}\n\
RMW_IMPLEMENTATION = {1}\n'.format(ros_domain_id, rmw_implementation)
return dds_env_list


def get_all_env_list():
ros_env_list = get_ros_env_list()
dds_env_list = get_dds_env_list()
all_env_list = ros_env_list + dds_env_list
return all_env_list


def set_ros_env(env_name, env_value):
os.environ[env_name] = env_value
value = os.getenv(env_name, 'None')
return '{0} = {1}'.format(env_name, value)
Empty file.
40 changes: 40 additions & 0 deletions ros2env/ros2env/command/env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2018 Open Source Robotics Foundation, Inc.
# Copyright 2019 Canonical Ldt.
# Copyright 2021 OROCA
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from ros2cli.command import add_subparsers_on_demand
from ros2cli.command import CommandExtension


class EnvCommand(CommandExtension):
"""Various env related sub-commands."""

def add_arguments(self, parser, cli_name):
self._subparser = parser

# add arguments and sub-commands of verbs
add_subparsers_on_demand(
parser, cli_name, '_verb', 'ros2env.verb', required=False)

def main(self, *, parser, args):
if not hasattr(args, '_verb'):
# in case no verb was passed
self._subparser.print_help()
return 0

extension = getattr(args, '_verb')

# call the verb's main method
return extension.main(args=args)
44 changes: 44 additions & 0 deletions ros2env/ros2env/verb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2018 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from ros2cli.plugin_system import PLUGIN_SYSTEM_VERSION
from ros2cli.plugin_system import satisfies_version


class VerbExtension:
"""
The extension point for 'env' verb extensions.
The following properties must be defined:
* `NAME` (will be set to the entry point name)
The following methods must be defined:
* `main`
The following methods can be defined:
* `add_arguments`
"""

NAME = None
EXTENSION_POINT_VERSION = '0.1'

def __init__(self):
super(VerbExtension, self).__init__()
satisfies_version(PLUGIN_SYSTEM_VERSION, '^0.1')

def add_arguments(self, parser, cli_name):
pass

def main(self, *, args):
raise NotImplementedError()
44 changes: 44 additions & 0 deletions ros2env/ros2env/verb/list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2018 Open Source Robotics Foundation, Inc.
# Copyright 2019 Canonical Ldt.
# Copyright 2021 OROCA
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from ros2env.api import get_all_env_list
from ros2env.api import get_dds_env_list
from ros2env.api import get_ros_env_list
from ros2env.verb import VerbExtension


class ListVerb(VerbExtension):
"""Output a list of ROS environment variables."""

def add_arguments(self, parser, cli_name):
parser.add_argument(
'-a', '--all', action='store_true',
help='Display all environment variables.')
parser.add_argument(
'-r', '--ros-env', action='store_true',
help='Display the ROS environment variables.')
parser.add_argument(
'-d', '--dds-env', action='store_true',
help='Display the DDS environment variables.')

def main(self, *, args):
if args.ros_env:
message = get_ros_env_list()
elif args.dds_env:
message = get_dds_env_list()
else:
message = get_all_env_list()
print(message)
Loading

0 comments on commit c581c4d

Please sign in to comment.