Skip to content

Commit 96beb50

Browse files
committed
Modify socket import
1 parent a3915f6 commit 96beb50

File tree

8 files changed

+54
-17
lines changed

8 files changed

+54
-17
lines changed

content/introduction.ipynb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
"# Introduction"
88
]
99
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": null,
13+
"metadata": {},
14+
"outputs": [],
15+
"source": [
16+
"%pip install ipynao==0.1.1"
17+
]
18+
},
1019
{
1120
"cell_type": "code",
1221
"execution_count": null,
@@ -36,7 +45,7 @@
3645
},
3746
"outputs": [],
3847
"source": [
39-
"w.connect()"
48+
"w.connect(\"nao.local\", port=\"80\")"
4049
]
4150
},
4251
{
@@ -184,7 +193,7 @@
184193
"name": "python",
185194
"nbconvert_exporter": "python",
186195
"pygments_lexer": "ipython3",
187-
"version": "3.11.3"
196+
"version": "3.11.4"
188197
}
189198
},
190199
"nbformat": 4,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
/*!
2+
* socket.io-node
3+
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
4+
* MIT Licensed
5+
*/
6+
17
/*! Socket.IO.js build:0.9.17, development. Copyright(c) 2011 LearnBoost <dev@learnboost.com> MIT Licensed */

examples/introduction.ipynb

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,27 @@
99
},
1010
{
1111
"cell_type": "code",
12-
"execution_count": null,
12+
"execution_count": 1,
1313
"metadata": {
1414
"tags": []
1515
},
16-
"outputs": [],
16+
"outputs": [
17+
{
18+
"data": {
19+
"application/vnd.jupyter.widget-view+json": {
20+
"model_id": "cd58f8dba0e641c1b849c4aa111ab0d3",
21+
"version_major": 2,
22+
"version_minor": 0
23+
},
24+
"text/plain": [
25+
"NaoRobotWidget()"
26+
]
27+
},
28+
"execution_count": 1,
29+
"metadata": {},
30+
"output_type": "execute_result"
31+
}
32+
],
1733
"source": [
1834
"import ipynao\n",
1935
"\n",
@@ -30,7 +46,7 @@
3046
},
3147
{
3248
"cell_type": "code",
33-
"execution_count": null,
49+
"execution_count": 2,
3450
"metadata": {
3551
"tags": []
3652
},
@@ -184,7 +200,7 @@
184200
"name": "python",
185201
"nbconvert_exporter": "python",
186202
"pygments_lexer": "ipython3",
187-
"version": "3.11.3"
203+
"version": "3.11.4"
188204
}
189205
},
190206
"nbformat": 4,

ipynao/nao_robot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ async def go_sleep(self, tSeconds=2):
8383
return self.wait_for_change("synco")
8484

8585

86-
def connect(self, ip_address="nao.local"):
86+
def connect(self, ip_address="nao.local", port="80"):
8787
data = {}
8888
data["command"] = str("connect")
8989
data["ipAddress"] = str(ip_address)
90+
data["port"] = str(port)
9091
self.send(data)
9192

9293

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ipynao",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "A widget library for controlling Nao",
55
"keywords": [
66
"jupyter",
@@ -51,7 +51,7 @@
5151
},
5252
"dependencies": {
5353
"@jupyter-widgets/base": "^1.1.10 || ^2 || ^3 || ^4 || ^5 || ^6",
54-
"nao-socket.io": "^1.0.2"
54+
"nao-socket.io": "1.0.3"
5555
},
5656
"devDependencies": {
5757
"@babel/core": "^7.5.0",

src/nao-socket.io.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module 'nao-socket.io';

src/qimessaging.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,23 @@
66
** - Laurent LEC <llec@aldebaran-robotics.com>
77
**
88
*/
9-
import { io } from "nao-socket.io";
9+
import io from "nao-socket.io";
1010

1111
export class QiSession {
1212
connected: Boolean = false;
1313
disconnected: any;
1414
host: any;
1515
service: any;
1616

17-
constructor(ipAddress: any = "nao.local") {
18-
// console.log("DBG Emile qim about to connect w/17"); REMOVE
17+
constructor(ipAddress: string = "nao.local", port: string = "80") {
18+
console.log("DBG Emile qim about to connect w/17");
19+
// @ts-ignore
20+
window["oioi"] = io;
1921
let _socket = io.connect(
20-
"nao:nao@" + ipAddress + ":80",
22+
"nao:nao@" + ipAddress + ":" + port,
2123
{ resource: "libs/qimessaging/2/socket.io",
2224
'force new connection': true });
23-
// console.log("DBG Emile qim connecting.."); REMOVE
25+
// console.log("DBG Emile qim connecting..");
2426
let _dfd = new Array();
2527
let _sigs = new Array();
2628
let _idm = 0;

src/widget.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ export class NaoRobotModel extends DOMWidgetModel {
4848
this.save_changes();
4949
}
5050

51-
async connect(ipAddress: any) {
51+
async connect(ipAddress: string, port: string) {
5252
console.log("REMOVE the command was to connect");
5353
this.changeStatus("Establishing connection");
5454

55-
this.qiSession = new QiSession(ipAddress);
55+
this.qiSession = new QiSession(ipAddress, port);
5656

5757
this.connected = "Connected";
5858
this.set("connected", "Connected");
@@ -114,7 +114,9 @@ export class NaoRobotModel extends DOMWidgetModel {
114114

115115
switch (cmd) {
116116
case "connect":
117-
await this.connect(commandData["ipAddress"]);
117+
await this.connect(
118+
commandData["ipAddress"],
119+
commandData["port"]);
118120
break;
119121

120122
case "disconnect":

0 commit comments

Comments
 (0)