Skip to content
This repository has been archived by the owner on Jan 28, 2023. It is now read-only.

sender with yaml config #62

Merged
merged 7 commits into from
Jan 3, 2020
Merged
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
6 changes: 5 additions & 1 deletion consai2r2_examples/launch/joystick_example.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
Expand Down Expand Up @@ -49,7 +51,9 @@ def generate_launch_description():

start_sender_cmd = Node(
package='consai2r2_sender', node_executable='sim_sender',
output='screen'
output='screen',
parameters=[os.path.join(get_package_share_directory(
'consai2r2_sender'), 'config', 'grsim.yaml')]
)

ld = LaunchDescription()
Expand Down
1 change: 1 addition & 0 deletions consai2r2_examples/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<buildtool_depend>ament_cmake</buildtool_depend>
<exec_depend>launch_ros</exec_depend>
<exec_depend>ament_index_python</exec_depend>
<exec_depend>joy</exec_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
Expand Down
10 changes: 10 additions & 0 deletions consai2r2_sender/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ install(TARGETS sim_sender
EXPORT export_${PROJECT_NAME}
DESTINATION lib/${PROJECT_NAME})

install(DIRECTORY
config
DESTINATION share/${PROJECT_NAME}/
)

install(DIRECTORY
launch
DESTINATION share/${PROJECT_NAME}/
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
Expand Down
53 changes: 53 additions & 0 deletions consai2r2_sender/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# consai2r2_sender

ロボット(grSim)へ動作司令を送信するパッケージです。
<!-- ロボット(実機/grSim)へ動作司令を送信するパッケージです。 -->


## ノードの起動方法

次のコマンドでsenderが起動します。

```sh
ros2 launch consai2r2_sender sender.launch.py
```

<!--
## 実機 / grSim の切り替え方法

`consai2_sender/launch/sender.launch`を編集するか、
launchファイルの引数で設定できます。

```sh
# 例:実機のロボットに動作司令を送信する
roslaunch consai2_sender sender.launch sim:=false

# 例:grSimのロボットに動作司令を送信する
roslaunch consai2_sender sender.launch sim:=true
```
-->

<!--
## grSimのサーバアドレス・ポートの変更方法

`consai2_description/param/game.yaml`を編集します。
-->

<!--
## 実機送信機のデバイス・ボーレートの変更方法

`consai2_description/param/game.yaml`を編集します。

## Subsribe Topics
- sim_sender
- consai2_control/robot_commands' (consai2_msgs/RobotCommands)
- ロボットの動作司令
- real_sender
- consai2_control/robot_commands' (consai2_msgs/RobotCommands)
- ロボットの動作司令
-->

## 参考ページ
### Google proto files
- grSim
- https://github.com/RoboCup-SSL/grSim/tree/master/src/proto
4 changes: 4 additions & 0 deletions consai2r2_sender/config/grsim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
consai2r2_sim_sender:
ros__parameters:
grsim_addr: '127.0.0.1'
grsim_port: 20011
39 changes: 39 additions & 0 deletions consai2r2_sender/launch/sender.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright (c) 2019 SSL-Roots
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch_ros.actions import Node


def generate_launch_description():
start_sender_cmd = Node(
package='consai2r2_sender', node_executable='sim_sender',
output='screen',
parameters=[os.path.join(get_package_share_directory(
'consai2r2_sender'), 'config', 'grsim.yaml')]
)

ld = LaunchDescription()

ld.add_action(start_sender_cmd)

return ld
2 changes: 2 additions & 0 deletions consai2r2_sender/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<depend>protobuf-dev</depend>
<depend>boost</depend>

<exec_depend>ament_index_python</exec_depend>
<exec_depend>launch_ros</exec_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

Expand Down
8 changes: 2 additions & 6 deletions consai2r2_sender/src/sim_sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,10 @@ class SimSender : public rclcpp::Node
SimSender()
: Node("consai2r2_sim_sender")
{
std::string host;
int port;

this->declare_parameter("grsim_addr", "127.0.0.1");
this->declare_parameter("grsim_port", 20011);

this->get_parameter("grsim_addr", host);
this->get_parameter("grsim_port", port);
auto host = this->get_parameter("grsim_addr").as_string();
auto port = this->get_parameter("grsim_port").as_int();

sub_commands_ = this->create_subscription<consai2r2_msgs::msg::RobotCommands>(
"robot_commands", 10, std::bind(&SimSender::send_commands, this, std::placeholders::_1));
Expand Down