-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First implementation for eCAL Core with nanobind.
- Loading branch information
1 parent
120f12f
commit 622c97d
Showing
52 changed files
with
3,058 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# ========================= eCAL LICENSE ================================= | ||
# | ||
# Copyright (C) 2016 - 2024 Continental Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# ========================= eCAL LICENSE ================================= | ||
|
||
from pickle import TRUE | ||
import sys | ||
import time | ||
|
||
import nanobind_core as ecal_core | ||
|
||
# define the client response callback to catch server responses | ||
def client_resp_callback(service_info, response): | ||
if (service_info["call_state"] == "call_state_executed"): | ||
print("'DemoService' method '{}' responded : '{}'".format(service_info["method_name"], response)) | ||
print() | ||
else: | ||
print("server {} response failed, error : '{}'".format(service_info["host_name"], service_info["error_msg"])) | ||
print() | ||
|
||
def main(): | ||
# print eCAL version and date | ||
print("eCAL {} ({})\n".format(ecal_core.get_version_string(), ecal_core.get_version_date())) | ||
|
||
# initialize eCAL API | ||
ecal_core.initialize() | ||
|
||
# create a client for the "DemoService" service | ||
client = ecal_core.ServiceClient("DemoService") | ||
|
||
# and add it to the client | ||
client.add_response_callback(client_resp_callback) | ||
|
||
# idle and call service methods | ||
i = 0 | ||
while(ecal_core.ok()): | ||
i = i + 1 | ||
# call foo | ||
request = bytes("hello foo {}".format(i), "ascii") | ||
print("'DemoService' method 'foo' requested with : {}".format(request)) | ||
client.call("foo", "request", 1234) | ||
time.sleep(0.5) | ||
# call ping | ||
request = bytes("ping number {}".format(i), "ascii") | ||
print("'DemoService' method 'ping' requested with : {}".format(request)) | ||
client.call("ping", "request", 1234) | ||
time.sleep(0.5) | ||
|
||
# destroy client | ||
client.destroy() | ||
|
||
# finalize eCAL API | ||
ecal_core.finalize() | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import sys | ||
|
||
import nanobind_core as ecal_core | ||
|
||
def main(): | ||
# print eCAL version and date | ||
print("eCAL {} ({})\n".format(ecal_core.get_version_string(), ecal_core.get_version_date())) | ||
|
||
# initialize eCAL API | ||
ecal_core.initialize() | ||
|
||
# create subscriber | ||
sub = ecal_core.Subscriber("Hello") | ||
|
||
# receive messages | ||
while ecal_core.ok(): | ||
msg = sub.receive(1234) | ||
print("Received: {} ".format(msg)) | ||
|
||
# finalize eCAL API | ||
ecal_core.finalize() | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# ========================= eCAL LICENSE ================================= | ||
# | ||
# Copyright (C) 2016 - 2024 Continental Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# ========================= eCAL LICENSE ================================= | ||
|
||
import sys | ||
import time | ||
|
||
import nanobind_core as ecal_core | ||
|
||
# eCAL receive callback | ||
def callback(topic_name, msg, time): | ||
print("Received: {} ms {}".format(time, msg)) | ||
|
||
def main(): | ||
# print eCAL version and date | ||
print("eCAL {} ({})\n".format(ecal_core.get_version_string(), ecal_core.get_version_date())) | ||
|
||
# initialize eCAL API | ||
ecal_core.initialize() | ||
|
||
# create subscriber and connect callback | ||
sub = ecal_core.Subscriber("Hello") | ||
sub.add_receive_callback(callback) | ||
|
||
# idle main thread | ||
while ecal_core.ok(): | ||
time.sleep(0.1) | ||
|
||
# finalize eCAL API | ||
ecal_core.finalize() | ||
|
||
if __name__ == "__main__": | ||
main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# ========================= eCAL LICENSE ================================= | ||
# | ||
# Copyright (C) 2016 - 2024 Continental Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# ========================= eCAL LICENSE ================================= | ||
|
||
import sys | ||
import time | ||
|
||
import nanobind_core as ecal_core | ||
|
||
# define the server method "foo" function | ||
def foo_req_callback(method_name, req_type, resp_type, request): | ||
print("'DemoService' method '{}' called with {}".format(method_name, request)) | ||
#return True #, bytes("thank you for calling foo :-)", "ascii") | ||
return 0, "pong" | ||
|
||
# define the server method "ping" function | ||
def ping_req_callback(method_name, req_type, resp_type, request): | ||
print("'DemoService' method '{}' called with {}".format(method_name, request)) | ||
return 0, bytes("pong", "ascii") | ||
|
||
def main(): | ||
# print eCAL version and date | ||
print("eCAL {} ({})\n".format(ecal_core.get_version_string(), ecal_core.get_version_date())) | ||
|
||
# initialize eCAL API | ||
ecal_core.initialize() | ||
|
||
# initialize eCAL API | ||
# ecal_core.initialize(sys.argv, "py_minimal_service_server") | ||
|
||
# set process state | ||
# ecal_core.set_process_state(1, 1, "I feel good") | ||
|
||
# create a server for the "DemoService" service | ||
server = ecal_core.ServiceServer("DemoService") | ||
|
||
# define the server methods and connect them to the callbacks | ||
server.add_method_callback("foo", "string", "string", foo_req_callback) | ||
server.add_method_callback("ping", "ping_type", "pong_type", ping_req_callback) | ||
|
||
# idle | ||
while(ecal_core.ok()): | ||
time.sleep(1.0) | ||
|
||
# destroy server | ||
server.destroy() | ||
|
||
# finalize eCAL API | ||
server.finalize() | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import sys | ||
import time | ||
|
||
import nanobind_core as ecal_core | ||
|
||
def main(): | ||
# print eCAL version and date | ||
print("eCAL {} ({})\n".format(ecal_core.get_version_string(), ecal_core.get_version_date())) | ||
|
||
# initialize eCAL API | ||
ecal_core.initialize() | ||
|
||
# create publisher | ||
pub = ecal_core.Publisher("Hello") | ||
msg = "HELLO WORLD FROM PYTHON" | ||
|
||
# send messages | ||
i = 0 | ||
while ecal_core.ok(): | ||
i = i + 1 | ||
current_message = "{} {:6d}".format(msg, i) | ||
print("Sending: {}".format(current_message)) | ||
pub.send(current_message,1234) | ||
time.sleep(0.5) | ||
|
||
# finalize eCAL API | ||
ecal_core.finalize() | ||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.