iml130 / firos

Firos helps to connect ROS-based robots to the Fiware Ecosystem...
MIT License
12 stars 8 forks source link

Restructuring of the Appearence of the JSON inside OCB #32

Open Luxxii opened 5 years ago

Luxxii commented 5 years ago

Currently the Orion Context Broker (OCB) gets an entity of a robot with ALL of its topics. This is not strictly as intended for the FIWARE-Entities. They should be kept small...

Current OCB Content:

[
   {
      "id":"turtle1",
      "type":"ROBOT",

      "pose":{
        "type":"turtlesim.Pose",
        "value":{ ... },
        "metadata":{ ... }
     },

     "cmd_vel":{
        "type":"geometry_msgs.Twist",
        "value":{ ... },
        "metadata":{ ... }
     }
   }
]

Expected OCB Content:

[
    {
        "id":"turtle1/pose",
        "type":"turtlesim.Pose",

        "pose":{
          "type":"turtlesim.Pose", // What is added here?
          "value":{ ... },
          "metadata":{ ... }
       }
     },
     {
        "id":"turtle1/cmd_vel",
        "type":"geometry_msgs.Twist",

       "cmd_vel":{
          "type":"geometry_msgs.Twist", // What is added here?
          "value":{ ... },
          "metadata":{ ... }
       }
     }
]

It means, we need to do the following:

FIROS will no longer support multiple instances on ONE OCB, where it only subscribes to a subset of messages (depending on the Context-Type-Attribute). This behaviour will be omitted. To only subscribe to some on the OCB, it needs to be specified inside robots.json and whitelist.json

In addition to that, the Issue #31 also needs to be completed.

For completeness: id will have the complete topic in it (maybe escaped with . @ptrdtznr ?) and type will be the message type inside

The comment // What is added here? shows, that there is currently redundant information in one Entity. Maybe we can add some useful information there. Maybe it gets resolved during Implementation.

@DLuensch @ptrdtznr , are there more changes that need to be made?

Luxxii commented 4 years ago

The Restructuring is almost finished.

Sadly some messages cannot be published up to the OCB (due to the Limitations, named here )

Here is a snippet of such an example from a regular ros message (/rosout):

{
   "function":{
      "type":"string",
      "value":"__cxx11::string turtlesim::TurtleFrame::spawnTurtle"
   },
   "name":{
      "type":"string",
      "value":"/turtlesim"
   },
   "level":{
      "type":"number",
      "value":2
   },
   "topics":{
      "type":"array",
      "value":[

      ]
   },
   "header":{
      "type":"std_msgs.Header",
      "value":{
         "stamp":{
            "type":"Time",
            "value":{
               "secs":{
                  "type":"number",
                  "value":1574152695
               },
               "nsecs":{
                  "type":"number",
                  "value":721920959
               }
            }
         },
         "frame_id":{
            "type":"string",
            "value":""
         },
         "seq":{
            "type":"number",
            "value":1
         }
      }
   },
   "file":{
      "type":"string",
      "value":"/tmp/binarydeb/ros-melodic-turtlesim-0.9.1/src/turtle_frame.cpp"
   },
   "msg":{
      "type":"string",
      "value":"Spawning turtle [turtle1] at x=[5,544445], y=[5,544445], theta=[0,000000]"
   },
   "line":{
      "type":"number",
      "value":186
   },
   "type":"rosgraph_msgs.Log",
   "id":".rosout"
}
Luxxii commented 4 years ago

@ptrdtznr and @DLuensch : In Development, everything has been redone. Could you please verify, if this is what you need. :)

Luxxii commented 4 years ago

In the new FOC, the strings inside an entity are now encoded (if needed). Firos utilizes this.

The Topic /rosout now looks as follows :

{
   "id":".rosout",
   "type":"rosgraph_msgs%2FLog",
   "file":{
      "type":"string",
      "value":"%2Ftmp%2Fbinarydeb%2Fros-melodic-turtlesim-0.9.1%2Fsrc%2Fturtle_frame.cpp",
      "metadata":{
         "dataType":{
            "type":"dataType",
            "value":"string"
         }
      }
   },
   "function":{
      "type":"string",
      "value":"__cxx11%3A%3Astring%20turtlesim%3A%3ATurtleFrame%3A%3AspawnTurtle",
      "metadata":{
         "dataType":{
            "type":"dataType",
            "value":"string"
         }
      }
   },
   "header":{
      "type":"std_msgs%2FHeader",
      "value":{
         "seq":{
            "value":1,
            "type":"number"
         },
         "stamp":{
            "value":{
               "secs":{
                  "value":1574670295,
                  "type":"number"
               },
               "nsecs":{
                  "value":635979261,
                  "type":"number"
               }
            },
            "type":"Time"
         },
         "frame_id":{
            "value":"",
            "type":"string"
         }
      },
      "metadata":{
         "dataType":{
            "type":"dataType",
            "value":{
               "seq":"uint32",
               "stamp":{
                  "secs":"int32",
                  "nsecs":"int32"
               },
               "frame_id":"string"
            }
         }
      }
   },
   "level":{
      "type":"number",
      "value":2,
      "metadata":{
         "dataType":{
            "type":"dataType",
            "value":"byte"
         }
      }
   },
   "line":{
      "type":"number",
      "value":186,
      "metadata":{
         "dataType":{
            "type":"dataType",
            "value":"uint32"
         }
      }
   },
   "msg":{
      "type":"string",
      "value":"Spawning%20turtle%20%5Bturtle1%5D%20at%20x%3D%5B5%2C544445%5D%2C%20y%3D%5B5%2C544445%5D%2C%20theta%3D%5B0%2C000000%5D",
      "metadata":{
         "dataType":{
            "type":"dataType",
            "value":"string"
         }
      }
   },
   "name":{
      "type":"string",
      "value":"%2Fturtlesim",
      "metadata":{
         "dataType":{
            "type":"dataType",
            "value":"string"
         }
      }
   },
   "topics":{
      "type":"array",
      "value":[

      ],
      "metadata":{
         "dataType":{
            "type":"dataType",
            "value":"string[]"
         }
      }
   }
}

It is less readable. For the unescaped version: FIROS_ADDR:PORT/topic/TOPIC can be used for subscribed topics! Nonetheless, the OCB should now accept most messages with 'cryptic' strings