AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
Classes | Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
isobus::AgriculturalGuidanceInterface Class Reference

An interface for sending and receiving ISOBUS guidance messages. More...

#include <isobus_guidance_interface.hpp>

Collaboration diagram for isobus::AgriculturalGuidanceInterface:
[legend]

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< GuidanceMachineInfoget_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< GuidanceSystemCommandget_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< ControlFunctiondestinationControlFunction
 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.
 

Detailed Description

An interface for sending and receiving ISOBUS guidance messages.

Definition at line 35 of file isobus_guidance_interface.hpp.

Member Enumeration Documentation

◆ TransmitFlags

enum class isobus::AgriculturalGuidanceInterface::TransmitFlags : std::uint32_t
strongprotected

Enumerates a set of flags to manage transmitting messages owned by this interface.

Enumerator
SendGuidanceSystemCommand 

A flag to manage sending the guidance system command message.

SendGuidanceMachineInfo 

A flag to manage sending the guidance machine info message.

NumberOfFlags 

The number of flags in this enumeration.

Definition at line 363 of file isobus_guidance_interface.hpp.

Constructor & Destructor Documentation

◆ AgriculturalGuidanceInterface()

isobus::AgriculturalGuidanceInterface::AgriculturalGuidanceInterface ( std::shared_ptr< InternalControlFunction > source,
std::shared_ptr< ControlFunction > destination,
bool enableSendingSystemCommandPeriodically = false,
bool enableSendingMachineInfoPeriodically = false )

Constructor for a AgriculturalGuidanceInterface.

Parameters
[in]sourceThe internal control function to use when sending messages, or nullptr for listen only
[in]destinationThe destination control function for transmitted messages, or nullptr for broadcasts
[in]enableSendingSystemCommandPeriodicallyIf true, the system command message will be sent periodically. This should (only) be used by an guidance application trying to steer a machine.
[in]enableSendingMachineInfoPeriodicallyIf 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.

◆ ~AgriculturalGuidanceInterface()

isobus::AgriculturalGuidanceInterface::~AgriculturalGuidanceInterface ( )

Destructor for the AgriculturalGuidanceInterface.

Definition at line 48 of file isobus_guidance_interface.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ get_guidance_machine_info_event_publisher()

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.

Returns
The event publisher for guidance machine info messages

Definition at line 299 of file isobus_guidance_interface.cpp.

◆ get_guidance_system_command_event_publisher()

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.

Returns
The event publisher for guidance system command messages

Definition at line 304 of file isobus_guidance_interface.cpp.

◆ get_initialized()

bool isobus::AgriculturalGuidanceInterface::get_initialized ( ) const

Returns if the interface has been initialized.

Returns
true if initialize has been called for this interface, otherwise false

Definition at line 262 of file isobus_guidance_interface.cpp.

◆ get_number_received_guidance_machine_info_message_sources()

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.

Returns
The number of CFs sending the guidance machine info message either as a broadcast, or to our internal control function

Definition at line 272 of file isobus_guidance_interface.cpp.

◆ get_number_received_guidance_system_command_sources()

std::size_t isobus::AgriculturalGuidanceInterface::get_number_received_guidance_system_command_sources ( ) const

Returns the number of received, unique guidance system command sources.

Returns
The number of CFs sending the guidance system command either as a broadcast, or to our internal control function

Definition at line 267 of file isobus_guidance_interface.cpp.

◆ get_received_guidance_machine_info()

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.

Parameters
[in]indexAn index of senders of the agricultural guidance machine info message
Note
Only one device on the bus will send this normally, but we provide a generic way to get an arbitrary number of these commands. So generally using only index 0 will be acceptable.
Returns
The content of the agricultural guidance machine info message

Definition at line 277 of file isobus_guidance_interface.cpp.

◆ get_received_guidance_system_command()

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.

Parameters
[in]indexAn index of senders of the agricultural guidance curvature command message
Note
Only one device on the bus will send this normally, but we provide a generic way to get an arbitrary number of these commands. So generally using only index 0 will be acceptable.
Returns
The content of the agricultural guidance curvature command message

Definition at line 288 of file isobus_guidance_interface.cpp.

◆ initialize()

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.

Here is the call graph for this function:

◆ process_flags()

void isobus::AgriculturalGuidanceInterface::process_flags ( std::uint32_t flag,
void * parentPointer )
staticprotected

Processes one flag (which sends the associated message)

Parameters
[in]flagThe flag to process
[in]parentPointerA pointer to the interface instance

Definition at line 438 of file isobus_guidance_interface.cpp.

◆ process_rx_message()

void isobus::AgriculturalGuidanceInterface::process_rx_message ( const CANMessage & message,
void * parentPointer )
staticprotected

Processes a CAN message.

Parameters
[in]messageThe CAN message being received
[in]parentPointerA context variable to find the relevant instance of this class

Definition at line 470 of file isobus_guidance_interface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_guidance_machine_info()

bool isobus::AgriculturalGuidanceInterface::send_guidance_machine_info ( ) const
protected

Sends the agricultural guidance machine info message based on the configured content of guidanceMachineInfoTransmitData.

Returns
true if the message was sent, otherwise false

