mvsim-teleop.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 
3 # ---------------------------------------------------------------------
4 # This example shows how to:
5 # - Call a MVSIM service.
6 # - Use it to drive a vehicle/robot using its internal kinematics
7 # controller.
8 #
9 # Install python3-mvsim, or test with a local build with:
10 # export PYTHONPATH=$HOME/code/mvsim/build/:$PYTHONPATH
11 # ---------------------------------------------------------------------
12 
13 from mvsim_comms import pymvsim_comms
14 from mvsim_msgs import SrvSetControllerTwist_pb2
15 
16 
17 def sendRobotTwistSetpoint(client, robotName, vx, vy, w):
18  # (vx,vy) in local coordinates [m/s]
19  # (w) in [rad/s]
20 
21  req = SrvSetControllerTwist_pb2.SrvSetControllerTwist()
22  req.objectId = robotName # vehicle/robot/object name in MVSIM
23  req.twistSetPoint.vx = vx
24  req.twistSetPoint.vy = vy
25  req.twistSetPoint.vz = 0
26  req.twistSetPoint.wx = 0
27  req.twistSetPoint.wy = 0
28  req.twistSetPoint.wz = w
29  # ret =
30  client.callService('set_controller_twist', req.SerializeToString())
31 
32 
33 if __name__ == "__main__":
34  client = pymvsim_comms.mvsim.Client()
35  client.setName("mvsim-teleop")
36  print("Connecting to server...")
37  client.connect()
38  print("Connected successfully.")
39 
40  sendRobotTwistSetpoint(client, 'r1', 0.75, 0.0, 1.0)
OutIt print(OutIt out, const xml_node< Ch > &node, int flags=0)
def sendRobotTwistSetpoint(client, robotName, vx, vy, w)
Definition: mvsim-teleop.py:17


mvsim
Author(s):
autogenerated on Tue Jul 4 2023 03:08:21