File tree Expand file tree Collapse file tree 3 files changed +79
-0
lines changed Expand file tree Collapse file tree 3 files changed +79
-0
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ def setup_launch(context: LaunchContext) -> List[Node]:
73
73
launch_description_entities .append (get_mock_wind_sensor_node_description (context ))
74
74
launch_description_entities .append (get_mock_ais_node_description (context ))
75
75
launch_description_entities .append (get_mock_gps_node_description (context ))
76
+ launch_description_entities .append (get_navigate_observer_node_description (context ))
76
77
return launch_description_entities
77
78
78
79
@@ -199,3 +200,33 @@ def get_mock_gps_node_description(context: LaunchContext) -> Node:
199
200
)
200
201
201
202
return node
203
+
204
+
205
+ def get_navigate_observer_node_description (context : LaunchContext ) -> Node :
206
+ """Gets the launch description for the navigate_observer node.
207
+
208
+ Args:
209
+ context (LaunchContext): The current launch context.
210
+
211
+ Returns:
212
+ Node: The node object that launches the navigate_observer node.
213
+ """
214
+ node_name = "navigate_observer"
215
+ mode = LaunchConfiguration ("mode" ).perform (context )
216
+ ros_parameters = [{"mode" : mode }, LaunchConfiguration ("config" ).perform (context )]
217
+ ros_arguments : List [SomeSubstitutionsType ] = [
218
+ "--log-level" ,
219
+ [f"{ node_name } :=" , LaunchConfiguration ("log_level" )],
220
+ ]
221
+
222
+ node = Node (
223
+ package = PACKAGE_NAME ,
224
+ executable = "navigate_observer" ,
225
+ name = node_name ,
226
+ output = "screen" ,
227
+ emulate_tty = True ,
228
+ parameters = ros_parameters ,
229
+ ros_arguments = ros_arguments ,
230
+ )
231
+
232
+ return node
Original file line number Diff line number Diff line change
1
+ """
2
+ This node observes the navigate node by subscribing to the local_path ROS
3
+ topic.
4
+ """
5
+
6
+ import custom_interfaces .msg as ci
7
+ import rclpy
8
+ from rclpy .node import Node
9
+
10
+
11
+ def main (args = None ):
12
+ rclpy .init (args = args )
13
+ sailbot = SailbotObserver ()
14
+
15
+ rclpy .spin (node = sailbot )
16
+
17
+ sailbot .destroy_node ()
18
+ rclpy .shutdown ()
19
+
20
+
21
+ class SailbotObserver (Node ):
22
+ """Observes the Sailbot node, through the local_path topic, as it navigates.
23
+
24
+ Subscribers:
25
+ local_path_sub (Subscription): Subscribe to a `LPathData` msg.
26
+
27
+ Attributes From Subscribers:
28
+ local_path: (ci.LPathData
29
+ """
30
+
31
+ def __init__ (self ):
32
+ super ().__init__ (node_name = "navigate_observer" )
33
+
34
+ self .local_path_sub = self .create_subscription (
35
+ msg_type = ci .LPathData ,
36
+ topic = "local_path" ,
37
+ callback = self .local_path_callback ,
38
+ qos_profile = 10 ,
39
+ )
40
+
41
+ def local_path_callback (self , msg : ci .GPS ):
42
+ self .get_logger ().debug (f"Received data from { self .local_path_sub .topic } : { msg } " )
43
+ self .local_path_data = msg
44
+
45
+
46
+ if __name__ == "__main__" :
47
+ main ()
Original file line number Diff line number Diff line change 28
28
"mock_wind_sensor = local_pathfinding.node_mock_wind_sensor:main" ,
29
29
"mock_ais = local_pathfinding.node_mock_ais:main" ,
30
30
"mock_gps = local_pathfinding.node_mock_gps:main" ,
31
+ "navigate_observer = local_pathfinding.node_navigate_observer:main" ,
31
32
],
32
33
},
33
34
)
You can’t perform that action at this time.
0 commit comments