ROS can't read json file
Hello,
I am trying to communicate a non ros-program to ros kinetic via MQTT Broker. mqtt_bridge node make it easier and I already configurated it properly. When I launch roslaunch mqtt_bridge demo.launch it runs very well without any problem. As soon I start the communication from a non ros-programm to ros, the launch file throw this error message multiple times "Message type std_msgs/String does not have a field position".
The message program looks like this:
import json
import paho.mqtt.client as mqtt
import time
client = mqtt.Client()
client.connect(192.168.1.111, 1883, 60)
msg = {
'position': [
{
'x_value' : '5',
'y_value' : '2.6'
}
]
}
json_msg=json.dumps(msg)
channel = "ZIRP/FTS/N1/Pos"
client = mqttClient
client.publish(channel, json_msg)
The code is written in python and run in a non ros PC. The code doesn't throw any problem and the mqtt broker receive the message successfully. The sent data structure is string and probably in array but I'm not sure.
The configuration in mqtt_bridge node:
mqtt:
client:
protocol: 4 # MQTTv311
connection:
host: 192.168.1.101
port: 1883
keepalive: 60
private_path: device/001
bridge:
# echo back
- factory: mqtt_bridge.bridge:RosToMqttBridge
msg_type: std_msgs.msg:String
topic_from: /echo
topic_to: ZIRP/FTS/N1/Pos
- factory: mqtt_bridge.bridge:MqttToRosBridge
msg_type: std_msgs.msg:String
topic_from: ZIRP/FTS/N1/Pos
topic_to: /echo
Any idea why ros can't read the message?
Please edit your question to provide more context. To be able to help you best, we need to be able to reproduce your problem. It looks like you're trying to send structured data on a topic that is expecting a string.
I edited my question and it's in the actual version.
Please provide your configuration file.
The configuration file is included in the question right now