AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
isobus_guidance_interface.cpp
Go to the documentation of this file.
1//================================================================================================
21//================================================================================================
27#include "isobus/utility/system_timing.hpp"
28
29#include <algorithm>
30#include <cassert>
31#include <cmath>
32#include <limits>
33#include <memory>
34
35namespace isobus
36{
37 AgriculturalGuidanceInterface::AgriculturalGuidanceInterface(std::shared_ptr<InternalControlFunction> source,
38 std::shared_ptr<ControlFunction> destination,
39 bool enableSendingSystemCommandPeriodically,
40 bool enableSendingMachineInfoPeriodically) :
41 guidanceMachineInfoTransmitData(GuidanceMachineInfo(enableSendingMachineInfoPeriodically ? source : nullptr)),
42 guidanceSystemCommandTransmitData(GuidanceSystemCommand(enableSendingSystemCommandPeriodically ? source : nullptr)),
43 txFlags(static_cast<std::uint32_t>(TransmitFlags::NumberOfFlags), process_flags, this),
44 destinationControlFunction(destination)
45 {
46 }
47
49 {
50 if (initialized)
51 {
52 CANNetworkManager::CANNetwork.remove_any_control_function_parameter_group_number_callback(static_cast<std::uint32_t>(CANLibParameterGroupNumber::AgriculturalGuidanceMachineInfo), process_rx_message, this);
53 CANNetworkManager::CANNetwork.remove_any_control_function_parameter_group_number_callback(static_cast<std::uint32_t>(CANLibParameterGroupNumber::AgriculturalGuidanceSystemCommand), process_rx_message, this);
54 }
55 }
56
58 controlFunction(sender)
59 {
60 }
61
63 {
64 if (commandedStatus != newStatus)
65 {
66 commandedStatus = newStatus;
67 return true;
68 }
69 return false;
70 }
71
76
78 {
79 if (std::fabs(commandedCurvature - curvature) > std::numeric_limits<float>::epsilon())
80 {
81 commandedCurvature = curvature;
82 return true;
83 }
84 return false;
85 }
86
88 {
89 return commandedCurvature;
90 }
91
93 {
94 return controlFunction;
95 }
96
98 {
99 timestamp_ms = timestamp;
100 }
101
103 {
104 return timestamp_ms;
105 }
106
108 controlFunction(sender)
109 {
110 }
111
113 {
114 if (std::fabs(estimatedCurvature - curvature) > std::numeric_limits<float>::epsilon())
115 {
116 estimatedCurvature = curvature;
117 return true;
118 }
119 return false;
120 }
121
123 {
124 return estimatedCurvature;
125 }
126
128 {
129 if (mechanicalSystemLockoutState != state)
130 {
131 mechanicalSystemLockoutState = state;
132 return true;
133 }
134 return false;
135 }
136
141
143 {
144 if (guidanceSteeringSystemReadinessState != state)
145 {
146 guidanceSteeringSystemReadinessState = state;
147 return true;
148 }
149 return false;
150 }
151
156
158 {
159 if (guidanceSteeringInputPositionStatus != state)
160 {
161 guidanceSteeringInputPositionStatus = state;
162 return true;
163 }
164 return false;
165 }
166
171
173 {
174 if (requestResetCommandStatus != state)
175 {
176 requestResetCommandStatus = state;
177 return true;
178 }
179 return false;
180 }
181
186
188 {
189 if (guidanceLimitStatus != status)
190 {
191 guidanceLimitStatus = status;
192 return true;
193 }
194 return false;
195 }
196
201
203 {
204 if (guidanceSystemCommandExitReasonCode != exitCode)
205 {
206 guidanceSystemCommandExitReasonCode = exitCode;
207 return true;
208 }
209 return false;
210 }
211
213 {
214 return guidanceSystemCommandExitReasonCode;
215 }
216
218 {
219 if (guidanceSystemRemoteEngageSwitchStatus != switchStatus)
220 {
221 guidanceSystemRemoteEngageSwitchStatus = switchStatus;
222 return true;
223 }
224 return false;
225 }
226
231
233 {
234 return controlFunction;
235 }
236
238 {
239 timestamp_ms = timestamp;
240 }
241
243 {
244 return timestamp_ms;
245 }
246
248 {
249 if (!initialized)
250 {
252 {
253 // Make sure you know what you are doing... consider reviewing the guidance messaging in ISO 11783-7 if you haven't already.
254 LOG_WARNING("[Guidance]: Use extreme caution! You have configured the ISOBUS guidance interface with the ability to steer a machine.");
255 }
256 CANNetworkManager::CANNetwork.add_any_control_function_parameter_group_number_callback(static_cast<std::uint32_t>(CANLibParameterGroupNumber::AgriculturalGuidanceMachineInfo), process_rx_message, this);
257 CANNetworkManager::CANNetwork.add_any_control_function_parameter_group_number_callback(static_cast<std::uint32_t>(CANLibParameterGroupNumber::AgriculturalGuidanceSystemCommand), process_rx_message, this);
258 initialized = true;
259 }
260 }
261
266
271
276
277 std::shared_ptr<AgriculturalGuidanceInterface::GuidanceMachineInfo> AgriculturalGuidanceInterface::get_received_guidance_machine_info(std::size_t index)
278 {
279 std::shared_ptr<AgriculturalGuidanceInterface::GuidanceMachineInfo> retVal = nullptr;
280
281 if (index < receivedGuidanceMachineInfoMessages.size())
282 {
283 retVal = receivedGuidanceMachineInfoMessages.at(index);
284 }
285 return retVal;
286 }
287
288 std::shared_ptr<AgriculturalGuidanceInterface::GuidanceSystemCommand> AgriculturalGuidanceInterface::get_received_guidance_system_command(std::size_t index)
289 {
290 std::shared_ptr<AgriculturalGuidanceInterface::GuidanceSystemCommand> retVal = nullptr;
291
292 if (index < receivedGuidanceSystemCommandMessages.size())
293 {
294 retVal = receivedGuidanceSystemCommandMessages.at(index);
295 }
296 return retVal;
297 }
298
299 EventDispatcher<const std::shared_ptr<AgriculturalGuidanceInterface::GuidanceMachineInfo>, bool> &AgriculturalGuidanceInterface::get_guidance_machine_info_event_publisher()
300 {
302 }
303
304 EventDispatcher<const std::shared_ptr<AgriculturalGuidanceInterface::GuidanceSystemCommand>, bool> &AgriculturalGuidanceInterface::get_guidance_system_command_event_publisher()
305 {
307 }
308
310 {
311 bool retVal = false;
312
314 {
316 std::uint16_t encodedCurvature = ZERO_CURVATURE_INVERSE_KM;
317
319 {
320 encodedCurvature = 32127 + ZERO_CURVATURE_INVERSE_KM; // Clamp to maximum value
321 LOG_WARNING("[Guidance]: Transmitting a commanded curvature clamped to maximum value. Verify guidance calculations are accurate!");
322 }
323 else if (scaledCurvature < 0) // 0 In this case is -8032 km-1 due to the addition of the offset earlier
324 {
325 encodedCurvature = 0; // Clamp to minimum value
326 LOG_WARNING("[Guidance]: Transmitting a commanded curvature clamped to minimum value. Verify guidance calculations are accurate!");
327 }
328 else
329 {
330 encodedCurvature = static_cast<std::uint16_t>(scaledCurvature);
331 }
332
333 std::array<std::uint8_t, CAN_DATA_LENGTH> buffer = { static_cast<std::uint8_t>(encodedCurvature & 0xFF),
334 static_cast<std::uint8_t>((encodedCurvature >> 8) & 0xFF),
335 static_cast<std::uint8_t>(static_cast<std::uint8_t>(guidanceSystemCommandTransmitData.get_status()) | static_cast<std::uint8_t>(0xFC)),
336 0xFF,
337 0xFF,
338 0xFF,
339 0xFF,
340 0xFF };
341
342 retVal = CANNetworkManager::CANNetwork.send_can_message(static_cast<std::uint32_t>(CANLibParameterGroupNumber::AgriculturalGuidanceSystemCommand),
343 buffer.data(),
344 buffer.size(),
345 std::static_pointer_cast<InternalControlFunction>(guidanceSystemCommandTransmitData.get_sender_control_function()),
348 }
349 return retVal;
350 }
351
353 {
354 bool retVal = false;
355
357 {
359 std::uint16_t encodedCurvature = ZERO_CURVATURE_INVERSE_KM;
360
362 {
363 encodedCurvature = 32127 + ZERO_CURVATURE_INVERSE_KM; // Clamp to maximum value
364 LOG_WARNING("[Guidance]: Transmitting an estimated curvature clamped to maximum value. Verify guidance calculations are accurate!");
365 }
366 else if (scaledCurvature < 0) // 0 In this case is -8032 km-1 due to the addition of the offset earlier
367 {
368 encodedCurvature = 0; // Clamp to minimum value
369 LOG_WARNING("[Guidance]: Transmitting an estimated curvature clamped to minimum value. Verify guidance calculations are accurate!");
370 }
371 else
372 {
373 encodedCurvature = static_cast<std::uint16_t>(scaledCurvature);
374 }
375
376 std::array<std::uint8_t, CAN_DATA_LENGTH> buffer = {
377 static_cast<std::uint8_t>(encodedCurvature & 0xFF),
378 static_cast<std::uint8_t>((encodedCurvature >> 8) & 0xFF),
379 static_cast<std::uint8_t>((static_cast<std::uint8_t>(guidanceMachineInfoTransmitData.get_mechanical_system_lockout()) & 0x03) |
380 ((static_cast<std::uint8_t>(guidanceMachineInfoTransmitData.get_guidance_steering_system_readiness_state()) & 0x03) << 2) |
381 ((static_cast<std::uint8_t>(guidanceMachineInfoTransmitData.get_guidance_steering_input_position_status()) & 0x03) << 4) |
382 ((static_cast<std::uint8_t>(guidanceMachineInfoTransmitData.get_request_reset_command_status()) & 0x03) << 6)),
383 static_cast<std::uint8_t>(static_cast<std::uint8_t>(guidanceMachineInfoTransmitData.get_guidance_limit_status()) << 5),
386 0xFF, // Reserved
387 0xFF, // Reserved
388 0xFF // Reserved
389 };
390
391 retVal = CANNetworkManager::CANNetwork.send_can_message(static_cast<std::uint32_t>(CANLibParameterGroupNumber::AgriculturalGuidanceMachineInfo),
392 buffer.data(),
393 buffer.size(),
394 std::static_pointer_cast<InternalControlFunction>(guidanceMachineInfoTransmitData.get_sender_control_function()),
397 }
398 return retVal;
399 }
400
402 {
403 if (initialized)
404 {
407 [](std::shared_ptr<GuidanceMachineInfo> guidanceInfo) {
408 return SystemTiming::time_expired_ms(guidanceInfo->get_timestamp_ms(), GUIDANCE_MESSAGE_TIMEOUT_MS);
409 }),
413 [](std::shared_ptr<GuidanceSystemCommand> guidanceCommand) {
414 return SystemTiming::time_expired_ms(guidanceCommand->get_timestamp_ms(), GUIDANCE_MESSAGE_TIMEOUT_MS);
415 }),
417
420 {
421 txFlags.set_flag(static_cast<std::uint32_t>(TransmitFlags::SendGuidanceMachineInfo));
422 guidanceMachineInfoTransmitTimestamp_ms = SystemTiming::get_timestamp_ms();
423 }
426 {
427 txFlags.set_flag(static_cast<std::uint32_t>(TransmitFlags::SendGuidanceSystemCommand));
428 guidanceSystemCommandTransmitTimestamp_ms = SystemTiming::get_timestamp_ms();
429 }
430 txFlags.process_all_flags();
431 }
432 else
433 {
434 LOG_ERROR("[Guidance]: Guidance interface has not been initialized yet.");
435 }
436 }
437
438 void AgriculturalGuidanceInterface::process_flags(std::uint32_t flag, void *parentPointer)
439 {
440 if (nullptr != parentPointer)
441 {
442 auto targetInterface = static_cast<AgriculturalGuidanceInterface *>(parentPointer);
443 bool transmitSuccessful = false;
444
445 switch (flag)
446 {
447 case static_cast<std::uint32_t>(TransmitFlags::SendGuidanceMachineInfo):
448 {
449 transmitSuccessful = targetInterface->send_guidance_machine_info();
450 }
451 break;
452
453 case static_cast<std::uint32_t>(TransmitFlags::SendGuidanceSystemCommand):
454 {
455 transmitSuccessful = targetInterface->send_guidance_system_command();
456 }
457 break;
458
459 default:
460 break;
461 }
462
463 if (false == transmitSuccessful)
464 {
465 targetInterface->txFlags.set_flag(flag);
466 }
467 }
468 }
469
470 void AgriculturalGuidanceInterface::process_rx_message(const CANMessage &message, void *parentPointer)
471 {
472 assert(nullptr != parentPointer);
473 auto targetInterface = static_cast<AgriculturalGuidanceInterface *>(parentPointer);
474
475 switch (message.get_identifier().get_parameter_group_number())
476 {
477 case static_cast<std::uint32_t>(CANLibParameterGroupNumber::AgriculturalGuidanceSystemCommand):
478 {
479 if (CAN_DATA_LENGTH == message.get_data_length())
480 {
481 if (message.get_source_control_function() != nullptr)
482 {
483 auto result = std::find_if(targetInterface->receivedGuidanceSystemCommandMessages.begin(),
484 targetInterface->receivedGuidanceSystemCommandMessages.end(),
485 [&message](const std::shared_ptr<GuidanceSystemCommand> &receivedCommand) {
486 return (nullptr != receivedCommand) && (receivedCommand->get_sender_control_function() == message.get_source_control_function());
487 });
488
489 if (result == targetInterface->receivedGuidanceSystemCommandMessages.end())
490 {
491 // There is no existing message object from this control function, so create a new one
492 targetInterface->receivedGuidanceSystemCommandMessages.push_back(std::make_shared<GuidanceSystemCommand>(message.get_source_control_function()));
493 result = targetInterface->receivedGuidanceSystemCommandMessages.end() - 1;
494 }
495
496 auto guidanceCommand = *result;
497 bool changed = false;
498
499 changed |= guidanceCommand->set_curvature((message.get_uint16_at(0) * CURVATURE_COMMAND_RESOLUTION_PER_BIT) - CURVATURE_COMMAND_OFFSET_INVERSE_KM);
500 changed |= guidanceCommand->set_status(static_cast<GuidanceSystemCommand::CurvatureCommandStatus>(message.get_uint8_at(2) & 0x03));
501 guidanceCommand->set_timestamp_ms(SystemTiming::get_timestamp_ms());
502
503 targetInterface->guidanceSystemCommandEventPublisher.call(guidanceCommand, changed);
504 }
505 }
506 else
507 {
508 LOG_WARNING("[Guidance]: Received a malformed guidance system command message. DLC must be 8.");
509 }
510 }
511 break;
512
513 case static_cast<std::uint32_t>(CANLibParameterGroupNumber::AgriculturalGuidanceMachineInfo):
514 {
515 if (CAN_DATA_LENGTH == message.get_data_length())
516 {
517 if (message.get_source_control_function() != nullptr)
518 {
519 auto result = std::find_if(targetInterface->receivedGuidanceMachineInfoMessages.cbegin(),
520 targetInterface->receivedGuidanceMachineInfoMessages.cend(),
521 [&message](const std::shared_ptr<GuidanceMachineInfo> &receivedInfo) {
522 return (nullptr != receivedInfo) && (receivedInfo->get_sender_control_function() == message.get_source_control_function());
523 });
524
525 if (result == targetInterface->receivedGuidanceMachineInfoMessages.cend())
526 {
527 // There is no existing message object from this control function, so create a new one
528 targetInterface->receivedGuidanceMachineInfoMessages.push_back(std::make_shared<GuidanceMachineInfo>(message.get_source_control_function()));
529 result = targetInterface->receivedGuidanceMachineInfoMessages.cend() - 1;
530 }
531
532 auto machineInfo = *result;
533 bool changed = false;
534
535 changed |= machineInfo->set_estimated_curvature((message.get_uint16_at(0) * CURVATURE_COMMAND_RESOLUTION_PER_BIT) - CURVATURE_COMMAND_OFFSET_INVERSE_KM);
536 changed |= machineInfo->set_mechanical_system_lockout_state(static_cast<GuidanceMachineInfo::MechanicalSystemLockout>(message.get_uint8_at(2) & 0x03));
537 changed |= machineInfo->set_guidance_steering_system_readiness_state(static_cast<GuidanceMachineInfo::GenericSAEbs02SlotValue>((message.get_uint8_at(2) >> 2) & 0x03));
538 changed |= machineInfo->set_guidance_steering_input_position_status(static_cast<GuidanceMachineInfo::GenericSAEbs02SlotValue>((message.get_uint8_at(2) >> 4) & 0x03));
539 changed |= machineInfo->set_request_reset_command_status(static_cast<GuidanceMachineInfo::RequestResetCommandStatus>((message.get_uint8_at(2) >> 6) & 0x03));
540 changed |= machineInfo->set_guidance_limit_status(static_cast<GuidanceMachineInfo::GuidanceLimitStatus>(message.get_uint8_at(3) >> 5));
541 changed |= machineInfo->set_guidance_system_command_exit_reason_code(message.get_uint8_at(4) & 0x3F);
542 changed |= machineInfo->set_guidance_system_remote_engage_switch_status(static_cast<GuidanceMachineInfo::GenericSAEbs02SlotValue>((message.get_uint8_at(4) >> 6) & 0x03));
543 machineInfo->set_timestamp_ms(SystemTiming::get_timestamp_ms());
544
545 targetInterface->guidanceMachineInfoEventPublisher.call(machineInfo, changed);
546 }
547 }
548 else
549 {
550 LOG_WARNING("[Guidance]: Received a malformed guidance machine info message. DLC must be 8.");
551 }
552 }
553 break;
554
555 default:
556 break;
557 }
558 }
559} // namespace isobus
Defines some PGNs that are used in the library or are very common.
An abstraction of a CAN message, could be > 8 data bytes.
The main class that manages the ISOBUS stack including: callbacks, Name to Address management,...
A class that acts as a logging sink. The intent is that someone could make their own derived class of...
An interface for sending and receiving the ISOBUS agricultural guidance machine message.
bool set_guidance_steering_system_readiness_state(GenericSAEbs02SlotValue state)
Sets the guidance system's readiness state to report.
bool set_guidance_system_command_exit_reason_code(std::uint8_t exitCode)
Sets the exit code for the guidance system.
std::shared_ptr< ControlFunction > get_sender_control_function() const
Returns a pointer to the sender of the message. If an ICF is the sender, returns the ICF being used t...
RequestResetCommandStatus get_request_reset_command_status() const
Returns the reported request reset command.
GenericSAEbs02SlotValue get_guidance_steering_system_readiness_state() const
Returns the guidance system's readiness state for steering.
GenericSAEbs02SlotValue get_guidance_system_remote_engage_switch_status() const
Returns the state for the steering engage switch.
GuidanceLimitStatus
This parameter is used to report the steering system's present limit status associated with guidance ...
GenericSAEbs02SlotValue
A typical, generic 2 bit value in J1939 with no superseding definition in ISO 11783.
bool set_mechanical_system_lockout_state(MechanicalSystemLockout state)
Sets the mechanical system lockout state.
std::uint32_t get_timestamp_ms() const
Returns the timestamp for when the message was received, in milliseconds.
float get_estimated_curvature() const
Returns the estimated curvature that was previously set with set_estimated_curvature.
bool set_guidance_system_remote_engage_switch_status(GenericSAEbs02SlotValue switchStatus)
Sets the state for the steering engage switch.
bool set_request_reset_command_status(RequestResetCommandStatus state)
Sets the request reset command to report.
bool set_guidance_limit_status(GuidanceLimitStatus status)
Sets the reported guidance limit status.
GenericSAEbs02SlotValue get_guidance_steering_input_position_status() const
Returns the guidance steering input position state.
bool set_estimated_curvature(float curvature)
Sets the estimated course curvature over ground for the machine.
MechanicalSystemLockout get_mechanical_system_lockout() const
Returns the mechanical system lockout state.
MechanicalSystemLockout
State of a lockout switch that allows operators to disable automatic steering system functions.
void set_timestamp_ms(std::uint32_t timestamp)
Sets the timestamp for when the message was received or sent.
RequestResetCommandStatus
Machine steering system request to the automatic guidance system to change Curvature Command Status s...
GuidanceLimitStatus get_guidance_limit_status() const
Returns the reported guidance limit status.
std::uint8_t get_guidance_system_command_exit_reason_code() const
Returns the exit code for the guidance system.
GuidanceMachineInfo(std::shared_ptr< ControlFunction > sender)
Constructor for a GuidanceMachineInfo.
bool set_guidance_steering_input_position_status(GenericSAEbs02SlotValue state)
Sets the guidance steering input position state.
An interface for sending the agricultural guidance system command message.
bool set_curvature(float curvature)
Desired course curvature over ground that a machine's steering system is required to achieve.
CurvatureCommandStatus get_status() const
Returns the curvature command status that is active in the guidance system.
std::uint32_t get_timestamp_ms() const
Returns the timestamp for when the message was received, in milliseconds.
bool set_status(CurvatureCommandStatus newStatus)
Sets the curvature command status that will be encoded into the CAN message. This parameter indicates...
float get_curvature() const
Returns the curvature value that is currently be trying to be achieved by the guidance system.
GuidanceSystemCommand(std::shared_ptr< ControlFunction > sender)
Constructor for a GuidanceSystemCommand.
void set_timestamp_ms(std::uint32_t timestamp)
Sets the timestamp for when the message was received or sent.
std::shared_ptr< ControlFunction > get_sender_control_function() const
Returns a pointer to the sender of the message. If an ICF is the sender, returns the ICF being used t...
CurvatureCommandStatus
This parameter indicates whether the guidance system is attempting to control steering with this comm...
An interface for sending and receiving ISOBUS guidance messages.
GuidanceSystemCommand guidanceSystemCommandTransmitData
Use this to configure transmission the guidance system command message from your application....
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...
void update()
Call this cyclically to update the interface. Transmits messages if needed and processes timeouts for...
ProcessingFlags txFlags
Tx flag for sending messages periodically.
void initialize()
Sets up the class and registers it to receive callbacks from the network manager for processing guida...
AgriculturalGuidanceInterface(std::shared_ptr< InternalControlFunction > source, std::shared_ptr< ControlFunction > destination, bool enableSendingSystemCommandPeriodically=false, bool enableSendingMachineInfoPeriodically=false)
Constructor for a AgriculturalGuidanceInterface.
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 comma...
std::uint32_t guidanceSystemCommandTransmitTimestamp_ms
Timestamp used to know when to transmit the guidance system command message.
static constexpr float CURVATURE_COMMAND_MAX_INVERSE_KM
The maximum curvature that can be encoded once scaling is applied.
bool get_initialized() const
Returns if the interface has been initialized.
EventDispatcher< const std::shared_ptr< GuidanceSystemCommand >, bool > guidanceSystemCommandEventPublisher
An event publisher for notifying when new guidance system commands are received.
EventDispatcher< const std::shared_ptr< GuidanceMachineInfo >, bool > guidanceMachineInfoEventPublisher
An event publisher for notifying when new guidance machine info messages are received.
static constexpr float CURVATURE_COMMAND_OFFSET_INVERSE_KM
Constant offset for curvature being sent on the bus in km-1.
static void process_flags(std::uint32_t flag, void *parentPointer)
Processes one flag (which sends the associated message)
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 ...
static constexpr float CURVATURE_COMMAND_RESOLUTION_PER_BIT
The resolution of the message in km-1 per bit.
bool send_guidance_system_command() const
Sends the agricultural guidance system command message based on the configured content of guidanceSys...
std::vector< std::shared_ptr< GuidanceSystemCommand > > receivedGuidanceSystemCommandMessages
A list of all received curvature commands and statuses.
bool send_guidance_machine_info() const
Sends the agricultural guidance machine info message based on the configured content of guidanceMachi...
static void process_rx_message(const CANMessage &message, void *parentPointer)
Processes a CAN message.
std::uint32_t guidanceMachineInfoTransmitTimestamp_ms
Timestamp used to know when to transmit the guidance machine info message.
std::vector< std::shared_ptr< GuidanceMachineInfo > > receivedGuidanceMachineInfoMessages
A list of all received estimated curvatures.
TransmitFlags
Enumerates a set of flags to manage transmitting messages owned by this interface.
@ SendGuidanceSystemCommand
A flag to manage sending the guidance system command message.
@ SendGuidanceMachineInfo
A flag to manage sending the guidance machine info message.
std::size_t get_number_received_guidance_system_command_sources() const
Returns the number of received, unique guidance system command sources.
std::shared_ptr< ControlFunction > destinationControlFunction
The optional destination to which messages will be sent. If nullptr it will be broadcast instead.
bool initialized
Stores if the interface has been initialized.
std::size_t get_number_received_guidance_machine_info_message_sources() const
Returns the number of received, unique guidance machine info message sources.
static constexpr std::uint16_t ZERO_CURVATURE_INVERSE_KM
This is the value for zero km-1 for 0.25 km-1 per bit.
~AgriculturalGuidanceInterface()
Destructor for the AgriculturalGuidanceInterface.
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 sende...
GuidanceMachineInfo guidanceMachineInfoTransmitData
Use this to configure the transmission of the guidance machine info message from your application....
static constexpr std::uint32_t GUIDANCE_MESSAGE_TX_INTERVAL_MS
How often guidance messages are sent, defined in ISO 11783-7.
@ Priority3
Priority highest - 3 (Control messages priority)
std::uint32_t get_parameter_group_number() const
Returns the PGN encoded in the identifier.
A class that represents a generic CAN message of arbitrary length.
std::uint32_t get_data_length() const
Returns the length of the data in the CAN message.
std::shared_ptr< ControlFunction > get_source_control_function() const
Gets the source control function that the message is from.
std::uint8_t get_uint8_at(const std::uint32_t index) const
Get a 8-bit unsigned byte from the buffer at a specific index. A 8-bit unsigned byte can hold a value...
std::uint16_t get_uint16_at(const std::uint32_t index, const ByteFormat format=ByteFormat::LittleEndian) const
Get a 16-bit unsigned integer from the buffer at a specific index. A 16-bit unsigned integer can hold...
CANIdentifier get_identifier() const
Returns the identifier of the message.
static CANNetworkManager CANNetwork
Static singleton of the one network manager. Use this to access stack functionality.
void add_any_control_function_parameter_group_number_callback(std::uint32_t parameterGroupNumber, CANLibCallback callback, void *parent)
Registers a callback for ANY control function sending the associated PGN.
bool send_can_message(std::uint32_t parameterGroupNumber, const std::uint8_t *dataBuffer, std::uint32_t dataLength, std::shared_ptr< InternalControlFunction > sourceControlFunction, std::shared_ptr< ControlFunction > destinationControlFunction=nullptr, CANIdentifier::CANPriority priority=CANIdentifier::CANPriority::PriorityDefault6, TransmitCompleteCallback txCompleteCallback=nullptr, void *parentPointer=nullptr, DataChunkCallback frameChunkCallback=nullptr)
This is the main way to send a CAN message of any length.
void remove_any_control_function_parameter_group_number_callback(std::uint32_t parameterGroupNumber, CANLibCallback callback, void *parent)
This is how you remove a callback added with add_any_control_function_parameter_group_number_callback...
Defines an interface for sending and receiving ISOBUS guidance messages. These messages are used to s...
This namespace encompasses all of the ISO11783 stack's functionality to reduce global namespace pollu...
constexpr std::uint8_t CAN_DATA_LENGTH
The length of a classical CAN frame.