Python Robot Raconteur Client Example

 1from RobotRaconteur.Client import *
 2import time
 3import numpy as np
 4
 5# Connect to the Reynard service using a URL
 6c = RRN.ConnectService('rr+tcp://localhost:29200?service=reynard')
 7
 8
 9def new_message(msg):
10    print(f"New message: {msg}")
11
12
13# Connect a callback function to listen for new messages
14c.new_message += new_message
15
16# Read the current state using a wire "peek". Can also "connect" to receive streaming updates.
17state, _ = c.state.PeekInValue()
18print(state)
19
20# Teleport the robot
21c.teleport(0.1, -0.2)
22
23# Drive the robot with no timeout
24c.drive_robot(0.5, -0.2, -1, False)
25
26# Wait for one second
27time.sleep(1)
28
29# Stop the robot
30c.drive_robot(0, 0, -1, False)
31
32# Set the arm position
33c.setf_arm_position(np.deg2rad(100), np.deg2rad(-30), np.deg2rad(-70))
34
35# Drive the arm using timeout and wait
36c.drive_arm(np.deg2rad(10), np.deg2rad(-30), np.deg2rad(-15), 1.5, True)
37
38# Set the color to red
39c.color = (1, 0, 0)
40
41# Read the color
42print(f"Color: {c.color}")
43
44time.sleep(1)
45
46# Reset the color
47c.color = (0.929, 0.49, 0.192)
48
49# Say hello
50c.say("Hello, World From Robot Raconteur!")