Make choregraphe app predefined Pepper naoqi 2.5 - pepper

I have an application to host a webpage that will be the menu of the robot so I need it to be executing all the time unless my other apps are on use.
I have tried with trigger condition = 1:
Nature = Interactive: The app block other interactive apps such as face recognition and will not execute if other apps are running.
Nature = Solitary: The app is stopped when other interactive apps start (for example when a face is recognized)
The only important part of it is on the html part so maybe the approach is not correct.

I solved it by using:
Interactive nature with trigger condition as "1": makes the app run under any circumstances. (Solved in this stack overflow thread)
Setting my appplication's behavior as default: with this the app will start after every boot and it is important to mention that this is the only app (designed by me) running by default
calling the other behaviors with switch focus instead of runBehavior: by switching the focus the next behavior will run and when it finishes, it comes back to the menu.
Here is the code that I used (it doesn't work here because you need to download some software before):
var session = new QiSession(function(session) {
console.log("Connection esterblished!");
}, function() {
console.log("Could not connect to the robot");
});
function open_app(behavior_name) {
session.service("ALAutonomousLife").then(function(ALAutonomousLife) {
ALAutonomousLife.switchFocus(behavior_name, 1)
}).then(
console.log('Application cannot be switched to')
)
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Question Page</title>
<script src="/libs/qimessaging/2/qimessaging.js"></script>
</head>
<body>
<button class="app-button" onclick="open_app('mynewapp-5d8038/.')">Open app</button>
<!-- "mynewapp-5d8038/." is the direction to the behavior you want to run, not the app-->
</body>
</html>
Hope that someone else finds this info useful.

In Choregraphe, you can set your installed behavior as "default".
The Default Behaviors are played automatically at robot startup.
Also note that trigger conditions express when an app can be run, not when it should or must.

You probably want to develop the application as a service outside of Choregraphe. General robot-jumpstarter toolkit may be useful for creating a template here. You may look at an example application creating a service and a webpage to display subtitles of what Pepper says at NLPPepperTools.

Related

understanding smil with wowza and JWplayer

I'm trying to implement the adaptive streaming for my beloved website, i'm using wowza and jwplayer. My settings are:
js:
var playerInstance = jwplayer("myElement").setup({
file: "/testjwplayer.smil",
width: 980,
height: 535,
title: 'Basic Video Embed',
description: 'A video with a basic title and description!',
});
smil:
<smil>
<head>
<meta base="rtmp://myserver/myapplication?mp4:" />
</head>
<body>
<switch>
<video src="sample_360.mp4" height="360" system-bitrate="745472" />
<video src="sample_480.mp4" height="480" system-bitrate="1155072" />
<video src="sample_720.mp4" height="720" system-bitrate="1187840" />
<video src="sample.mp4" height="1080" system-bitrate="2467840" />
</switch>
</body>
</smil>
Everything is working, the player shows all the qualities and the 'auto' quality. The things i'm not understanding is how to determinate which quality is the player invoking when the 'auto' quality is active. Checking on wowza access.log file, seems that the player always invokes the same quality (hd), even if the connection is really bad (i'm using some tools to simulate a bad connection).
Now my quastions are:
There is a way to understand what the player is doing? which quality is trying to reach?
If i did all good, why the player invokes always the same quality (hd)?
and more important: should JWplayer switch the quality in real time or just when the player is created?
Thank for the attention guys
From the jwplayer documentation:
The switching of quality is automatically done by JW Player, who selects the highest quality:
Whose system-bitrate fits the current bandwidth of the connection.
Whose width fits the current width of the player screen.
Regarding to your second question, I am afraid that when using RTMP it does not change quality during playing the stream, it only selects once at startup.

QT QWebEnginePage::setWebChannel() transport object

I'm using the QT WebEngine framework to display web pages. I'm injecting javascript into a page when it loads, and want to allow the javascript to be able to access a QT object. Apparently, to do this a QWebChannel must exist that establishes some IPC between chromium (the javascript) and the rest of my C++/QT project. I came across the QWebEnginePage::setWebChannel (QWebChannel *channel) function, however I can't find any examples of its use. The documentation (http://doc.qt.io/qt-5/qwebenginepage.html#setWebChannel) mentions that qt.webChannelTransport should be available in the javascript context, but I don't see where that is established in qwebchannel.js (https://github.com/qtproject/qtwebchannel/blob/dev/src/webchannel/qwebchannel.js). I've seen the WebChannel examples (http://doc.qt.io/qt-5/qtwebchannel-examples.html) and would like to avoid WebSockets if possible.
Below is how I tried to implement the web channel.
Whenever a page loads I establish a channel and inject the javascript in C++:
QWebChannel *channel = new QWebChannel();
channel->registerObject(QStringLiteral("jshelper"), helper);
view->page()->runJavaScript(qwebjs); //this is qwebchannel.js
view->page()->setWebChannel(channel);
view->page()->runJavaScript(myfunction); //function that calls QT object (jshelper)
In Javascript:
new QWebChannel(qt.webChannelTransport, function(channel) { ... });
Which results in the channel not being connected properly (assuming this is because of qt.webChannelTransport, as it was working when I was using WebSockets). Any pointers to examples of QWebChannel being set up with QWebEnginePage this way is also appreciated.
Short answer: add <script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"></script> to your html page (before you call new QWebChannel of course), and remove the line view->page()->runJavaScript(qwebjs); //this is qwebchannel.js from your C++ code.
Long answer:
I too had a ton of trouble figuring out how to use QWebChannel without WebSockets correctly -- managed to get it working after digging around in Qt 5.5 source code and mailing lists (documentation is still lacking). Note that this only works with the new Qt 5.5.
Here's how to use QWebChannel:
// file: MyWebEngineView.cpp, MyWebEngineView extends QWebEngineView
QWebChannel *channel = new QWebChannel(page());
// set the web channel to be used by the page
// see http://doc.qt.io/qt-5/qwebenginepage.html#setWebChannel
page()->setWebChannel(channel);
// register QObjects to be exposed to JavaScript
channel->registerObject(QStringLiteral("jshelper"), helper);
// now you can call page()->runJavaScript(...) etc
// you DON'T need to call runJavaScript with qwebchannel.js, see the html file below
// load your page
load(url);
And on the JS side:
<!-- NOTE: this is what you're missing -->
<script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"></script>
<script type="text/javascript">
<!-- it's a good idea to initialize webchannel after DOM ready, if your code is going to manipulate the DOM -->
document.addEventListener("DOMContentLoaded", function () {
new QWebChannel(qt.webChannelTransport, function (channel) {
var jshelper = channel.objects.jshelper;
// do what you gotta do
});
});
</script>
Also make sure you've added QT += webenginewidgets webchannel to your .pro file else this won't build!
Bonus: you can debug your JavaScript from the comfort of Chrome Dev Tools now! Just add this somewhere in your Qt code (ideally in your application startup):
#ifdef QT_DEBUG
qputenv("QTWEBENGINE_REMOTE_DEBUGGING", "23654");
#endif
Then start your application, navigate to http://localhost:23654 in Chrome, and you'll get a fully-functional JS debugger, profiler, console, etc :)
Follow-up (19/04/2016): if your remote debugger isn't working, note that the qputenv call must also occur before any calls to QWebEngineSettings or any other WebEngine-related class, because these trigger the WebEngine "zygote" process immediately (the zygote is the parent QtWebEngineProcess from which all future QtWebEngineProcesses are forked) and then qputenv cannot affect it. Spent a few hours tracking this down.

QtWebEngine debugging

Recently Qt introduced the QtWebEngine module. Is there a way to invoke developer tools and debug JavaScript code inside QWebEngineView? It was possible with QWebView using
page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
but I couldn't find any similar option in QWebEngineView.
I just ran across this so I added it here for posterity.
It was just added to Qt 5.5 git. You have to enable it via an environment variable QTWEBENGINE_REMOTE_DEBUGGING=<port>. You can put 0.0.0.0:<port> if you are doing debugging of an embedded device and cant use the local console. Then you can point can connect to http://127.0.0.1: to get the debugger. It will need to be a chromium based browser. Do you have to use Chrome, or you can actually use the "quick nano browser" example if you want.
Alternatively, one may embed Firebug Lite to get a JavaScript console and inspectors.
Just add
<script type="text/javascript" src="https://getfirebug.com/firebug-lite.js"></script>
into the page. Pressing F12 will visualize the Firebug console.
If your devtools view and page are in the same program,use qt function to directly navigate to page devtools instead of http://localhost:port whith is devtools index(have to select devtools of whitch page).
After QTWEBENGINE_REMOTE_DEBUGGING being set up
>=5.13:
void QWebEnginePage::setDevToolsPage(QWebEnginePage *devToolsPage)
5.11~5.12:
void QWebEnginePage::setInspectedPage(QWebEnginePage *page)
Sample pyqt5.12
dev_view = QWebEngineView() # new web view
self.page().setDevToolsPage(dev_view.page()) # self is the source web view
Reference:
https://doc.qt.io/qt-5/qwebenginepage.html#setDevToolsPage
https://doc.qt.io/qt-5/qwebenginepage.html#setInspectedPage
For PyQt5 the following snippet:
self.mainLayout = QtWidgets.QVBoxLayout()
self.webView = QtWebEngineWidgets.QWebEngineView()
self.mainLayout.addWidget(self.webView, 100)
self.webView.settings().setAttribute(QtWebEngineWidgets.QWebEngineSettings.JavascriptEnabled, True)
self.webView.settings().setAttribute(QtWebEngineWidgets.QWebEngineSettings.LocalContentCanAccessRemoteUrls, True)
self.webView.settings().setAttribute(QtWebEngineWidgets.QWebEngineSettings.ErrorPageEnabled, True)
self.webView.settings().setAttribute(QtWebEngineWidgets.QWebEngineSettings.PluginsEnabled, True)
dev_view = QtWebEngineWidgets.QWebEngineView()
self.mainLayout.addWidget(dev_view, 100)
self.webView.page().setDevToolsPage(dev_view.page())
From http://blog.qt.io/blog/2015/03/17/qt-5-5-alpha-available/:
The remote inspector can be used by either defining the env variable
QTWEBENGINE_REMOTE_DEBUGGING, or by supplying the
–remote-debugging-port command line argument. You can then point a
browser at the specified port and inspect your web content.
look this:
The Chromium DevTools provide the ability to inspect and debug layout and performance issues of any web content
https://doc.qt.io/qt-5/qtwebengine-features.html#chromium-devtools

ZURB Foundation: CDN foundation.min.js with fallback to local

I want to load a CDN version of foundation.min.js with a local fallback. The question is: How can I detect if foundation.js is loaded?
I saw it done done with jQuery, modernizr, Bootstrap ... but I can't find the code for Foundation.
It should look like this except the part "window.Foundation":
<!-- jsDelivr CDN -->
<script src="//cdn.jsdelivr.net/foundation/4.3.1/js/foundation.min.js"></script>
<!-- Fallback to local -->
<script>window.Foundation || document.write('<script src="/js/vendor/foundation.min.js"><\/script>')</script>
Ok, it turned out that my original code was actually correct. Foundation is actual JavaScript object and I had a typo somewhere else. So, to sum up ... you can load foundation.min.js from CDN with a local fallback like this:
<!-- jsDelivr CDN -->
<script src="//cdn.jsdelivr.net/foundation/4.3.1/js/foundation.min.js"></script>
<!-- Fallback to local -->
<script>window.Foundation || document.write('<script src="/js/vendor/foundation.min.js"><\/script>')</script>
If anyone is interested I've created the gist with CDN/local fallback for all Foundation required files:
gist.github.com/kevinwake/6208601
RequireJS might be one option for you.
From sections 4.6.2 and 4.6.3 at http://requirejs.org/docs/api.html#pathsfallbacks
requirejs.config({
//To get timely, correct error triggers in IE, force a define/shim exports check.
enforceDefine: true,
paths: {
jquery: [
'http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min',
//If the CDN location fails, load from this location
'lib/jquery'
]
}
});
//Later
require(['jquery'], function ($) {
});
This above code will try the CDN location, but if that fails, fall back to the local lib/jquery.js location.
Good luck!

logout not working in IPAD

Really weird think happening with my site!
I have a "welcome {{user.email}}" in the top of my base.html page! So far was working fine, but when I tested the site in a IPAD2 and Iphone4, I saw that, the login part wasnt working right!What I mean by that is, if I am logged in the welcome message has been showing, but if I logout, some pages are still showing the welcome message in the top, but if I reload the page then it works fine afterwards! It seems that JUST ipad is holding some kind of cache! is it that even possible?
Just for record I am not using cache in my django app! my settings.py file has:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}
So, I know that django is not messing things up! it is something with ipad!(client side)
does someone have a clue about it?!
EDIT
I tried already adding;
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
and
<meta http-equiv="Cache-control" content="no-cache">
no success so far though.
EDIT2:
This is happening in Safari also! but just in Safari and MAC os!! using Safari in windows works fine!
you're probably holding it wrong...
if you really think it's client side maybe you can try to add some meta tags for cache control and see if that helps.