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 6 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 @@
# consai2_sender
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ついでに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 -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

末尾の-->の削除をお願いします

- 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
3 changes: 3 additions & 0 deletions consai2r2_sender/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
<license>MIT</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>python_cmake_module</buildtool_depend>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python_cmake_moduleは必要ですか?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要なので,削除する方向で修正します.ありがとうございます.


<depend>rclcpp</depend>
<depend>std_msgs</depend>
<depend>consai2r2_msgs</depend>
<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
9 changes: 3 additions & 6 deletions consai2r2_sender/src/sim_sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "grSim_Replacement.pb.h"

using std::placeholders::_1;
using namespace std::chrono_literals;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chrono_literalsは将来的に使うから追加したのでしょうか?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こちらに関しては,同期パラメータクライアントが必要だと思いこんでいた際にパラメータ取得待ちのため追加したものでした.
現在は不要なので削除しようと思います.


namespace asio = boost::asio;

Expand Down Expand Up @@ -63,14 +64,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