Skip to content

Commit 8214158

Browse files
authored
Small Fixes to WebRTC (#115)
* Make the robot browser headless * Add comments
1 parent c293b3e commit 8214158

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

feedingwebapp/src/robot/RobotVideoStreams.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ import PropTypes from 'prop-types'
66
import { ROBOT_COMPRESSED_IMG_TOPICS } from '../Pages/Constants'
77
import VideoStream from './VideoStream'
88

9+
/**
10+
* Renders all the video streams from the robot.
11+
*
12+
* NOTE: This page *must* be rendered on the robot, otherwise it will have
13+
* incredible lag.
14+
*
15+
* @param {string} webrtcURL - The URL of the webrtc signalling server.
16+
*/
917
function RobotVideoStreams(props) {
1018
console.log('Rendering RobotVideoStreams', ROBOT_COMPRESSED_IMG_TOPICS)
1119
return (

feedingwebapp/src/robot/VideoStream.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ import { useROS, subscribeToROSTopic, unsubscribeFromROSTopic } from '../ros/ros
77
import { createPeerConnection } from '../webrtc/webrtc_helpers'
88
import { REALSENSE_WIDTH, REALSENSE_HEIGHT } from '../Pages/Constants'
99

10+
/**
11+
* Renders a video stream from the robot.
12+
*
13+
* NOTE: This page *must* be rendered on the robot, otherwise it will have
14+
* incredible lag.
15+
*
16+
* @param {string} webrtcURL - The URL of the webrtc signalling server.
17+
* @param {string} topic - The topic to subscribe to.
18+
*
19+
* @returns {object} A canvas element that displays the video stream.
20+
*/
1021
function VideoStream(props) {
1122
const canvas = useRef(null)
1223
const img = useMemo(() => document.createElement('img'), [])

feedingwebapp/src/webrtc/webrtc_helpers.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
import axios from 'axios'
44

5+
/**
6+
* Creates a peer connection to the given url and topic. This is intended to work with
7+
* the server in server.js.
8+
*
9+
* @param {string} url The url of the server to connect to.
10+
* @param {string} topic The topic to subscribe to.
11+
* @param {function} onTrackAdded The callback function to call when a track is added.
12+
* @param {function} onConnectionEnd The callback function to call when the connection ends.
13+
* @returns {object} The RTCPeerConnection.
14+
*/
515
export function createPeerConnection(url, topic, onTrackAdded, onConnectionEnd) {
616
try {
717
const peerConnection = new RTCPeerConnection({

feedingwebapp/start_robot_browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if (process.argv.length > 2) {
2121
///////////////////////////////////////////////
2222

2323
const browser = await chromium.launch({
24-
headless: false, // default is true
24+
headless: true, // default is true
2525
ignoreHTTPSErrors: true, // avoid ERR_CERT_COMMON_NAME_INVALID
2626
defaultViewport: null,
2727
args: [

0 commit comments

Comments
 (0)