AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
|
An interface for sending and receiving ISOBUS guidance messages. More...
#include <isobus_guidance_interface.hpp>
Classes | |
class | GuidanceMachineInfo |
An interface for sending and receiving the ISOBUS agricultural guidance machine message. More... | |
class | GuidanceSystemCommand |
An interface for sending the agricultural guidance system command message. More... | |
Public Member Functions | |
AgriculturalGuidanceInterface (std::shared_ptr< InternalControlFunction > source, std::shared_ptr< ControlFunction > destination, bool enableSendingSystemCommandPeriodically=false, bool enableSendingMachineInfoPeriodically=false) | |
Constructor for a AgriculturalGuidanceInterface. | |
~AgriculturalGuidanceInterface () | |
Destructor for the AgriculturalGuidanceInterface. | |
void | initialize () |
Sets up the class and registers it to receive callbacks from the network manager for processing guidance messages. The class will not receive messages if this is not called. | |
bool | get_initialized () const |
Returns if the interface has been initialized. | |
std::size_t | get_number_received_guidance_system_command_sources () const |
Returns the number of received, unique guidance system command sources. | |
std::size_t | get_number_received_guidance_machine_info_message_sources () const |
Returns the number of received, unique guidance machine info message sources. | |
std::shared_ptr< GuidanceMachineInfo > | get_received_guidance_machine_info (std::size_t index) |
Returns the content of the agricultural guidance machine info message based on the index of the sender. Use this to read the received messages' content. | |
std::shared_ptr< GuidanceSystemCommand > | get_received_guidance_system_command (std::size_t index) |
Returns the content of the agricultural guidance curvature command message based on the index of the sender. Use this to read the received messages' content. | |
EventDispatcher< const std::shared_ptr< GuidanceMachineInfo >, bool > & | get_guidance_machine_info_event_publisher () |
Returns an event dispatcher which you can use to get callbacks when new/updated guidance machine info messages are received. | |
EventDispatcher< const std::shared_ptr< GuidanceSystemCommand >, bool > & | get_guidance_system_command_event_publisher () |
Returns an event dispatcher which you can use to get callbacks when new/updated guidance system command messages are received. | |
void | update () |
Call this cyclically to update the interface. Transmits messages if needed and processes timeouts for received messages. | |
Public Attributes | |
GuidanceMachineInfo | guidanceMachineInfoTransmitData |
Use this to configure the transmission of the guidance machine info message from your application. If you pass in an internal control function to the constructor of this class, then this message is available to be sent. | |
GuidanceSystemCommand | guidanceSystemCommandTransmitData |
Use this to configure transmission the guidance system command message from your application. If you pass in an internal control function to the constructor of this class, then this message is available to be sent. | |
Protected Types | |
enum class | TransmitFlags : std::uint32_t { SendGuidanceSystemCommand = 0 , SendGuidanceMachineInfo , NumberOfFlags } |
Enumerates a set of flags to manage transmitting messages owned by this interface. More... | |
Protected Member Functions | |
bool | send_guidance_machine_info () const |
Sends the agricultural guidance machine info message based on the configured content of guidanceMachineInfoTransmitData. | |
bool | send_guidance_system_command () const |
Sends the agricultural guidance system command message based on the configured content of guidanceSystemCommandTransmitData. | |
Static Protected Member Functions | |
static void | process_flags (std::uint32_t flag, void *parentPointer) |
Processes one flag (which sends the associated message) | |
static void | process_rx_message (const CANMessage &message, void *parentPointer) |
Processes a CAN message. | |
Protected Attributes | |
ProcessingFlags | txFlags |
Tx flag for sending messages periodically. | |
EventDispatcher< const std::shared_ptr< GuidanceMachineInfo >, bool > | guidanceMachineInfoEventPublisher |
An event publisher for notifying when new guidance machine info messages are received. | |
EventDispatcher< const std::shared_ptr< GuidanceSystemCommand >, bool > | guidanceSystemCommandEventPublisher |
An event publisher for notifying when new guidance system commands are received. | |
std::shared_ptr< ControlFunction > | destinationControlFunction |
The optional destination to which messages will be sent. If nullptr it will be broadcast instead. | |
std::vector< std::shared_ptr< GuidanceMachineInfo > > | receivedGuidanceMachineInfoMessages |
A list of all received estimated curvatures. | |
std::vector< std::shared_ptr< GuidanceSystemCommand > > | receivedGuidanceSystemCommandMessages |
A list of all received curvature commands and statuses. | |
std::uint32_t | guidanceSystemCommandTransmitTimestamp_ms = 0 |
Timestamp used to know when to transmit the guidance system command message. | |
std::uint32_t | guidanceMachineInfoTransmitTimestamp_ms = 0 |
Timestamp used to know when to transmit the guidance machine info message. | |
bool | initialized = false |
Stores if the interface has been initialized. | |
Static Protected Attributes | |
static constexpr std::uint32_t | GUIDANCE_MESSAGE_TX_INTERVAL_MS = 100 |
How often guidance messages are sent, defined in ISO 11783-7. | |
static constexpr std::uint32_t | GUIDANCE_MESSAGE_TIMEOUT_MS = 150 |
Amount of time before a guidance message is stale. We currently tolerate 50ms of delay. | |
static constexpr float | CURVATURE_COMMAND_OFFSET_INVERSE_KM = 8032.0f |
Constant offset for curvature being sent on the bus in km-1. | |
static constexpr float | CURVATURE_COMMAND_MAX_INVERSE_KM = 8031.75f |
The maximum curvature that can be encoded once scaling is applied. | |
static constexpr float | CURVATURE_COMMAND_RESOLUTION_PER_BIT = 0.25f |
The resolution of the message in km-1 per bit. | |
static constexpr std::uint16_t | ZERO_CURVATURE_INVERSE_KM = 32128 |
This is the value for zero km-1 for 0.25 km-1 per bit. | |
An interface for sending and receiving ISOBUS guidance messages.
Definition at line 35 of file isobus_guidance_interface.hpp.
|
strongprotected |
Enumerates a set of flags to manage transmitting messages owned by this interface.
Definition at line 363 of file isobus_guidance_interface.hpp.
isobus::AgriculturalGuidanceInterface::AgriculturalGuidanceInterface | ( | std::shared_ptr< InternalControlFunction > | source, |
std::shared_ptr< ControlFunction > | destination, | ||
bool | enableSendingSystemCommandPeriodically = false, | ||
bool | enableSendingMachineInfoPeriodically = false ) |
Constructor for a AgriculturalGuidanceInterface.
[in] | source | The internal control function to use when sending messages, or nullptr for listen only |
[in] | destination | The destination control function for transmitted messages, or nullptr for broadcasts |
[in] | enableSendingSystemCommandPeriodically | If true, the system command message will be sent periodically. This should (only) be used by an guidance application trying to steer a machine. |
[in] | enableSendingMachineInfoPeriodically | If true, the machine info message will be sent periodically. This should (only) be used by the steering controller itself. |
Definition at line 37 of file isobus_guidance_interface.cpp.
isobus::AgriculturalGuidanceInterface::~AgriculturalGuidanceInterface | ( | ) |
Destructor for the AgriculturalGuidanceInterface.
Definition at line 48 of file isobus_guidance_interface.cpp.
EventDispatcher< const std::shared_ptr< AgriculturalGuidanceInterface::GuidanceMachineInfo >, bool > & isobus::AgriculturalGuidanceInterface::get_guidance_machine_info_event_publisher | ( | ) |
Returns an event dispatcher which you can use to get callbacks when new/updated guidance machine info messages are received.
Definition at line 299 of file isobus_guidance_interface.cpp.
EventDispatcher< const std::shared_ptr< AgriculturalGuidanceInterface::GuidanceSystemCommand >, bool > & isobus::AgriculturalGuidanceInterface::get_guidance_system_command_event_publisher | ( | ) |
Returns an event dispatcher which you can use to get callbacks when new/updated guidance system command messages are received.
Definition at line 304 of file isobus_guidance_interface.cpp.
bool isobus::AgriculturalGuidanceInterface::get_initialized | ( | ) | const |
Returns if the interface has been initialized.
Definition at line 262 of file isobus_guidance_interface.cpp.
std::size_t isobus::AgriculturalGuidanceInterface::get_number_received_guidance_machine_info_message_sources | ( | ) | const |
Returns the number of received, unique guidance machine info message sources.
Definition at line 272 of file isobus_guidance_interface.cpp.
std::size_t isobus::AgriculturalGuidanceInterface::get_number_received_guidance_system_command_sources | ( | ) | const |
Returns the number of received, unique guidance system command sources.
Definition at line 267 of file isobus_guidance_interface.cpp.
std::shared_ptr< AgriculturalGuidanceInterface::GuidanceMachineInfo > isobus::AgriculturalGuidanceInterface::get_received_guidance_machine_info | ( | std::size_t | index | ) |
Returns the content of the agricultural guidance machine info message based on the index of the sender. Use this to read the received messages' content.
[in] | index | An index of senders of the agricultural guidance machine info message |
Definition at line 277 of file isobus_guidance_interface.cpp.
std::shared_ptr< AgriculturalGuidanceInterface::GuidanceSystemCommand > isobus::AgriculturalGuidanceInterface::get_received_guidance_system_command | ( | std::size_t | index | ) |
Returns the content of the agricultural guidance curvature command message based on the index of the sender. Use this to read the received messages' content.
[in] | index | An index of senders of the agricultural guidance curvature command message |
Definition at line 288 of file isobus_guidance_interface.cpp.
void isobus::AgriculturalGuidanceInterface::initialize | ( | ) |
Sets up the class and registers it to receive callbacks from the network manager for processing guidance messages. The class will not receive messages if this is not called.
Definition at line 247 of file isobus_guidance_interface.cpp.
|
staticprotected |
Processes one flag (which sends the associated message)
[in] | flag | The flag to process |
[in] | parentPointer | A pointer to the interface instance |
Definition at line 438 of file isobus_guidance_interface.cpp.
|
staticprotected |
Processes a CAN message.
[in] | message | The CAN message being received |
[in] | parentPointer | A context variable to find the relevant instance of this class |
Definition at line 470 of file isobus_guidance_interface.cpp.
|
protected |
Sends the agricultural guidance machine info message based on the configured content of guidanceMachineInfoTransmitData.
Definition at line 352 of file isobus_guidance_interface.cpp.
|
protected |
Sends the agricultural guidance system command message based on the configured content of guidanceSystemCommandTransmitData.
Definition at line 309 of file isobus_guidance_interface.cpp.
void isobus::AgriculturalGuidanceInterface::update | ( | ) |
Call this cyclically to update the interface. Transmits messages if needed and processes timeouts for received messages.
Definition at line 401 of file isobus_guidance_interface.cpp.
|
staticconstexprprotected |
The maximum curvature that can be encoded once scaling is applied.
Definition at line 384 of file isobus_guidance_interface.hpp.
|
staticconstexprprotected |
Constant offset for curvature being sent on the bus in km-1.
Definition at line 383 of file isobus_guidance_interface.hpp.
|
staticconstexprprotected |
The resolution of the message in km-1 per bit.
Definition at line 385 of file isobus_guidance_interface.hpp.
|
protected |
The optional destination to which messages will be sent. If nullptr it will be broadcast instead.
Definition at line 399 of file isobus_guidance_interface.hpp.
|
staticconstexprprotected |
Amount of time before a guidance message is stale. We currently tolerate 50ms of delay.
Definition at line 382 of file isobus_guidance_interface.hpp.
|
staticconstexprprotected |
How often guidance messages are sent, defined in ISO 11783-7.
Definition at line 381 of file isobus_guidance_interface.hpp.
|
protected |
An event publisher for notifying when new guidance machine info messages are received.
Definition at line 397 of file isobus_guidance_interface.hpp.
GuidanceMachineInfo isobus::AgriculturalGuidanceInterface::guidanceMachineInfoTransmitData |
Use this to configure the transmission of the guidance machine info message from your application. If you pass in an internal control function to the constructor of this class, then this message is available to be sent.
Definition at line 319 of file isobus_guidance_interface.hpp.
|
protected |
Timestamp used to know when to transmit the guidance machine info message.
Definition at line 403 of file isobus_guidance_interface.hpp.
|
protected |
An event publisher for notifying when new guidance system commands are received.
Definition at line 398 of file isobus_guidance_interface.hpp.
GuidanceSystemCommand isobus::AgriculturalGuidanceInterface::guidanceSystemCommandTransmitData |
Use this to configure transmission the guidance system command message from your application. If you pass in an internal control function to the constructor of this class, then this message is available to be sent.
Definition at line 323 of file isobus_guidance_interface.hpp.
|
protected |
Timestamp used to know when to transmit the guidance system command message.
Definition at line 402 of file isobus_guidance_interface.hpp.
|
protected |
Stores if the interface has been initialized.
Definition at line 404 of file isobus_guidance_interface.hpp.
|
protected |
A list of all received estimated curvatures.
Definition at line 400 of file isobus_guidance_interface.hpp.
|
protected |
A list of all received curvature commands and statuses.
Definition at line 401 of file isobus_guidance_interface.hpp.
|
protected |
Tx flag for sending messages periodically.
Definition at line 396 of file isobus_guidance_interface.hpp.
|
staticconstexprprotected |
This is the value for zero km-1 for 0.25 km-1 per bit.
Definition at line 386 of file isobus_guidance_interface.hpp.