24 lines
670 B
Python
24 lines
670 B
Python
from pythonosc import dispatcher
|
|
from pythonosc import osc_server
|
|
|
|
def joint_handler(address, *args):
|
|
print(f"{address} -> {args[0]}")
|
|
|
|
def main():
|
|
ip = "0.0.0.0" # Listen on all network interfaces
|
|
port = 8000 # Must match the sender's port in `joint_state_osc.py`
|
|
|
|
# Create dispatcher and register callback
|
|
disp = dispatcher.Dispatcher()
|
|
disp.map("/joint_states/shoulder_lift_joint/*", joint_handler)
|
|
|
|
server = osc_server.ThreadingOSCUDPServer((ip, port), disp) # Start OSC server
|
|
|
|
try:
|
|
server.serve_forever() # Keep server running
|
|
except KeyboardInterrupt:
|
|
print("")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|