7.26-rosbridge-suit Interpretation

ROS ROS program and non-program communication

TOC

reference

rosbridge_suit
rosbridge Protocol Specification V2.0
the WebSocket Features and Applications
LabVIEW TCP JSON the Write
LabVIEW the WebSocket Client
Client
Principles and Applications rosbridge

Learning Record

rosbridge_suit

  • The toolkit provides a JSON API for non-ROS uses, there are a lot of front-end can be used, including WebSocket Server.
  • Any environment, so long as the data transmission protocol and in accordance with JSON transmission protocol rosbridge
  • Note, JSON protocol and TCP, HTTP is not on a level, JSON is a data protocol, the provisions of which should have transmitted data format, it can be said, JSON at the presentation layer of the OSI standard protocols.

WebSocket Json API is valid

  • websocket is a protocol for full duplex communication on a single TCP connection. The socket into the network.
  • Popular speaking, is carried out by running the program in the browser B / S architecture and communications software running locally, complete the relevant function socket.

rosbridge2.0 agreement Statute

  • Message is a transport layer rosbridge JSON object field only requirement is' OP 'field representing the operation of the message (Operation), the entire protocol is' set op'codes, plus the semantics of each operation.

Transport Layer

  • A message is a JSON object, similar to the following key-value pairs:
{“op”: "Example" }
  • Please note, still able to provide any string key-value pairs, such as
{"op": “Example”
    "id": "fred"
}

Note, however, "id" key may not be any interpretation, but the server can be designed for a specific meaning.

Protocol Statute main categories

  • Message compression and conversion
    • A portion of the message segment - fragment
    • png - a part of the picture segment message
  • Status Message
    • set_status_level - a status message reporting level setting request message
    • status - a status message
  • Confirmation message
    • auth - Confirm client authorized to connect or
  • ROS news

ROS Message Detail

  • Registration (Advertise)

3.4.1 Advertise ( advertise )

If you wish to advertise that you are or will be publishing a topic, then use the advertise command.

{ "op": "advertise",  (optional) "id": <string>,  "topic": <string>,  "type": <string> } 
  • topic – the string name of the topic to advertise
  • type – the string type to advertise for the topic
  • If the topic does not already exist, and the type specified is a valid type, then the topic will be established with this type.
  • If the topic already exists with a different type, an error status message is sent and this message is dropped
  • If the topic already exists with the same type, the sender of this message is registered as another publisher.
  • If the topic doesnt already exist but the type cannot be resolved, then an error status message is sent and this message is dropped.

3.4.2 Unadvertise ( unadvertise ) This stops advertising that you are publishing a topic.

{ "op": "unadvertise",  (optional) "id": <string>,  "topic": <string> } 
  • topic – the string name of the topic being unadvertised
  • If the topic does not exist, a warning status message is sent and this message is dropped
  • If the topic exists and there are still clients left advertising it, rosbridge will continue to advertise it until all of them have unadvertised
  • If the topic exists but rosbridge is not advertising it, a warning status message is sent and this message is dropped

3.4.3 Publish ( publish )

The publish message is used to send data on a topic.

 { "op": "publish",  (optional) "id": <string>,  "topic": <string>,  "msg": <json> }

The publish command publishes a message on a topic.

  • topic - the string name of the topic to publish to
  • msg - the message to publish on the topic
  • If the topic does not exist, then an error status message is sent and this message is dropped
  • If the msg does not conform to the type of the topic, then an error status message is sent and this message is dropped
  • If the msg is a subset of the type of the topic, then a warning status message is sent and the unspecified fields are filled in with defaults Special case: if the type being published has a 'header' field, then the client can optionally omit the header from the msg. If this happens, rosbridge will automatically populate the header with a frame id of "" and the timestamp as the current time. Alternatively, just the timestamp field can be omitted, and then the current time will be automatically inserted.

