Skip to content

Commit a004cde

Browse files
committed
new version added
1 parent a1cc643 commit a004cde

File tree

10 files changed

+203
-64
lines changed

10 files changed

+203
-64
lines changed

ethercat_controller/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ethercat_controller"
3-
version = "0.1.0"
3+
version = "1.5.0"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

poulpe_ethercat_controller/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "poulpe_ethercat_controller"
3-
version = "0.1.0"
3+
version = "1.5.0"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

poulpe_ethercat_grpc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "poulpe_ethercat_grpc"
3-
version = "0.1.0"
3+
version = "1.5.0"
44
edition = "2021"
55
default-run = "server"
66

python_client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "python_client"
3-
version = "0.1.0"
3+
version = "1.5.0"
44
edition = "2021"
55

66

python_client/notebooks/orbita2d_test_assembly.ipynb

Lines changed: 54 additions & 24 deletions
Large diffs are not rendered by default.

python_client/notebooks/orbita3d_test_assembly.ipynb

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,41 @@
1111
"- measuign and checking the torque"
1212
]
1313
},
14+
{
15+
"cell_type": "markdown",
16+
"id": "171da5cf-f146-423a-b2bd-ea18fce28dbc",
17+
"metadata": {},
18+
"source": [
19+
"### Launch the EtherCAT sever"
20+
]
21+
},
22+
{
23+
"cell_type": "code",
24+
"execution_count": 3,
25+
"id": "1886418a-95ba-4ea5-8834-8a2c23e3effc",
26+
"metadata": {},
27+
"outputs": [
28+
{
29+
"name": "stdout",
30+
"output_type": "stream",
31+
"text": [
32+
"POULPE controller ready!\n"
33+
]
34+
}
35+
],
36+
"source": [
37+
"import python_client\n",
38+
"python_client.launch_server(\"../../config/ethercat.yaml\")"
39+
]
40+
},
41+
{
42+
"cell_type": "markdown",
43+
"id": "6ac1b151-ee00-43b9-9288-ee46652618c3",
44+
"metadata": {},
45+
"source": [
46+
"### Create teh the EtherCAT sever"
47+
]
48+
},
1449
{
1550
"cell_type": "code",
1651
"execution_count": 6,
@@ -36,22 +71,17 @@
3671
"\n",
3772
"print(client.get_connected_devices())\n",
3873
"\n",
39-
"# Use client methods\n",
74+
"## turn of the orbita\n",
75+
"client.turn_off(slave_id)\n",
76+
"# set the mode of operation to position\n",
77+
"time.sleep(0.5)\n",
78+
"client.set_mode_of_operation(slave_id, 1) # set position mode\n",
79+
"time.sleep(0.5)\n",
80+
"## turn of the orbita\n",
4081
"client.turn_on(slave_id)\n",
41-
"client.set_torque_limit(slave_id,[0.3]*n_axis)\n",
42-
"client.set_velocity_limit(slave_id, [0.3]*n_axis)"
43-
]
44-
},
45-
{
46-
"cell_type": "code",
47-
"execution_count": 7,
48-
"id": "e8bd0d86-f7ff-4ffe-9d20-9581a9cfd0bb",
49-
"metadata": {},
50-
"outputs": [],
51-
"source": [
52-
"client.set_torque_limit(slave_id,[0.3]*n_axis)\n",
53-
"client.set_velocity_limit(slave_id, [0.3]*n_axis)\n",
54-
"client.set_target_position(slave_id,[0]*n_axis)"
82+
"# set the velocity and torque limits \n",
83+
"client.set_torque_limit(slave_id,[1.0]*n_axis)\n",
84+
"client.set_velocity_limit(slave_id, [1.0]*n_axis)"
5585
]
5686
},
5787
{

python_client/notebooks/poulpe_test.ipynb

Lines changed: 81 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,64 @@
55
"id": "71753ae2-a418-4444-9e68-d2f0c0539a74",
66
"metadata": {},
77
"source": [
8-
"## Orbita2d / Orbiat3d API test example"
8+
"# Orbita2d / Orbiat3d API test example"
9+
]
10+
},
11+
{
12+
"cell_type": "markdown",
13+
"id": "1a507cef-64bd-4135-a449-ece16084c17b",
14+
"metadata": {},
15+
"source": [
16+
"### Launch the EtherCAT sever"
917
]
1018
},
1119
{
1220
"cell_type": "code",
13-
"execution_count": 29,
21+
"execution_count": 3,
22+
"id": "45a55cd9-9ed1-43c7-9f18-63b4499ece82",
23+
"metadata": {},
24+
"outputs": [
25+
{
26+
"name": "stdout",
27+
"output_type": "stream",
28+
"text": [
29+
"POULPE controller ready!\n"
30+
]
31+
}
32+
],
33+
"source": [
34+
"import python_client\n",
35+
"python_client.launch_server(\"../../config/ethercat.yaml\")"
36+
]
37+
},
38+
{
39+
"cell_type": "markdown",
40+
"id": "c6da6096-631d-41ba-a0b2-5c56807b6392",
41+
"metadata": {},
42+
"source": [
43+
"### Create teh the EtherCAT sever"
44+
]
45+
},
46+
{
47+
"cell_type": "code",
48+
"execution_count": 4,
1449
"id": "c69edec1-3871-44d0-a104-73a40eebb4ee",
1550
"metadata": {},
1651
"outputs": [
1752
{
1853
"name": "stdout",
1954
"output_type": "stream",
2055
"text": [
21-
"Connecting to slave 1\n",
22-
"Connected to slaves | ids: [1] , names: ['RightWristOrbita3d']\n"
56+
"Connecting to slave 0\n",
57+
"Connected to slaves | ids: [0] , names: ['RightShoulderOrbita2d']\n"
2358
]
2459
}
2560
],
2661
"source": [
2762
"from python_client import PyPoulpeRemoteClient\n",
2863
"import time\n",
2964
"\n",
30-
"slave_id = 1\n",
65+
"slave_id = 0\n",
3166
"n_axis = 3 # 2 or 3 make sure to set it!!!!!\n",
3267
"\n",
3368
"print(\"Connecting to slave {}\".format(slave_id))\n",
@@ -60,7 +95,7 @@
6095
},
6196
{
6297
"cell_type": "code",
63-
"execution_count": 26,
98+
"execution_count": 2,
6499
"id": "b4098313-37a0-4a8c-98d3-0f79ee32779c",
65100
"metadata": {},
66101
"outputs": [
@@ -69,8 +104,7 @@
69104
"output_type": "stream",
70105
"text": [
71106
"Devices connected in the network: \n",
72-
"Slave 1: RightWristOrbita3d\n",
73-
"Slave 0: RightShoulderOrbita2d\n"
107+
"Slave 0: RightWristOrbita3d\n"
74108
]
75109
}
76110
],
@@ -83,7 +117,7 @@
83117
},
84118
{
85119
"cell_type": "code",
86-
"execution_count": 27,
120+
"execution_count": 3,
87121
"id": "f55e9993-2e55-45ce-89d1-4fb12e6cbdf4",
88122
"metadata": {},
89123
"outputs": [
@@ -102,7 +136,7 @@
102136
},
103137
{
104138
"cell_type": "code",
105-
"execution_count": 22,
139+
"execution_count": 4,
106140
"id": "26fd1933-dc3b-406d-a0a0-45b3da9e25be",
107141
"metadata": {},
108142
"outputs": [
@@ -124,7 +158,7 @@
124158
},
125159
{
126160
"cell_type": "code",
127-
"execution_count": 23,
161+
"execution_count": 5,
128162
"id": "0848f2f4-bd16-4180-9907-8ccd8e87cfcf",
129163
"metadata": {},
130164
"outputs": [
@@ -315,6 +349,42 @@
315349
"# read the current target position\n",
316350
"client.get_target_position(slave_id)"
317351
]
352+
},
353+
{
354+
"cell_type": "code",
355+
"execution_count": null,
356+
"id": "0f6d4bc3-3e27-484a-83c1-1a05089d1530",
357+
"metadata": {},
358+
"outputs": [],
359+
"source": []
360+
},
361+
{
362+
"cell_type": "code",
363+
"execution_count": 29,
364+
"id": "98a27437-4544-4400-a5db-0abc93c0a4ed",
365+
"metadata": {},
366+
"outputs": [],
367+
"source": [
368+
"client.turn_on(slave_id)\n"
369+
]
370+
},
371+
{
372+
"cell_type": "code",
373+
"execution_count": 30,
374+
"id": "054ebd80-e018-4f85-8f97-3ad0a4abd889",
375+
"metadata": {},
376+
"outputs": [],
377+
"source": [
378+
"client.turn_off(slave_id)\n"
379+
]
380+
},
381+
{
382+
"cell_type": "code",
383+
"execution_count": null,
384+
"id": "e84a806f-67d9-4adb-a791-f60d302cf022",
385+
"metadata": {},
386+
"outputs": [],
387+
"source": []
318388
}
319389
],
320390
"metadata": {

python_client/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "maturin"
44

55
[project]
66
name = "python_client"
7-
version = "0.1.0"
7+
version = "1.5.0"
88
description = "A Python client for the Poulpe EtherCAT controller"
99
readme = "README.md"
1010
classifiers = [
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import python_client
2+
3+
print("Launching the EhterCAT server")
4+
5+
# launch the server and allow ctrl-c to stop the server
6+
python_client.launch_server("../../config/ethercat.yaml")
7+
8+
while True:
9+
pass

python_client/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,17 +348,17 @@ impl PyPoulpeRemoteClient {
348348
#[pyo3(signature = (file_name=None))]
349349
pub fn launch_server(file_name: Option<&str>) -> () {
350350
let filename = match file_name {
351-
Some(name) => name,
352-
None => "../config/ethercat.yaml",
351+
Some(name) => name.to_string(),
352+
None => "../config/ethercat.yaml".to_string(),
353353
};
354354

355-
// launch the server
356-
let server_future = poulpe_ethercat_grpc::server::launch_server(filename);
357-
tokio::runtime::Runtime::new().unwrap().block_on(async {
358-
match server_future.await {
359-
Ok(_) => {}
360-
Err(e) => panic!("Failed to launch the server: {}", e),
361-
}
355+
std::thread::spawn(move || {
356+
let rt = tokio::runtime::Runtime::new().unwrap();
357+
rt.block_on(async {
358+
if let Err(e) = poulpe_ethercat_grpc::server::launch_server(&filename).await {
359+
eprintln!("Failed to launch the server: {}", e);
360+
}
361+
});
362362
});
363363
return ();
364364
}

0 commit comments

Comments
 (0)