Skip to content

Commit

Permalink
Generalized IP variable
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephSaliba01 committed May 9, 2024
1 parent 73edc82 commit 75d10cb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component } from '@angular/core';
import { ViewChild, ElementRef } from '@angular/core';
import { AppConstants } from 'src/app/constants';

@Component({
selector: 'app-camera-box',
Expand All @@ -10,7 +11,7 @@ export class CameraBoxComponent {
isHovered: boolean = true;

pc: RTCPeerConnection | null = null;
host_ip: string = "127.0.0.1";
host_ip: string = AppConstants.HOST_IP;
device_id: number = 0;
error: unknown;

Expand Down
5 changes: 5 additions & 0 deletions angular_ui_app/src/app/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class AppConstants {
// public static get HOST_IP(): string { return '192.168.1.69'; }
// public static get HOST_IP(): string { return '10.122.8.160'; }
public static get HOST_IP(): string { return 'localhost'; }
}
6 changes: 2 additions & 4 deletions angular_ui_app/src/app/ros.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Injectable } from '@angular/core';
import { AppConstants } from './constants';
import * as ROSLIB from 'roslib';

@Injectable({
Expand All @@ -9,10 +10,7 @@ export class RosService {

constructor() {
this.ros = new ROSLIB.Ros({
url: 'ws://localhost:9090' //replace with your ip for port forwarding
// user ng serve --host 0.0.0.0
// works over LAN, must later be tested with an access point without wifi
// url: 'ws://10.122.8.160:9090'
url: 'ws://' + AppConstants.HOST_IP + ':9090'
});

this.ros.on('connection', () => {
Expand Down

0 comments on commit 75d10cb

Please sign in to comment.