# Magni human/robot web interface:

**URL:** <https://forum.ubiquityrobotics.com/t/magni-human-robot-web-interface/767>\
**Category:** General Questions\
**Created:** [March 26, 2021, 6:01pm UTC](https://forum.ubiquityrobotics.com/t/magni-human-robot-web-interface/767 "2021-03-26T18:01:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![EdSeymore](https://forum.ubiquityrobotics.com/letter_avatar_proxy/v4/letter/e/ecb155/32.png) [@EdSeymore](https://forum.ubiquityrobotics.com/u/EdSeymore)\
**Post date:** [March 26, 2021, 6:01pm UTC](https://forum.ubiquityrobotics.com/t/magni-human-robot-web-interface/767/1 "2021-03-26T18:01:54Z")

</div>

Has anyone developed a web based html document to display Magni status  
and control motion? I am working on an implementation to show enable/disable status, battery status and left, front, right distance and provide both keyboard and joystick motion control. I am having difficulty displaying the video image from Magni’s camera. Links to successful efforts would be appreciated.

---

<div class="post-metadata">

**Author:** ![MoffKalast](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/moffkalast/32/214_2.png) [@MoffKalast](https://forum.ubiquityrobotics.com/u/MoffKalast)\
**Post date:** [March 26, 2021, 6:47pm UTC](https://forum.ubiquityrobotics.com/t/magni-human-robot-web-interface/767/2 "2021-03-26T18:47:50Z")

</div>

Yes, we have an application like that in development. It has video streaming, robot control, telemetry, rosbag recording, rqt reconfigure and full lidar slam display and route navigation. And supports all browsers mobile/desktop. I have a [somewhat dated gazebo demo video](https://workdrive.zohoexternal.com/file/bdkeq9e99bea014994b91b55c40f7d5c2c6b6) on hand. Currently closed source for the time being though, for obvious reasons.

I can give you some tips regarding video streaming though, the easiest way to do it is to simply subscribe to the camera topic using rosbridge, but that’s pretty slow (image sent as hex string).

So the next option is using the web\_video\_server which can do http streaming which at least no longer clogs up rosbridge, but is still pretty slow with larger resolutions (image sent as jpeg).

The best option is however webrtc\_ros, which does full webrtc streaming (image sent as h264) that is fast enough to allow teleop with basically no latency over decent wifi (but takes up a fair bit of CPU on the Pi). Browser support for webrtc is a bit iffy though, so we still use the web video server as a fallback.

---

<div class="post-metadata">

**Author:** ![EdSeymore](https://forum.ubiquityrobotics.com/letter_avatar_proxy/v4/letter/e/ecb155/32.png) [@EdSeymore](https://forum.ubiquityrobotics.com/u/EdSeymore)\
**Post date:** [March 26, 2021, 8:06pm UTC](https://forum.ubiquityrobotics.com/t/magni-human-robot-web-interface/767/3 "2021-03-26T20:06:05Z")

</div>

> [@MoffKalast](#):
>
> subscribe to the camera topic using rosbridge

Thanks for the excellent reply. Hoping to get rosbridge working as a first step.

If you have the rosbridge code working perhaps you can spot my error(s).  
My setup is as follows:  
Using two systems with multiple terminal sessions:

m - Magni using Pi 4B  
u - ubuntu 18.04 on x86 chip set

- u1: roslaunch rosbridge\_server rosbridge\_websocket.launch
- m1: rosrun sonar\_detector sonar\_detector \>/dev/null 2\>&1 &
- m2: rostopic echo /system\_control
- m3: roslaunch raspicam\_node camerav2\_1280x960.launch

use the file manager to access gui.html file and then  
open to chrome on u1804  
use chrome extensions to observe results [ctrl+ shift + I]

in gui.html:

div class=“row-4”  
div class=“col-41”  
video src=“” id=“video” width=“1280” height=“960” alt=“Robot view of world”  
/div  
/div

in webui.js:

// Subscribe to video topic  
var video = new ROSLIB.Topic({  
ros : ros,  
name : ‘/raspicam\_node/image/compressed’,  
messageType : ‘sensor\_msgs/CompressedImage’  
});

video.subscribe(function(m) {  
document.getElementById(“video”).value = m.data;  
// console.log(m.format);  
});

in robot.css:

.row-4  
{  
/\*border: 2px solid black; \*/  
position: relative;  
margin-top: 20px;  
width: 12808px;  
height: 968px;  
}  
.col-41  
{  
border: 2px solid black;  
position: relative;  
margin-top: 2px;  
left: 2px;  
width: 1280px;  
height: 960px;  
}

Results:

1. all fields show correctly
2. chrome console shows no errors
3. video frame is empty
4. message to console for each video input does display [getting video traffic]
5. message to console for msgs format shows jpeg

Some characters \<\> removed to allow stmts to display in post.

Thoughts?

---

<div class="post-metadata">

**Author:** ![MoffKalast](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/moffkalast/32/214_2.png) [@MoffKalast](https://forum.ubiquityrobotics.com/u/MoffKalast)\
**Post date:** [March 27, 2021, 1:17am UTC](https://forum.ubiquityrobotics.com/t/magni-human-robot-web-interface/767/4 "2021-03-27T01:17:06Z")

</div>

> `video src="" id=“video” width=“1280” height=“960” alt=“Robot view of world”`

At first glance that might be the problem, the data you get isn’t video, it’s an image and should be fed into the img element. At least I think that’s what I remember working at the time.

Btw if you want code to display in a normal way you should put it in backticks or mark it using the preformatted text thing.

---

<div class="post-metadata">

**Author:** ![EdSeymore](https://forum.ubiquityrobotics.com/letter_avatar_proxy/v4/letter/e/ecb155/32.png) [@EdSeymore](https://forum.ubiquityrobotics.com/u/EdSeymore)\
**Post date:** [March 27, 2021, 2:26pm UTC](https://forum.ubiquityrobotics.com/t/magni-human-robot-web-interface/767/5 "2021-03-27T14:26:17Z")

</div>

**MoffKalast** , Thanks for sharing your most valuable possessions: your time and your knowledge.

---

<div class="post-metadata">

**Author:** ![EdSeymore](https://forum.ubiquityrobotics.com/letter_avatar_proxy/v4/letter/e/ecb155/32.png) [@EdSeymore](https://forum.ubiquityrobotics.com/u/EdSeymore)\
**Post date:** [March 28, 2021, 8:53pm UTC](https://forum.ubiquityrobotics.com/t/magni-human-robot-web-interface/767/6 "2021-03-28T20:53:42Z")

</div>

Made the following changes:  
in gui.html:  
\<img src="" id=“video” width=“1280” height=“960” alt=“Robot view of world”

in webui.js, replaced all with:  
robot\_IP = “magni”

// get handle for video placeholder  
video = document.getElementById(‘video’);  
// Populate video source  
video.src = “http://” + robot\_IP + “:8080/stream?topic=/raspicam\_node/image&image\_transport=compressed&type=ros\_compressed”;  
video.onload = function (m) {  
console.log("video loaded ");  
};

Added the web\_video\_server:

- m4: rosrun web\_video\_server web\_video\_server

Can now display Magni’s view of thr world.

Then modified to reduce the image size and performance is very good.
