Skip to content

Commit

Permalink
Merge pull request #59 from cwruRobotics/tether-namespace
Browse files Browse the repository at this point in the history
tether namespace
  • Loading branch information
InvincibleRMC authored Nov 20, 2023
2 parents 88c5df4 + b7cc0a2 commit 20dac21
Show file tree
Hide file tree
Showing 20 changed files with 73 additions and 44 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ All packages to be installed on the pi compute module live in the `pi` directory

All packages to be installed on the float live in the `float` directory.

## Namespaces

All nodes running on the pi will be in the pi namespace.

All nodes running on the surface will be in the surface namespace.

Any topics or services communicating across will be renamed first into the tether namespace.

![Picture of rqt with namespaces](/doc/images/namespaces.png)

## Documentation Structure

Documentation will take place at 3 levels:
Expand Down
Binary file added doc/images/namespaces.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/pi/camera_streamer/launch/camera_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def generate_launch_description() -> LaunchDescription:
{"image_size": [640, 480]},
{"time_per_frame": [1, 30]}
],
remappings=[("/pi/front_cam/image_raw", "/front_cam/image_raw")],
remappings=[("/pi/front_cam/image_raw", "/tether/front_cam/image_raw")],
emulate_tty=True,
output='screen'
)
Expand All @@ -37,7 +37,7 @@ def generate_launch_description() -> LaunchDescription:
{"image_size": [640, 480]},
{"time_per_frame": [1, 30]}
],
remappings=[("/pi/bottom_cam/image_raw", "/bottom_cam/image_raw")],
remappings=[("/pi/bottom_cam/image_raw", "/tether/bottom_cam/image_raw")],
emulate_tty=True,
output='screen'
)
Expand Down
20 changes: 10 additions & 10 deletions src/pi/pi_main/launch/pi_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
def generate_launch_description() -> LaunchDescription:
NS = 'pi'
# Manipulator Controller
manip_path: str = get_package_share_directory('manipulators')

manip_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource([
os.path.join(
manip_path, 'launch', 'manip_launch.py'
)
])
)
# manip_path: str = get_package_share_directory('manipulators')
#
# manip_launch = IncludeLaunchDescription(
# PythonLaunchDescriptionSource([
# os.path.join(
# manip_path, 'launch', 'manip_launch.py'
# )
# ])
# )

# Camera Streamer
cam_path: str = get_package_share_directory('camera_streamer')
Expand Down Expand Up @@ -57,7 +57,7 @@ def generate_launch_description() -> LaunchDescription:
namespace_launch = GroupAction(
actions=[
PushRosNamespace(NS),
manip_launch,
# manip_launch,
pixhawk_launch,
cam_launch,
# realsense_launch
Expand Down
4 changes: 2 additions & 2 deletions src/pi/pixhawk_communication/launch/mavros_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def generate_launch_description() -> LaunchDescription:
{"plugin_allowlist": ["sys_status", "rc_io", "command"]},
{"fcu_url": "/dev/ttyPixhawk"}
],
remappings=[('/pi/mavros/rc/override', '/mavros/rc/override'),
('/pi/mavros/cmd/arming', '/mavros/cmd/arming')]
remappings=[('/pi/mavros/rc/override', '/tether/mavros/rc/override'),
('/pi/mavros/cmd/arming', '/tether/mavros/cmd/arming')]
)

