publisher-example1.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 
3 # To test with a local build:
4 #
5 # export PYTHONPATH=$HOME/code/mvsim/build/lib/:$PYTHONPATH
6 
7 from mvsim_comms import pymvsim_comms
8 from mvsim_msgs import SrvSetPose_pb2
9 import time
10 import math
11 
12 
13 def setObjectPose(client, objectName, x, y, theta_rad):
14  # Send a set pose request:
15  req = SrvSetPose_pb2.SrvSetPose()
16  req.objectId = objectName # vehicle/robot/object name in MVSIM
17  req.pose.x = x
18  req.pose.y = y
19  req.pose.z = 0
20  req.pose.yaw = theta_rad
21  req.pose.pitch = 0
22  req.pose.roll = 0 # math.radians(0.0)
23  #ret =
24  client.callService('set_pose', req.SerializeToString())
25 
26 
27 if __name__ == "__main__":
28  client = pymvsim_comms.mvsim.Client()
29  client.setName("tutorial1")
30  print("Connecting to server...")
31  client.connect()
32  print("Connected successfully.")
33 
34  for i in range(1000):
35  th = i*0.02
36  R = 5
37  setObjectPose(client, 'r1', math.sin(th)*R, R*(1-math.cos(th)), th)
38  time.sleep(0.01)
OutIt print(OutIt out, const xml_node< Ch > &node, int flags=0)
def setObjectPose(client, objectName, x, y, theta_rad)


mvsim
Author(s):
autogenerated on Fri May 7 2021 03:05:51