FIWARE FIROS 从非 ROS 世界发布 cmd_vel
FIWARE FIROS Publish cmd_vel from Non-ROS-World
在 firos turtlesim 示例 (https://firos.readthedocs.io/en/latest/install/turtlesim-example.html) 中,我正在尝试通过 POST 请求从非 ROS 世界发布关于 /turtle1/cmd_vel 主题的消息,以便移动机器人。
但是我不确定该怎么做,因为当我开始 firos/core.py 时,创建的实体列表是:
{"id":".turtle1.pose","type":"turtlesim%2FPose","angular_velocity":{"type":"number","value":0,"metadata":{"dataType":{"type":"dataType","value":"float32"}}},"linear_velocity":{"type":"number","value":0,"metadata":{"dataType":{"type":"dataType","value":"float32"}}},"theta":{"type":"number","value":0,"metadata":{"dataType":{"type":"dataType","value":"float32"}}},"x":{"type":"number","value":5.544444561,"metadata":{"dataType":{"type":"dataType","value":"float32"}}},"y":{"type":"number","value":5.544444561,"metadata":{"dataType":{"type":"dataType","value":"float32"}}}}
订阅列表为:
{"id":"XXXX","expires":"2021-06-09T22:10:17.000Z","status":"active","subject":{"entities":[{"id":".turtle1.cmd_vel","type":"geometry_msgs%2FTwist"}],"condition":{"attrs":[]}},"notification":{"attrs":["linear","angular"],"onlyChangedAttrs":false,"attrsFormat":"normalized","http":{"url":"http://XXX.XXX.X.XXX:YYYYY"}}}
None id 为 .turtle1.cmd_vel 的实体已创建,因此我不知道如何更新例如线性属性。我是否必须先手动创建 .turtle1.cmd_vel 实体,然后再更新属性?我试过了:
curl -iX POST \
'http://localhost:1026/v2/entities' \
-H 'Content-Type: application/json' \
-d '
{
"id": ".turtle1.cmd_vel",
"type": "geometry_msgs%2FTwist",
"linear": {
"type": "float64",
"value": {
"x": "1",
"y": "0",
"z": "0"
}
},
"angular": {
"type": "float64",
"value": {
"x": "0",
"y": "0",
"z": "0"
}
}
}'
但我遇到了错误。
最后我解决了如下问题:
POST实体:
curl -iX POST \
'http://localhost:1026/v2/entities' \
-H 'Content-Type: application/json' \
-d '
{
"id":".turtle1.cmd_vel",
"type":"geometry_msgs%2FTwist",
"angular":{
"type":"geometry_msgs%2FVector3",
"value":{
"y":{
"type":"number",
"value":0.0
},
"x":{
"type":"number",
"value":0.0
},
"z":{
"type":"number",
"value":0.0
}
},
"metadata":{
"dataType":{
"type":"dataType",
"value":{
"y":"float64",
"x":"float64",
"z":"float64"
}
}
}
},
"linear":{
"type":"geometry_msgs%2FVector3",
"value":{
"y":{
"type":"number",
"value":0.0
},
"x":{
"type":"number",
"value":0.0
},
"z":{
"type":"number",
"value":0.0
}
},
"metadata":{
"dataType":{
"type":"dataType",
"value":{
"y":"float64",
"x":"float64",
"z":"float64"
}
}
}
}
}'
要更新值:
curl -iX PATCH \
--url 'http://localhost:1026/v2/entities/.turtle1.cmd_vel/attrs' \
--header 'Content-Type: application/json' \
--data-raw ' {
"angular": {
"type":"geometry_msgs%2FVector3",
"value":{
"y":{
"type":"number",
"value": 0.0
},
"x":{
"type":"number",
"value": 0.0
},
"z":{
"type":"number",
"value": 0.0
}
},
"metadata":{
"dataType":{
"type":"dataType",
"value":{
"y":"float64",
"x":"float64",
"z":"float64"
}
}
}
},
"linear": {
"type":"geometry_msgs%2FVector3",
"value":{
"y":{
"type":"number",
"value": 8.0
},
"x":{
"type":"number",
"value": 8.0
},
"z":{
"type":"number",
"value": 8.0
}
},
"metadata":{
"dataType":{
"type":"dataType",
"value":{
"y":"float64",
"x":"float64",
"z":"float64"
}
}
}
}
}'
关于更新实体的注意事项:
它不能自己直接更新子属性“x”(来自“线性”属性),它需要重新提供整个 JSON 对象。
其背后的原因如下:NGSI 仅处理属性和关系 - 它是互操作性的抽象层。 属性“线性”是一个原子单位,因此您可以更改整个“线性”或 none。在这种情况下,“linear”的值是一个 JSON 对象。
在 firos turtlesim 示例 (https://firos.readthedocs.io/en/latest/install/turtlesim-example.html) 中,我正在尝试通过 POST 请求从非 ROS 世界发布关于 /turtle1/cmd_vel 主题的消息,以便移动机器人。
但是我不确定该怎么做,因为当我开始 firos/core.py 时,创建的实体列表是:
{"id":".turtle1.pose","type":"turtlesim%2FPose","angular_velocity":{"type":"number","value":0,"metadata":{"dataType":{"type":"dataType","value":"float32"}}},"linear_velocity":{"type":"number","value":0,"metadata":{"dataType":{"type":"dataType","value":"float32"}}},"theta":{"type":"number","value":0,"metadata":{"dataType":{"type":"dataType","value":"float32"}}},"x":{"type":"number","value":5.544444561,"metadata":{"dataType":{"type":"dataType","value":"float32"}}},"y":{"type":"number","value":5.544444561,"metadata":{"dataType":{"type":"dataType","value":"float32"}}}}
订阅列表为:
{"id":"XXXX","expires":"2021-06-09T22:10:17.000Z","status":"active","subject":{"entities":[{"id":".turtle1.cmd_vel","type":"geometry_msgs%2FTwist"}],"condition":{"attrs":[]}},"notification":{"attrs":["linear","angular"],"onlyChangedAttrs":false,"attrsFormat":"normalized","http":{"url":"http://XXX.XXX.X.XXX:YYYYY"}}}
None id 为 .turtle1.cmd_vel 的实体已创建,因此我不知道如何更新例如线性属性。我是否必须先手动创建 .turtle1.cmd_vel 实体,然后再更新属性?我试过了:
curl -iX POST \
'http://localhost:1026/v2/entities' \
-H 'Content-Type: application/json' \
-d '
{
"id": ".turtle1.cmd_vel",
"type": "geometry_msgs%2FTwist",
"linear": {
"type": "float64",
"value": {
"x": "1",
"y": "0",
"z": "0"
}
},
"angular": {
"type": "float64",
"value": {
"x": "0",
"y": "0",
"z": "0"
}
}
}'
但我遇到了错误。
最后我解决了如下问题:
POST实体:
curl -iX POST \
'http://localhost:1026/v2/entities' \
-H 'Content-Type: application/json' \
-d '
{
"id":".turtle1.cmd_vel",
"type":"geometry_msgs%2FTwist",
"angular":{
"type":"geometry_msgs%2FVector3",
"value":{
"y":{
"type":"number",
"value":0.0
},
"x":{
"type":"number",
"value":0.0
},
"z":{
"type":"number",
"value":0.0
}
},
"metadata":{
"dataType":{
"type":"dataType",
"value":{
"y":"float64",
"x":"float64",
"z":"float64"
}
}
}
},
"linear":{
"type":"geometry_msgs%2FVector3",
"value":{
"y":{
"type":"number",
"value":0.0
},
"x":{
"type":"number",
"value":0.0
},
"z":{
"type":"number",
"value":0.0
}
},
"metadata":{
"dataType":{
"type":"dataType",
"value":{
"y":"float64",
"x":"float64",
"z":"float64"
}
}
}
}
}'
要更新值:
curl -iX PATCH \
--url 'http://localhost:1026/v2/entities/.turtle1.cmd_vel/attrs' \
--header 'Content-Type: application/json' \
--data-raw ' {
"angular": {
"type":"geometry_msgs%2FVector3",
"value":{
"y":{
"type":"number",
"value": 0.0
},
"x":{
"type":"number",
"value": 0.0
},
"z":{
"type":"number",
"value": 0.0
}
},
"metadata":{
"dataType":{
"type":"dataType",
"value":{
"y":"float64",
"x":"float64",
"z":"float64"
}
}
}
},
"linear": {
"type":"geometry_msgs%2FVector3",
"value":{
"y":{
"type":"number",
"value": 8.0
},
"x":{
"type":"number",
"value": 8.0
},
"z":{
"type":"number",
"value": 8.0
}
},
"metadata":{
"dataType":{
"type":"dataType",
"value":{
"y":"float64",
"x":"float64",
"z":"float64"
}
}
}
}
}'
关于更新实体的注意事项:
它不能自己直接更新子属性“x”(来自“线性”属性),它需要重新提供整个 JSON 对象。
其背后的原因如下:NGSI 仅处理属性和关系 - 它是互操作性的抽象层。 属性“线性”是一个原子单位,因此您可以更改整个“线性”或 none。在这种情况下,“linear”的值是一个 JSON 对象。