Implement negotiation and actuation endpoints #5

Merged
0950726 merged 13 commits from feat/actuation-receiver into dev 2025-10-22 08:49:05 +00:00
0950726 commented 2025-10-16 19:57:04 +00:00 (Migrated from git.science.uu.nl)

This merge request implements the main and current actuation endpoints, i.e. 'ping', 'negotiate', and 'actuate/speech'.

It adds unit tests and a dependency for the unit tests (mock).

To test:

  • Re-install dependencies (pip install -r requirements.txt)
    • Or just add the mock dependency (pip install mock)
  • Run the unit tests as described in the README
  • Run main as described in the README (with --qi-url), then run the attached script (make a new file to put the script in, then run it)

When running main with the given script, try running main with the simulator connected (add the --qi-url tcp://<host of simulator>:<port of simulator> argument).

The test is successful if you see the simulator speak 5 messages, with numbers 0 through 4.

The script:

import zmq
import time


def main():
    context = zmq.Context()
    socket = context.socket(zmq.REQ)
    socket.bind("tcp://*:5555")

    actuation_socket = None

    try:
        request = {"endpoint": "negotiate/ports", "data": None}
        print("Sending port negotiation request: {}".format(request))
        socket.send_json(request)

        response = socket.recv_json()
        print("Received port negotiation response: {}".format(response))

        for endpoint in response["data"]:
            if endpoint["id"] == "actuation":
                print("Discovered actuation socket, connecting on port {}.".format(endpoint["port"]))
                actuation_socket = context.socket(zmq.PUB)
                actuation_socket.connect("tcp://localhost:{}".format(endpoint["port"]))
                time.sleep(0.1)  # To avoid sending too soon
                break
        if not actuation_socket:
            print("Failure: Negotiation did not discover actuation socket.")
            return

        for i in range(5):
            msg = {"endpoint": "actuate/speech", "data": "Hello ({}) with some more extra stuff to make it take longer.".format(i)}
            print("Sending request: {}".format(msg))
            actuation_socket.send_json(msg)

            time.sleep(1)
    except KeyboardInterrupt:
        print("\nInterrupted by user, exiting.")
    finally:
        socket.close()
        if actuation_socket: actuation_socket.close()
        context.term()


if __name__ == "__main__":
    main()

Ref: N25B-168

This merge request implements the main and current actuation endpoints, i.e. 'ping', 'negotiate', and 'actuate/speech'. It adds unit tests and a dependency for the unit tests (`mock`). To test: - Re-install dependencies (`pip install -r requirements.txt`) - Or just add the `mock` dependency (`pip install mock`) - Run the unit tests as described in the README - Run main as described in the README (with `--qi-url`), then run the attached script (make a new file to put the script in, then run it) When running main with the given script, try running main with the simulator connected (add the `--qi-url tcp://<host of simulator>:<port of simulator>` argument). The test is successful if you see the simulator speak 5 messages, with numbers 0 through 4. The script: ```python import zmq import time def main(): context = zmq.Context() socket = context.socket(zmq.REQ) socket.bind("tcp://*:5555") actuation_socket = None try: request = {"endpoint": "negotiate/ports", "data": None} print("Sending port negotiation request: {}".format(request)) socket.send_json(request) response = socket.recv_json() print("Received port negotiation response: {}".format(response)) for endpoint in response["data"]: if endpoint["id"] == "actuation": print("Discovered actuation socket, connecting on port {}.".format(endpoint["port"])) actuation_socket = context.socket(zmq.PUB) actuation_socket.connect("tcp://localhost:{}".format(endpoint["port"])) time.sleep(0.1) # To avoid sending too soon break if not actuation_socket: print("Failure: Negotiation did not discover actuation socket.") return for i in range(5): msg = {"endpoint": "actuate/speech", "data": "Hello ({}) with some more extra stuff to make it take longer.".format(i)} print("Sending request: {}".format(msg)) actuation_socket.send_json(msg) time.sleep(1) except KeyboardInterrupt: print("\nInterrupted by user, exiting.") finally: socket.close() if actuation_socket: actuation_socket.close() context.term() if __name__ == "__main__": main() ``` Ref: N25B-168
0950726 commented 2025-10-16 20:09:11 +00:00 (Migrated from git.science.uu.nl)

added 1 commit

  • 45be0366 - style: correct and clarify docs and comments

Compare with previous version

added 1 commit <ul><li>45be0366 - style: correct and clarify docs and comments</li></ul> [Compare with previous version](/ics/sp/2025/n25b/pepperplus-ri/-/merge_requests/5/diffs?diff_id=132346&start_sha=4c3aa3a91102de83a866eb35a407a8dad64ee272)
0950726 commented 2025-10-21 11:55:10 +00:00 (Migrated from git.science.uu.nl)

added 1 commit

Compare with previous version

added 1 commit <ul><li>5631a556 - test: convert to pytest</li></ul> [Compare with previous version](/ics/sp/2025/n25b/pepperplus-ri/-/merge_requests/5/diffs?diff_id=132610&start_sha=45be0366ba267e516f4459951512119391f6839a)
0950726 commented 2025-10-21 11:57:26 +00:00 (Migrated from git.science.uu.nl)

added 3 commits

  • 5631a556...5dce0e34 - 2 commits from branch dev
  • 9d728f78 - Merge remote-tracking branch 'origin/dev' into feat/actuation-receiver

Compare with previous version

added 3 commits <ul><li>5631a556...5dce0e34 - 2 commits from branch <code>dev</code></li><li>9d728f78 - Merge remote-tracking branch &#39;origin/dev&#39; into feat/actuation-receiver</li></ul> [Compare with previous version](/ics/sp/2025/n25b/pepperplus-ri/-/merge_requests/5/diffs?diff_id=132613&start_sha=5631a55697a815b102e239bef0f5bdf0f40ea5ca)
0950726 commented 2025-10-22 08:45:36 +00:00 (Migrated from git.science.uu.nl)

assigned to @0950726

assigned to @0950726
8464960 commented 2025-10-22 08:45:54 +00:00 (Migrated from git.science.uu.nl)

requested review from @8464960

requested review from @8464960
8464960 commented 2025-10-22 08:49:01 +00:00 (Migrated from git.science.uu.nl)

approved this merge request

approved this merge request
8464960 commented 2025-10-22 08:49:05 +00:00 (Migrated from git.science.uu.nl)

mentioned in commit 4da83a0a7e

mentioned in commit 4da83a0a7e0352a288b4c0f075615bf935a39752
8464960 (Migrated from git.science.uu.nl) merged commit 4da83a0a7e into dev 2025-10-22 08:49:05 +00:00
8464960 (Migrated from git.science.uu.nl) approved these changes 2026-02-02 13:26:46 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: pepperplus/pepperplus-ri#5