Skip to content

Commit 39e20e0

Browse files
authored
Merge pull request #63 from ichiro-its/feature/adapt-main-to-ros2-launch
[Feature / PD-420] Adapt Tachimawari Main to Remove Ros Arguments
2 parents 399e94e + ac8029a commit 39e20e0

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

launch/tachimawari_launch.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright (c) 2024 ICHIRO ITS
2+
#
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy
4+
# of this software and associated documentation files (the "Software"), to deal
5+
# in the Software without restriction, including without limitation the rights
6+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
# copies of the Software, and to permit persons to whom the Software is
8+
# furnished to do so, subject to the following conditions:
9+
#
10+
# The above copyright notice and this permission notice shall be included in
11+
# all copies or substantial portions of the Software.
12+
#
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16+
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
# THE SOFTWARE.
20+
21+
import os
22+
import socket
23+
from launch import LaunchDescription
24+
from launch_ros.actions import Node
25+
26+
def generate_launch_description():
27+
hostname = socket.gethostname()
28+
config_path = os.path.expanduser(f'~/ros2-ws/configuration/{hostname}/ipm/')
29+
30+
return LaunchDescription([
31+
Node(
32+
package='tachimawari',
33+
executable='main',
34+
name='main',
35+
output='screen',
36+
arguments=['cm740', config_path],
37+
respawn=True,
38+
respawn_delay=1
39+
)
40+
])

src/tachimawari_main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@
2727

2828
int main(int argc, char * argv[])
2929
{
30-
rclcpp::init(argc, argv);
30+
auto args = rclcpp::init_and_remove_ros_arguments(argc, argv);
3131

32-
if (argc < 2) {
32+
if (args.size() < 2) {
3333
std::cerr << "Please specify the mode! [sdk / cm740]" << std::endl;
3434
return 0;
35-
} else if (argc < 3) {
35+
} else if (args.size() < 3) {
3636
std::cerr << "Please specify the tf configuration path" << std::endl;
3737
}
3838

39-
std::string mode = argv[1];
40-
std::string path = argv[2];
39+
std::string mode = args[1];
40+
std::string path = args[2];
4141
std::shared_ptr<tachimawari::control::ControlManager> controller;
4242

4343
if (mode == "sdk") {

0 commit comments

Comments
 (0)