return LaunchDescription([
Expand Down
2 changes: 1 addition & 1 deletion src/surface/gui/gui/event_nodes/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class GUIEventClient(Node):

def __init__(self, srv_type: SrvType, topic: str, signal: pyqtBoundSignal):
# Name this node with a sanitized version of the topic
self.name: str = f'client{re.sub(r"[^a-zA-Z0-9_]", "_", topic)}'
self.name: str = f'client_{re.sub(r"[^a-zA-Z0-9_]", "_", topic)}'
super().__init__(self.name, parameter_overrides=[])

self.srv_type = srv_type
Expand Down
2 changes: 1 addition & 1 deletion src/surface/gui/gui/event_nodes/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class GUIEventPublisher(Node):
def __init__(self, msg_type: MsgType, topic: str,
qos_profile: QoSProfile = qos_profile_system_default) -> None:
# Name this node with a sanitized version of the topic
name: str = f'publisher{re.sub(r"[^a-zA-Z0-9_]", "_", topic)}'
name: str = f'publisher_{re.sub(r"[^a-zA-Z0-9_]", "_", topic)}'
super().__init__(name, parameter_overrides=[])

self.publisher = self.create_publisher(msg_type, topic, qos_profile)
Expand Down
2 changes: 1 addition & 1 deletion src/surface/gui/gui/event_nodes/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, srv_type: SrvType, topic: str,
Remember to use a signal to update the GUI!
"""
# Name this node with a sanitized version of the topic
name: str = f'server{re.sub(r"[^a-zA-Z0-9_]", "_", topic)}'
name: str = f'server_{re.sub(r"[^a-zA-Z0-9_]", "_", topic)}'
super().__init__(name, parameter_overrides=[])

self.srv: Service = self.create_service(srv_type, topic, callback)
Expand Down
2 changes: 1 addition & 1 deletion src/surface/gui/gui/event_nodes/subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GUIEventSubscriber(Node):
def __init__(self, msg_type: type, topic: str, signal: pyqtBoundSignal,
qos_profile: QoSProfile = qos_profile_system_default):
# Name this node with a sanitized version of the topic
name: str = f'subscriber{re.sub(r"[^a-zA-Z0-9_]", "_", topic)}'
name: str = f'subscriber_{re.sub(r"[^a-zA-Z0-9_]", "_", topic)}'
super().__init__(name, parameter_overrides=[])

self.subscription = self.create_subscription(
Expand Down
8 changes: 4 additions & 4 deletions src/surface/gui/gui/pilot_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ def __init__(self) -> None:
layout: QHBoxLayout = QHBoxLayout()
self.setLayout(layout)

self.video_area = SwitchableVideoWidget(["/front_cam/image_raw",
"/bottom_cam/image_raw",
"/camera/color/image_raw"],
self.video_area = SwitchableVideoWidget(["front_cam/image_raw",
"bottom_cam/image_raw",
"camera/color/image_raw"],
["Front Camera",
"Bottom Camera",
"Depth Camera"],
"/camera_switch")
"camera_switch")
layout.addWidget(self.video_area, alignment=Qt.AlignmentFlag.AlignCenter)

self.arm: Arm = Arm()
Expand Down
2 changes: 1 addition & 1 deletion src/surface/gui/gui/widgets/arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self) -> None:

self.arm_client: GUIEventClient = GUIEventClient(
CommandBool,
"/mavros/cmd/arming",
"mavros/cmd/arming",
self.signal
)

Expand Down
2 changes: 1 addition & 1 deletion src/surface/gui/gui/widgets/seagrass.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self) -> None:
before_layout.addStretch()

# Bottom cam
self.bottom_cam = PauseableVideoWidget("/bottom_cam/image_raw", "Bottom Cam",
self.bottom_cam = PauseableVideoWidget("bottom_cam/image_raw", "Bottom Cam",
widget_width=640, widget_height=360)

# After layout
Expand Down
2 changes: 1 addition & 1 deletion src/surface/gui/gui/widgets/task_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self) -> None:
# self.scheduler_response_signal.connect(
# self.handle_scheduler_response)
self.task_changed_client: GUIEventClient = GUIEventClient(
TaskRequest, '/task_request', self.scheduler_response_signal)
TaskRequest, 'task_request', self.scheduler_response_signal)

# Server doesn't spin, so we init in main thread
# self.update_task_dropdown_signal.connect(self.update_task_dropdown)
Expand Down
20 changes: 15 additions & 5 deletions src/surface/gui/launch/operator_launch.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
from launch.launch_description import LaunchDescription
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from launch_ros.actions import Node, PushRosNamespace
from launch.actions import GroupAction


def generate_launch_description() -> LaunchDescription:
"""Asynchronously launches operator's gui node."""
gui_node: Node = Node(
package='gui',
executable='run_operator',
namespace='gui',
parameters=[
{'theme': LaunchConfiguration('theme', default='dark')}],
parameters=[{'theme': LaunchConfiguration('theme', default='dark')}],
remappings=[("/surface/gui/bottom_cam/image_raw", "/tether/bottom_cam/image_raw"),
("/surface/gui/task_request", "/surface/task_request"),
("/surface/gui/task_feedback", "/surface/task_feedback")
],
emulate_tty=True,
output='screen'
)

return LaunchDescription([gui_node])
namespace_launch = GroupAction(
actions=[
PushRosNamespace('gui'),
gui_node
]
)

return LaunchDescription([namespace_launch])
22 changes: 15 additions & 7 deletions src/surface/gui/launch/pilot_launch.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
from launch.actions import GroupAction
from launch.launch_description import LaunchDescription
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from launch_ros.actions import Node, PushRosNamespace


def generate_launch_description() -> LaunchDescription:
"""Asynchronously launches pilot's gui node."""
gui_node: Node = Node(
package='gui',
executable='run_pilot',
namespace='gui',
parameters=[
{'theme': LaunchConfiguration('theme', default='dark')}],
remappings=[("/surface/gui/mavros/cmd/arming", "/mavros/cmd/arming"),
("/surface/gui/camera_switch", "/surface/camera_switch")],
parameters=[{'theme': LaunchConfiguration('theme', default='dark')}],
remappings=[("/surface/gui/mavros/cmd/arming", "/tether/mavros/cmd/arming"),
("/surface/gui/camera_switch", "/surface/camera_switch"),
("/surface/gui/bottom_cam/image_raw", "/tether/bottom_cam/image_raw"),
("/surface/gui/front_cam/image_raw", "/tether/front_cam/image_raw")],
emulate_tty=True,
output='screen'
)

return LaunchDescription([gui_node])
namespace_launch = GroupAction(
actions=[
PushRosNamespace('gui'),
gui_node
]
)

return LaunchDescription([namespace_launch])
2 changes: 1 addition & 1 deletion src/surface/surface_main/launch/surface_operator_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def generate_launch_description() -> LaunchDescription:

namespace_launch = GroupAction(
actions=[
PushRosNamespace("/surface"),
PushRosNamespace("surface"),
gui_launch,
task_selector_launch,
]
Expand Down
2 changes: 1 addition & 1 deletion src/surface/surface_main/launch/surface_pilot_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def generate_launch_description() -> LaunchDescription:

namespace_launch = GroupAction(
actions=[
PushRosNamespace("/surface"),
PushRosNamespace("surface"),
gui_launch,
controller_launch,
]
Expand Down
5 changes: 3 additions & 2 deletions src/surface/task_selector/launch/task_scheduler_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ def generate_launch_description() -> LaunchDescription:
manual_control_node: Node = Node(
package='task_selector',
executable='manual_control_node',
remappings=[('/surface/manipulator_control', '/manipulator_control'),
('/surface/mavros/rc/override', '/mavros/rc/override')],
remappings=[('/surface/manipulator_control', '/tether/manipulator_control'),
('/surface/mavros/rc/override', '/tether/mavros/rc/override'),
('/tether/mavros/rc/override', '/surface/mavros/rc/override')],
emulate_tty=True,
output='screen'
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self) -> None:
)
self.rc_pub: Publisher = self.create_publisher(
OverrideRCIn,
'/mavros/rc/override',
'mavros/rc/override',
qos_profile_system_default
)
self.subscription: Subscription = self.create_subscription(
Expand Down
4 changes: 2 additions & 2 deletions src/surface/task_selector/task_selector/task_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def __init__(self) -> None:

# create service to handle requests for task switching
self.request_server = self.create_service(
TaskRequest, '/task_request', self.request_task_callback)
TaskRequest, 'task_request', self.request_task_callback)

self.feedback_server = self.create_publisher(
TaskFeedback, '/task_feedback', qos_profile_system_default)
TaskFeedback, 'task_feedback', qos_profile_system_default)

# instantiates new action clients with inputs of node,
# action type, action name
Expand Down

0 comments on commit 20dac21

Please sign in to comment.