3.4.4 Subscribe

 { "op": "subscribe",  (optional) "id": <string>,  "topic": <string>,  (optional) "type": <string>,  (optional) "throttle_rate": <int>,  (optional) "queue_length": <int>,  (optional) "fragment_size": <int>,  (optional) "compression": <string> }

This command subscribes the client to the specified topic. It is recommended that if the client has multiple components subscribing to the same topic, that each component makes its own subscription request providing an ID. That way, each can individually unsubscribe and rosbridge can select the correct rate at which to send messages.

  • type – the (expected) type of the topic to subscribe to. If left off, type will be inferred, and if the topic doesn't exist then the command to subscribe will fail
  • topic – the name of the topic to subscribe to
  • throttle_rate – the minimum amount of time (in ms) that must elapse between messages being sent. Defaults to 0
  • queue_length – the size of the queue to buffer messages. Messages are buffered as a result of the throttle_rate. Defaults to 1.
  • id – if specified, then this specific subscription can be unsubscribed by referencing the ID.
  • fragment_size – the maximum size that a message can take before it is to be fragmented.
  • compression – an optional string to specify the compression scheme to be used on messages. Valid values are "none" and "png" If queue_length is specified, then messages are placed into the queue before being sent. Messages are sent from the head of the queue. If the queue gets full, the oldest message is removed and replaced by the newest message. If a client has multiple subscriptions to the same topic, then messages are sent at the lowest throttle_rate, with the lowest fragmentation size, and highest queue_length. It is recommended that the client provides IDs for its subscriptions, to enable rosbridge to effectively choose the appropriate fragmentation size and publishing rate.

3.4.5 Unsubscribe

 { "op": "unsubscribe",  (optional) "id": <string>,  "topic": <string> } 
  • topic – the name of the topic to unsubscribe from
  • id – an id of the subscription to unsubscribe If an id is provided, then only the corresponding subscription is unsubscribed. If no ID is provided, then all subscriptions are unsubscribed.

3.4.6 Call Service

{ "op": "call_service",  (optional) "id": <string>,  "service": <string>,  (optional) "args": <list<json>>,  (optional) "fragment_size": <int>,  (optional) "compression": <string> } 

Calls a ROS service

  • service – the name of the service to call
  • args – if the service has no args, then args does not have to be provided, though an empty list is equally acceptable. Args should be a list of json objects representing the arguments to the service
  • id – an optional id to distinguish this service call
  • fragment_size – the maximum size that the response message can take before it is fragmented
  • compression – an optional string to specify the compression scheme to be used on messages. Valid values are "none" and "png"

3.4.7 Advertise Service

{ "op": "advertise_service",  "type": <string>,  "service": <string> } 

Advertises an external ROS service server. Requests come to the client via Call Service.

  • service – the name of the service to advertise
  • type – the advertised service message type

3.4.8 Unadvertise Service

 { "op": "unadvertise_service",  "service": <string> } 

Stops advertising an external ROS service server

  • service – the name of the service to unadvertise

3.4.9 Service Response

{ "op": "service_response",  (optional) "id": <string>,  "service": <string>,  (optional) "values": <list<json>>,  "result": <boolean> } 

A response to a ROS service call

  • service – the name of the service that was called
  • values – the return values. If the service had no return values, then this field can be omitted (and will be by the rosbridge server)
  • id – if an ID was provided to the service request, then the service response will contain the ID
  • result - return value of service callback. true means success, false failure.

rosbridge server implementation

  • Implementation details are given for the convenience of the server protocol modified

LabVIEW JSON TCP

  • LabVIEW2014 has a "cluster Flatten To JSON string" and "Recovering from a JSON" vi function, we can complete these requirements, though I find some JSON plug-ins, but it looks like there is no need to use are relatively old library, the new version of LV has included this feature

rosbridge-suit use

installation

sudo apt-get install ros-indigo-rosbridge-suit

Tcp server running

rosrun rosbridge_server rosbridge_tcp
rqt_graph

Guess you like

Origin www.cnblogs.com/lizhensheng/p/11117602.html