Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
62 changes: 62 additions & 0 deletions BuildInstructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,68 @@ ros2 run waybionic_teleop mks_drive_sim --interface socketcan --channel vcan0
In a second terminal, launch with `drive_interface:=socketcan drive_channel:=vcan0`
and zero as above. CI runs `waybionic_teleop/test/test_can_drives.py` over `vcan0`.

## Doctor View Camera

Until the doctor's camera is chosen, a USB webcam stands in for it. `camera_bridge`
captures the webcam on the computer it is plugged into and sends JPEG frames to the
ground station, each stamped with its capture time. The ground station publishes
them on `/doctor_view/left/image_raw/compressed` with `/doctor_view/left/camera_info`.
The diagnostics panel's `camera.doctor_view` entry shows the frame rate and the delay
from capture to arrival: mean, minimum, maximum and jitter.

**Windows (Docker):** first install OpenCV for the bridge with
`python -m pip install opencv-python`. Python 3.13 or newer is recommended for the
bridge: on Windows, older versions read the clock in 15.6 ms steps, which can add up
to 15.6 ms to the measured delay. Then start the ground station with the camera
port, from the repository root:

```powershell
& "$env:LOCALAPPDATA\Programs\DockerDesktop\resources\bin\docker.exe" compose run --rm --build -p 127.0.0.1:47310:47310 wslg ros2 launch waybionic_bringup ground_station.launch.py camera:=true camera_bind:=0.0.0.0
```

In a second PowerShell window, start the bridge from the repository root:

```powershell
cd waybionic_camera
python -m waybionic_camera.camera_bridge
```

Finally, tick **Doctor View** in RViz's Displays panel.

**Bridge options:**

- `--camera 1` uses another camera.
- `--width 1280 --height 720` changes the resolution.
- On Windows, `--backend dshow` often opens a webcam faster.

**Linux (native ROS):** run
`ros2 launch waybionic_bringup ground_station.launch.py camera:=true`. Then, from
`waybionic_camera`, run `python3 -m waybionic_camera.camera_bridge`; it needs
`python3-opencv`.

**Measuring the delay.**

- **What the reported delay covers:** from when OpenCV hands the bridge a frame to
when the frame reaches ROS. It leaves out the time spent inside the camera and on
the display.
- **Full delay:** point the camera at a millisecond stopwatch on the same screen as
RViz, then compare the live stopwatch with the one in the Doctor View.
- **Logging each frame:** add `camera_log:=` with a CSV path to the launch command to
log every frame's capture time, arrival time and delay. `frame` counts the frames
that arrived, so a dropped frame shows as a longer gap in `captured_s`. With native
ROS, any path works, such as `camera_log:=/tmp/camera.csv`. In Docker, `--rm`
deletes the container and its files when it stops, so log to a Windows folder
mounted into the container instead. This writes `camera.csv` to `camera-logs` in
your user folder:

```powershell
& "$env:LOCALAPPDATA\Programs\DockerDesktop\resources\bin\docker.exe" compose run --rm --build -p 127.0.0.1:47310:47310 -v "$HOME\camera-logs:/camera-logs" wslg ros2 launch waybionic_bringup ground_station.launch.py camera:=true camera_bind:=0.0.0.0 camera_log:=/camera-logs/camera.csv
```

- **Clocks:** the bridge stamps frames with the camera computer's clock, so the two
clocks must agree. Docker Desktop keeps them within a few milliseconds. If the
delay looks negative or keeps growing after the PC sleeps, restart Docker Desktop.

## Native Ubuntu Setup for RViz

Only follow this section if you need ROS and RViz outside the container. It is
Expand Down
37 changes: 32 additions & 5 deletions waybionic_bringup/launch/ground_station.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, OpaqueFunction
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, OpaqueFunction
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import (
AndSubstitution, Command, EqualsSubstitution, LaunchConfiguration, NotSubstitution,
OrSubstitution)
Expand Down Expand Up @@ -99,6 +100,18 @@ def generate_launch_description():
'use_sim_time', default_value='false',
description='Use simulation time')

camera_arg = DeclareLaunchArgument(
'camera', default_value='false',
description='Show the doctor view sent by camera_bridge and report its delay')

camera_bind_arg = DeclareLaunchArgument(
'camera_bind', default_value='127.0.0.1',
description='Address the camera receiver listens on (0.0.0.0 inside Docker)')

camera_log_arg = DeclareLaunchArgument(
'camera_log', default_value='',
description='CSV file for each camera frame: capture time, arrival time and delay')

launch_rviz_arg = DeclareLaunchArgument(
'launch_rviz', default_value='true',
description='Launch RViz (set false for headless validation)')
Expand Down Expand Up @@ -203,15 +216,28 @@ def generate_launch_description():
]
)

# Demo mode and teleop report on /diagnostics, so the panel listens to live diagnostics.
camera = LaunchConfiguration('camera')
camera_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(
get_package_share_directory('waybionic_camera'), 'launch', 'camera.launch.py')),
condition=IfCondition(camera),
launch_arguments={
'bind_address': LaunchConfiguration('camera_bind'),
'log_csv': LaunchConfiguration('camera_log'),
'diagnostics_topic': LaunchConfiguration('diagnostics_topic'),
}.items()
)

# Demo mode, teleop and the camera report on /diagnostics, so the panel listens to them.
rviz_node = Node(
package='rviz2', executable='rviz2', name='rviz2', output='screen',
arguments=['-d', LaunchConfiguration('rvizconfig')],
condition=IfCondition(LaunchConfiguration('launch_rviz')),
parameters=[
{'use_sim_time': LaunchConfiguration('use_sim_time')},
{'use_mock_diagnostics': AndSubstitution(
LaunchConfiguration('use_mock_diagnostics'), NotSubstitution(simulated_joints))},
LaunchConfiguration('use_mock_diagnostics'),
NotSubstitution(OrSubstitution(simulated_joints, camera)))},
{'diagnostics_topic': LaunchConfiguration('diagnostics_topic')}
]
)
Expand All @@ -220,8 +246,9 @@ def generate_launch_description():
model_arg, use_mock_diag_arg, diag_topic_arg, start_temp_pub_arg,
use_jsp_gui_arg, demo_mode_arg, demo_speed_arg, teleop_arg, drive_interface_arg,
drive_channel_arg, joy_source_arg,
joy_udp_bind_arg, joy_udp_port_arg, follow_camera_arg, use_sim_time_arg,
joy_udp_bind_arg, joy_udp_port_arg, follow_camera_arg, use_sim_time_arg, camera_arg,
camera_bind_arg, camera_log_arg,
launch_rviz_arg, rviz_config_arg, file_check, rsp_node, jsp_gui_node, joint_demo_node,
joy_node, joy_udp_node, teleop_node, drives_node, camera_follower_node,
temp_diag_pub_node, rviz_node
temp_diag_pub_node, camera_launch, rviz_node
])
1 change: 1 addition & 0 deletions waybionic_bringup/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<exec_depend>tf2_ros_py</exec_depend>
<exec_depend>joy</exec_depend>
<exec_depend>waybionic_teleop</exec_depend>
<exec_depend>waybionic_camera</exec_depend>

<test_depend>ament_cmake_ros</test_depend>
<test_depend>ament_lint_auto</test_depend>
Expand Down
14 changes: 14 additions & 0 deletions waybionic_bringup/rviz/waybionic_unified.rviz
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ Visualization Manager:
Reliability Policy: Reliable
Value: /waybionic/teleop/markers
Value: true
- Class: rviz_default_plugins/Image
Enabled: false
Max Value: 1
Median window: 5
Min Value: 0
Name: Doctor View
Normalize Range: true
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Best Effort
Value: /doctor_view/left/image_raw/compressed
Comment thread
yassinsolim marked this conversation as resolved.
Resolved
Value: false
Enabled: true
Global Options:
Background Color: 48; 48; 48
Expand Down
35 changes: 35 additions & 0 deletions waybionic_camera/launch/camera.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from launch_ros.parameter_descriptions import ParameterValue


def generate_launch_description():
return LaunchDescription([
DeclareLaunchArgument(
'bind_address', default_value='127.0.0.1',
description='Address camera_receiver listens on (0.0.0.0 inside Docker)'),
DeclareLaunchArgument(
'port', default_value='47310', description='TCP port for camera_bridge'),
DeclareLaunchArgument(
'log_csv', default_value='',
description='Log each frame: capture time, arrival time and delay (CSV path)'),
DeclareLaunchArgument(
'diagnostics_topic', default_value='/diagnostics',
description='Diagnostics topic for the frame rate and delay'),
Node(
package='waybionic_camera', executable='camera_receiver', name='camera_receiver',
output='screen',
parameters=[{
'bind_address': LaunchConfiguration('bind_address'),
'port': ParameterValue(LaunchConfiguration('port'), value_type=int),
}]),
Node(
package='waybionic_camera', executable='latency_monitor',
name='camera_latency_monitor',
parameters=[{
'log_csv': ParameterValue(LaunchConfiguration('log_csv'), value_type=str),
'diagnostics_topic': LaunchConfiguration('diagnostics_topic'),
}]),
])
25 changes: 25 additions & 0 deletions waybionic_camera/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>waybionic_camera</name>
<version>0.1.0</version>
<description>Doctor view camera feed for the ground station, with frame delay and rate monitoring.</description>
<maintainer email="solimanyassin@gmail.com">Yassin Soliman</maintainer>
<license>Apache-2.0</license>

<depend>diagnostic_msgs</depend>
<depend>rclpy</depend>
<depend>sensor_msgs</depend>

<exec_depend>compressed_image_transport</exec_depend>
<exec_depend>launch</exec_depend>
<exec_depend>launch_ros</exec_depend>

<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>python3-pytest</test_depend>

<export>
<build_type>ament_python</build_type>
</export>
</package>
Empty file.
4 changes: 4 additions & 0 deletions waybionic_camera/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[develop]
script_dir=$base/lib/waybionic_camera
[install]
install_scripts=$base/lib/waybionic_camera
32 changes: 32 additions & 0 deletions waybionic_camera/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from glob import glob
import os

from setuptools import find_packages, setup

package_name = 'waybionic_camera'

setup(
name=package_name,
version='0.1.0',
packages=find_packages(exclude=['test']),
data_files=[
('share/ament_index/resource_index/packages', ['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
(os.path.join('share', package_name, 'launch'), glob('launch/*.launch.py')),
],
install_requires=['setuptools'],
zip_safe=True,
maintainer='Yassin Soliman',
maintainer_email='solimanyassin@gmail.com',
description=(
'Doctor view camera feed for the ground station, with frame delay and rate monitoring.'
),
license='Apache-2.0',
tests_require=['pytest'],
entry_points={
'console_scripts': [
'camera_receiver = waybionic_camera.camera_receiver:main',
'latency_monitor = waybionic_camera.latency_monitor:main',
],
},
)
Loading
Loading