Definition at line 352 of file isobus_guidance_interface.cpp.

Here is the call graph for this function:

◆ send_guidance_system_command()

bool isobus::AgriculturalGuidanceInterface::send_guidance_system_command ( ) const
protected

Sends the agricultural guidance system command message based on the configured content of guidanceSystemCommandTransmitData.

Returns
true if the message was sent, otherwise false

Definition at line 309 of file isobus_guidance_interface.cpp.

Here is the call graph for this function:

◆ update()

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.

Here is the call graph for this function:

Member Data Documentation

◆ CURVATURE_COMMAND_MAX_INVERSE_KM

constexpr float isobus::AgriculturalGuidanceInterface::CURVATURE_COMMAND_MAX_INVERSE_KM = 8031.75f
staticconstexprprotected

The maximum curvature that can be encoded once scaling is applied.

Definition at line 384 of file isobus_guidance_interface.hpp.

◆ CURVATURE_COMMAND_OFFSET_INVERSE_KM

constexpr float isobus::AgriculturalGuidanceInterface::CURVATURE_COMMAND_OFFSET_INVERSE_KM = 8032.0f
staticconstexprprotected

Constant offset for curvature being sent on the bus in km-1.

Definition at line 383 of file isobus_guidance_interface.hpp.

◆ CURVATURE_COMMAND_RESOLUTION_PER_BIT

constexpr float isobus::AgriculturalGuidanceInterface::CURVATURE_COMMAND_RESOLUTION_PER_BIT = 0.25f
staticconstexprprotected

The resolution of the message in km-1 per bit.

Definition at line 385 of file isobus_guidance_interface.hpp.

◆ destinationControlFunction

std::shared_ptr<ControlFunction> isobus::AgriculturalGuidanceInterface::destinationControlFunction
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.

◆ GUIDANCE_MESSAGE_TIMEOUT_MS

constexpr std::uint32_t isobus::AgriculturalGuidanceInterface::GUIDANCE_MESSAGE_TIMEOUT_MS = 150
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.

◆ GUIDANCE_MESSAGE_TX_INTERVAL_MS

constexpr std::uint32_t isobus::AgriculturalGuidanceInterface::GUIDANCE_MESSAGE_TX_INTERVAL_MS = 100
staticconstexprprotected

How often guidance messages are sent, defined in ISO 11783-7.

Definition at line 381 of file isobus_guidance_interface.hpp.

◆ guidanceMachineInfoEventPublisher

EventDispatcher<const std::shared_ptr<GuidanceMachineInfo>, bool> isobus::AgriculturalGuidanceInterface::guidanceMachineInfoEventPublisher
protected

An event publisher for notifying when new guidance machine info messages are received.

Definition at line 397 of file isobus_guidance_interface.hpp.

◆ guidanceMachineInfoTransmitData

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.

◆ guidanceMachineInfoTransmitTimestamp_ms

std::uint32_t isobus::AgriculturalGuidanceInterface::guidanceMachineInfoTransmitTimestamp_ms = 0
protected

Timestamp used to know when to transmit the guidance machine info message.

Definition at line 403 of file isobus_guidance_interface.hpp.

◆ guidanceSystemCommandEventPublisher

EventDispatcher<const std::shared_ptr<GuidanceSystemCommand>, bool> isobus::AgriculturalGuidanceInterface::guidanceSystemCommandEventPublisher
protected

An event publisher for notifying when new guidance system commands are received.

Definition at line 398 of file isobus_guidance_interface.hpp.

◆ guidanceSystemCommandTransmitData

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.

◆ guidanceSystemCommandTransmitTimestamp_ms

std::uint32_t isobus::AgriculturalGuidanceInterface::guidanceSystemCommandTransmitTimestamp_ms = 0
protected

Timestamp used to know when to transmit the guidance system command message.

Definition at line 402 of file isobus_guidance_interface.hpp.

◆ initialized

bool isobus::AgriculturalGuidanceInterface::initialized = false
protected

Stores if the interface has been initialized.

Definition at line 404 of file isobus_guidance_interface.hpp.

◆ receivedGuidanceMachineInfoMessages

std::vector<std::shared_ptr<GuidanceMachineInfo> > isobus::AgriculturalGuidanceInterface::receivedGuidanceMachineInfoMessages
protected

A list of all received estimated curvatures.

Definition at line 400 of file isobus_guidance_interface.hpp.

◆ receivedGuidanceSystemCommandMessages

std::vector<std::shared_ptr<GuidanceSystemCommand> > isobus::AgriculturalGuidanceInterface::receivedGuidanceSystemCommandMessages
protected

A list of all received curvature commands and statuses.

Definition at line 401 of file isobus_guidance_interface.hpp.

◆ txFlags

ProcessingFlags isobus::AgriculturalGuidanceInterface::txFlags
protected

Tx flag for sending messages periodically.

Definition at line 396 of file isobus_guidance_interface.hpp.

◆ ZERO_CURVATURE_INVERSE_KM

constexpr std::uint16_t isobus::AgriculturalGuidanceInterface::ZERO_CURVATURE_INVERSE_KM = 32128
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.


The documentation for this class was generated from the following files: