I'm programming an App for the Aldebaran's Pepper robot. I'm using Choregraphe and I made an html page for displaying in robots tablet. I just want to activate an output (that i have to add at the "SHOW APP" box) by pressing a button in the Html page displayed on the tablet of the robot. How to do this?
Pepper: how to activate output of the box by Html/Javascript webpage
1k Views Asked by F.ar At
2
There are 2 best solutions below
0

index.html
<head>
<script src="/libs/qi/2/qi.js"></script>
<script src="js/script.js"></script>
</head>
<body>
<div class="flex">
<button class="button" onclick="launchEvent1()">First event</button>
<button class="button" onclick="launchEvent2()">Second event</button>
<button class="button" onclick="launchEvent3()">Third event</button>
<button class="home" onclick="launchEventHome()">Home button</button>
</div>
</body>
script.js
session = null
QiSession(connected, disconnected, location.host);
function connected(s) {
console.log("Session connected");
session = s;
//If you want to subscribe so some events (to send info pepper->tablet) call the function here
}
function disconnected(error) {
console.log("Session disconnected");
}
function launchEventHome(){
session.service("ALMemory").then(function (memory) {
memory.raiseEvent("homeEvent", "paramHome");
});
}
function launchEvent1(){
session.service("ALMemory").then(function (memory) {
memory.raiseEvent("event1", "param1");
});
}
function launchEvent2(){
session.service("ALMemory").then(function (memory) {
memory.raiseEvent("event2", "param2");
});
}
function launchEvent3(){
session.service("ALMemory").then(function (memory) {
memory.raiseEvent("event3", "param3");
});
}
On choregraphe, click on "add event from ALMemory" (the plus icon on the left side) and select "add new key". Give it the name you gave it on your .js file (in my case, event1, event2, event3 and homeEvent).
With that, whenever the user clicks on the button on the tablet, it will trigger the event and it will send the param as a dynamic type (param1, 2, etc. depending on which button the user pressed)
What you can do is use the Javascript SDK to raise ALMemory events, and subscribe to those in Choregraphe.
Something like this (left red box):