Ivy Interface¶
The IvyMessagesInterface class allows to send paparazzi messages on the Ivy bus and receive paparazzi messages from Ivy.
See the tutorial to learn how to use it.
- class pprzlink.ivy.IvyMessagesInterface(agent_name=None, start_ivy=True, verbose=False, ivy_bus='')[source]¶
This class is the interface between the paparazzi messages and the Ivy bus.
- bind_raw(callback, regex='(.*)')[source]¶
Bind callback to Ivy messages matching regex (without any extra parsing)
- Parameters
callback – function called on new message with agent, message, from as params
regex – regular expression for matching message
- static parse_pprz_msg(ivy_msg)[source]¶
Parse an Ivy message into a PprzMessage.
- Parameters
ivy_msg – Ivy message string to parse into PprzMessage
- Return ac_id, request_id, msg
The parameters to be passed to callback
- send(msg, sender_id=None, receiver_id=None, component_id=None)[source]¶
Send a message
- Parameters
msg – PprzMessage or simple string
sender_id – Needed if sending a PprzMessage of telemetry msg_class, otherwise message class might be used instead
- Returns
Number of clients the message was sent to
- Raises
ValueError: if msg was invalid or sender_id not provided for telemetry messages
- Raises
RuntimeError: if the server is not running
- send_raw_datalink(msg)[source]¶
Send a PprzMessage of datalink msg_class embedded in RAW_DATALINK message
- Parameters
msg – PprzMessage
- Returns
Number of clients the message was sent to
- Raises
ValueError: if msg was invalid
- Raises
RuntimeError: if the server is not running
- send_request(class_name, request_name, callback, **request_extra_data)[source]¶
Send a data request message and passes the result directly to the callback method.
- Returns
Number of clients this message was sent to.
- Return type
int
- Parameters
class_name (str) – Message class, the same as PprzMessage.__init__
request_name (str) – Request name (without the _REQ suffix)
callback (Callable[[str, PprzMessage], Any]) – Callback function that accepts two parameters: 1. aircraft id as int 2. The response message
request_extra_data (Dict[str, Any]) – Payload that will be sent with the request if any
- Raises
ValueError: if msg was invalid or sender_id not provided for telemetry messages
- Raises
RuntimeError: if the server is not running
- subscribe(callback, regex_or_msg='(.*)')[source]¶
Subscribe to Ivy message matching regex and call callback with ac_id and PprzMessage
- Parameters
callback – function called on new message with ac_id and PprzMessage as params
regex_or_msg – regular expression for matching message or a PprzMessage object to subscribe to
- subscribe_request_answerer(callback, request_name)[source]¶
Subscribe to advanced request messages.
- Parameters
callback (Callable[[int, PprzMessage], PprzMessage]) – Should return the answer as a PprzMessage
request_name (str) – Request message name to listen to (without _REQ suffix)
- Returns
binding id