

fix launch file
@c625b81aa5205d54241a6994ad60a49a57742e38
--- p9n_example/launch/display.launch.py
+++ p9n_example/launch/display.launch.py
... | ... | @@ -13,12 +13,24 @@ |
13 | 13 |
# limitations under the License. |
14 | 14 |
|
15 | 15 |
from launch import LaunchDescription |
16 |
-from launch_ros.actions import ComposableNodeContainer, Node |
|
16 |
+from launch.actions import DeclareLaunchArgument |
|
17 |
+from launch.substitutions import ( |
|
18 |
+ TextSubstitution, |
|
19 |
+ LaunchConfiguration, |
|
20 |
+) |
|
21 |
+ |
|
22 |
+from launch_ros.actions import ComposableNodeContainer |
|
17 | 23 |
from launch_ros.descriptions import ComposableNode |
18 | 24 |
|
19 | 25 |
|
20 | 26 |
def generate_launch_description(): |
21 | 27 |
"""Generate launch description.""" |
28 |
+ launch_args = [ |
|
29 |
+ DeclareLaunchArgument( |
|
30 |
+ 'hw_type', |
|
31 |
+ default_value=TextSubstitution(text='Dualsense') |
|
32 |
+ ) |
|
33 |
+ ] |
|
22 | 34 |
nodes = [ |
23 | 35 |
ComposableNodeContainer( |
24 | 36 |
name='joy_container', |
... | ... | @@ -31,11 +43,15 @@ |
31 | 43 |
plugin='joy::Joy', |
32 | 44 |
name='joy', |
33 | 45 |
), |
46 |
+ ComposableNode( |
|
47 |
+ package='p9n_example', |
|
48 |
+ plugin='p9n_example::DisplayNode', |
|
49 |
+ name='display_node', |
|
50 |
+ parameters=[{ |
|
51 |
+ 'hw_type': LaunchConfiguration('hw_type') |
|
52 |
+ }] |
|
53 |
+ ) |
|
34 | 54 |
]), |
35 |
- Node( |
|
36 |
- name='display_node', |
|
37 |
- package='p9n_example', |
|
38 |
- executable='display_node_exec'), |
|
39 | 55 |
] |
40 | 56 |
|
41 |
- return LaunchDescription(nodes) |
|
57 |
+ return LaunchDescription(launch_args + nodes) |
--- p9n_example/src/display_node.cpp
+++ p9n_example/src/display_node.cpp
... | ... | @@ -23,7 +23,7 @@ |
23 | 23 |
{ |
24 | 24 |
|
25 | 25 |
const std::string hw_name = this->declare_parameter<std::string>( |
26 |
- "controller_type", p9n_interface::HW_NAME::DUALSENSE); |
|
26 |
+ "hw_type", p9n_interface::HW_NAME::DUALSENSE); |
|
27 | 27 |
|
28 | 28 |
try { |
29 | 29 |
this->hw_type_ = p9n_interface::getHwType(hw_name); |
--- p9n_interface/src/p9n_interface.cpp
+++ p9n_interface/src/p9n_interface.cpp
... | ... | @@ -69,9 +69,9 @@ |
69 | 69 |
|
70 | 70 |
switch (this->HW_TYPE_) { |
71 | 71 |
case HW_TYPE::DUALSHOCK3: |
72 |
- throw std::runtime_error("Not supported yet."); |
|
72 |
+ throw std::runtime_error("DualShock3 not supported yet."); |
|
73 | 73 |
case HW_TYPE::DUALSHOCK4: |
74 |
- throw std::runtime_error("Not supported yet."); |
|
74 |
+ throw std::runtime_error("DualShock4 not supported yet."); |
|
75 | 75 |
case HW_TYPE::DUALSENSE: |
76 | 76 |
{ |
77 | 77 |
using BTN_IDX = BUTTONS_DUALSENSE; |
--- p9n_test/launch/test.launch.py
+++ p9n_test/launch/test.launch.py
... | ... | @@ -13,12 +13,24 @@ |
13 | 13 |
# limitations under the License. |
14 | 14 |
|
15 | 15 |
from launch import LaunchDescription |
16 |
+from launch.actions import DeclareLaunchArgument |
|
17 |
+from launch.substitutions import ( |
|
18 |
+ TextSubstitution, |
|
19 |
+ LaunchConfiguration, |
|
20 |
+) |
|
21 |
+ |
|
16 | 22 |
from launch_ros.actions import ComposableNodeContainer |
17 | 23 |
from launch_ros.descriptions import ComposableNode |
18 | 24 |
|
19 | 25 |
|
20 | 26 |
def generate_launch_description(): |
21 | 27 |
"""Generate launch description.""" |
28 |
+ launch_args = [ |
|
29 |
+ DeclareLaunchArgument( |
|
30 |
+ 'hw_type', |
|
31 |
+ default_value=TextSubstitution(text='Dualsense') |
|
32 |
+ ) |
|
33 |
+ ] |
|
22 | 34 |
nodes = [ |
23 | 35 |
ComposableNodeContainer( |
24 | 36 |
name='joy_container', |
... | ... | @@ -34,8 +46,11 @@ |
34 | 46 |
ComposableNode( |
35 | 47 |
package='p9n_test', |
36 | 48 |
plugin='p9n_test::PlayStationTestNode', |
37 |
- name='p9n_test' |
|
49 |
+ name='p9n_test', |
|
50 |
+ parameters=[{ |
|
51 |
+ 'hw_type': LaunchConfiguration('hw_type') |
|
52 |
+ }] |
|
38 | 53 |
), |
39 | 54 |
])] |
40 | 55 |
|
41 |
- return LaunchDescription(nodes) |
|
56 |
+ return LaunchDescription(launch_args + nodes) |
--- p9n_test/src/p9n_test_node.cpp
+++ p9n_test/src/p9n_test_node.cpp
... | ... | @@ -20,7 +20,7 @@ |
20 | 20 |
: rclcpp::Node("p9n_test_node", options) |
21 | 21 |
{ |
22 | 22 |
const std::string hw_name = this->declare_parameter<std::string>( |
23 |
- "controller_type", p9n_interface::HW_NAME::DUALSENSE); |
|
23 |
+ "hw_type", p9n_interface::HW_NAME::DUALSENSE); |
|
24 | 24 |
|
25 | 25 |
try { |
26 | 26 |
this->hw_type_ = p9n_interface::getHwType(hw_name); |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?