mqtt_test_proto.py
Go to the documentation of this file.
1 import paho.mqtt.client as mqtt
2 import math
3 import robot_state_pb2
4 from time import sleep
5 
6 # The callback for when the client receives a CONNACK response from the server.
7 def on_connect(client, userdata, flags, rc):
8  print("Connected with result code "+str(rc))
9 
10 client = mqtt.Client()
11 client.on_connect = on_connect
12 
13 client = mqtt.Client("PlotJuggler-test") #create new instance
14 
15 client.connect("127.0.0.1", 1883, 60)
16 
17 time = 0.0
18 
19 
20 page_number = 0;
21 
22 
23 
24 while True:
26  robot_state.query = "query";
27  sleep(0.20)
28  time += 0.20
29 
30  page_number = page_number +1
31  robot_state.page_number = page_number
32  robot_state.result_per_page = page_number*2
33 
34  robot_state.pos.x = 1.1
35  robot_state.pos.y = 2.2
36  robot_state.pos.z = 3.3
37 
38 # robot_state.corpus = 3
39 
40  robot_state.sensor_reading["sensor1"] = 15;
41  robot_state.sensor_reading["sensor2"] = page_number;
42 
43  msg = robot_state.SerializeToString()
44 
45  ret = client.publish("plotjuggler/stuff", msg, qos=0 )
46  print( ret.is_published() )
robot_state_pb2.RobotState
RobotState
Definition: robot_state_pb2.py:190
print
void print(std::FILE *f, const text_style &ts, const S &format_str, const Args &... args)
Definition: color.h:497
mqtt_test_proto.on_connect
on_connect
Definition: mqtt_test_proto.py:11


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Aug 11 2024 02:24:23