Skip to content

Commit

Permalink
feat: add demo
Browse files Browse the repository at this point in the history
  • Loading branch information
alberto-abarzua committed Nov 17, 2023
1 parent 918dab3 commit fb8cbe6
Show file tree
Hide file tree
Showing 20 changed files with 378 additions and 288 deletions.
10 changes: 7 additions & 3 deletions frontend/src/components/armsimulation/ArmSimulation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const ArmSimulation = () => {
const [websocketPort, setWebsocketPort] = useState(0);

const simulation_url = import.meta.env.VITE_ARM_SIMULATION_URL;
const websocket_host = import.meta.env.VITE_ARM_SIMULATION_WEBSOCKET_HOST;
let websocket_host = import.meta.env.VITE_ARM_SIMULATION_WEBSOCKET_HOST;

useEffect(() => {
const getWebsocketInfo = async () => {
Expand All @@ -16,12 +16,16 @@ const ArmSimulation = () => {

console.log('this is the websocket port');
console.log(websocketPort, simulation_url, websocket_host);
}, []);
}, [simulation_url, websocketPort, websocket_host]);

const protocol = websocket_host === 'localhost' ? 'ws' : 'wss';
if (websocket_host !== 'localhost') {
websocket_host = `${websocket_host}/w${websocketPort}`;
}
return (
<div className="relative h-full w-full">
<iframe
src={`${simulation_url}/game.html?ip=${websocket_host}&port=${websocketPort}`}
src={`${simulation_url}/game.html?ip=${websocket_host}&port=${websocketPort}&protocol=${protocol}`}
className="absolute left-0 top-0 h-full w-full cursor-none border-none"
></iframe>
<div className="absolute inset-0 bg-transparent"></div>
Expand Down
2 changes: 2 additions & 0 deletions instanciator/backend/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
HOST=https://api.demo.ribot.dev
ORIGIN=https://demo.ribot.dev
1 change: 1 addition & 0 deletions instanciator/backend/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
HOST = os.environ.get('HOST', 'http://localhost')

ORIGIN = os.environ.get('ORIGIN', 'http://localhost:3000')

app = FastAPI()

app.add_middleware(
Expand Down
10 changes: 6 additions & 4 deletions instanciator/nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ server {

# Proxy requests to your FastAPI application
location / {
proxy_pass http://localhost:6000;
proxy_pass http://127.0.0.1:7400;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand All @@ -33,7 +33,7 @@ server {
location ~ ^/s(\d+)(/.*)?$ {
set $port $1;
set $path $2;
proxy_pass http://localhost:$port$path$is_args$args;
proxy_pass http://127.0.0.1:$port$path$is_args$args;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand All @@ -42,8 +42,10 @@ server {


# Proxy requests to WebSocket server
location /ws {
proxy_pass http://localhost:7000;
location ~ ^/w(\d+)(/.*)?$ {
set $port $1;
set $path $2;
proxy_pass http://127.0.0.1:$port$path$is_args$args;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
Expand Down
23 changes: 0 additions & 23 deletions instanciator/nginx/docker-compose.yaml

This file was deleted.

24 changes: 0 additions & 24 deletions instanciator/router/Dockerfile

This file was deleted.

48 changes: 0 additions & 48 deletions instanciator/router/main.cpp

This file was deleted.

9 changes: 6 additions & 3 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,15 +452,18 @@ def runserver(self, **kwargs):
use_instanciator = kwargs.get('use_instanciator', False)
if use_instanciator:
os.environ['VITE_BACKEND_URL'] = 'no_backend'

service_list = ['frontend.yaml']
else:

service_list = ['backend.yaml', 'unity_webgl_server.yaml', 'frontend.yaml']

if not esp and not use_instanciator:
service_list.append('firmware.yaml')
self.docker_manager.dc_up(service_list, env={
"ESP_CONTROLLER_SERVER_HOST": self.current_host_ip ,}, detached=detached)

if esp:
os.environ["ESP_CONTROLLER_SERVER_HOST"] = self.current_host_ip

self.docker_manager.dc_up(service_list, detached=detached)

if not detached:
self.docker_manager.dc_down(service_list)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ mergeInto(LibraryManager.library, {
const protocol = params.get("protocol");
if (protocol) {
console.log("SetWebSocketInfo: " + protocol);
return protocol;
var bufferSize = lengthBytesUTF8(protocol) + 1;
var buffer = _malloc(bufferSize);
stringToUTF8(protocol, buffer, bufferSize);
return buffer;
}
},
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_IndirectSpecularColor: {r: 0.4416632, g: 0.49055576, b: 0.570549, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
Expand Down Expand Up @@ -97,7 +97,7 @@ LightmapSettings:
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingDataAsset: {fileID: 112000000, guid: 26eea3eb254899e01ad6c00f75dd8f96, type: 2}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
Expand Down
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fb8cbe6

Please sign in to comment.