Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions examples/seeder_example/vt_application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ bool SeederVtApplication::initialize()
}

speedMessages.initialize();
speedMessages.get_machine_selected_speed_data_event_publisher().add_listener([this](const std::shared_ptr<isobus::SpeedMessagesInterface::MachineSelectedSpeedData> mssData, bool changed) { this->handle_machine_selected_speed(mssData, changed); });
speedMessages.get_ground_based_machine_speed_data_event_publisher().add_listener([this](const std::shared_ptr<isobus::SpeedMessagesInterface::GroundBasedSpeedData> gbsData, bool changed) { this->handle_ground_based_speed(gbsData, changed); });
speedMessages.get_wheel_based_machine_speed_data_event_publisher().add_listener([this](const std::shared_ptr<isobus::SpeedMessagesInterface::WheelBasedMachineSpeedData> wbsData, bool changed) { this->handle_wheel_based_speed(wbsData, changed); });
speedMessages.get_machine_selected_speed_data_event_publisher().add_listener([this](const std::shared_ptr<isobus::MachineSelectedSpeedData> mssData, bool changed) { this->handle_machine_selected_speed(mssData, changed); });
speedMessages.get_ground_based_machine_speed_data_event_publisher().add_listener([this](const std::shared_ptr<isobus::GroundBasedSpeedData> gbsData, bool changed) { this->handle_ground_based_speed(gbsData, changed); });
speedMessages.get_wheel_based_machine_speed_data_event_publisher().add_listener([this](const std::shared_ptr<isobus::WheelBasedMachineSpeedData> wbsData, bool changed) { this->handle_wheel_based_speed(wbsData, changed); });

ddop = std::make_shared<isobus::DeviceDescriptorObjectPool>();
if (sectionControl.create_ddop(ddop, TCClientInterface.get_internal_control_function()->get_NAME()))
Expand Down Expand Up @@ -281,17 +281,17 @@ void SeederVtApplication::handle_numeric_value_events(const isobus::VirtualTermi
}
}

void SeederVtApplication::handle_machine_selected_speed(const std::shared_ptr<isobus::SpeedMessagesInterface::MachineSelectedSpeedData> mssData, bool)
void SeederVtApplication::handle_machine_selected_speed(const std::shared_ptr<isobus::MachineSelectedSpeedData> mssData, bool)
{
process_new_speed(SpeedSources::MachineSelected, mssData->get_machine_speed());
}

void SeederVtApplication::handle_ground_based_speed(const std::shared_ptr<isobus::SpeedMessagesInterface::GroundBasedSpeedData> gbsData, bool)
void SeederVtApplication::handle_ground_based_speed(const std::shared_ptr<isobus::GroundBasedSpeedData> gbsData, bool)
{
process_new_speed(SpeedSources::GroundBased, gbsData->get_machine_speed());
}

void SeederVtApplication::handle_wheel_based_speed(const std::shared_ptr<isobus::SpeedMessagesInterface::WheelBasedMachineSpeedData> wbsData, bool)
void SeederVtApplication::handle_wheel_based_speed(const std::shared_ptr<isobus::WheelBasedMachineSpeedData> wbsData, bool)
{
process_new_speed(SpeedSources::WheelBased, wbsData->get_machine_speed());
}
Expand Down
6 changes: 3 additions & 3 deletions examples/seeder_example/vt_application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ class SeederVtApplication

/// @brief A callback for handling machine selected speed events, used to set appropriate VT flags
/// @param[in] event The event data to process
void handle_machine_selected_speed(const std::shared_ptr<isobus::SpeedMessagesInterface::MachineSelectedSpeedData> mssData, bool changed);
void handle_machine_selected_speed(const std::shared_ptr<isobus::MachineSelectedSpeedData> mssData, bool changed);

/// @brief A callback for handling ground based speed events, used to set appropriate VT flags
/// @param[in] event The event data to process
void handle_ground_based_speed(const std::shared_ptr<isobus::SpeedMessagesInterface::GroundBasedSpeedData> mssData, bool changed);
void handle_ground_based_speed(const std::shared_ptr<isobus::GroundBasedSpeedData> mssData, bool changed);

/// @brief A callback for handling wheel based speed events, used to set appropriate VT flags
/// @param[in] event The event data to process
void handle_wheel_based_speed(const std::shared_ptr<isobus::SpeedMessagesInterface::WheelBasedMachineSpeedData> mssData, bool changed);
void handle_wheel_based_speed(const std::shared_ptr<isobus::WheelBasedMachineSpeedData> mssData, bool changed);

/// @brief Aggregates speeds and decides which speed to use
void process_new_speed(SpeedSources source, std::uint32_t speed);
Expand Down
4 changes: 4 additions & 0 deletions isobus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ set(ISOBUS_SRC
"nmea2000_fast_packet_protocol.cpp"
"isobus_data_dictionary.cpp"
"isobus_language_command_interface.cpp"
"isobus_machine_selected_speed.cpp"
"isobus_machine_selected_speed_command.cpp"
"isobus_time_date_interface.cpp"
"isobus_task_controller_client_objects.cpp"
"isobus_task_controller_client.cpp"
"isobus_device_descriptor_object_pool.cpp"
"isobus_shortcut_button_interface.cpp"
"isobus_ground_based_speed.cpp"
"isobus_functionalities.cpp"
"isobus_guidance_interface.cpp"
"isobus_speed_distance_messages.cpp"
Expand All @@ -45,6 +48,7 @@ set(ISOBUS_SRC
"isobus_heartbeat.cpp"
"isobus_task_controller_server.cpp"
"isobus_task_controller_server_options.cpp"
"isobus_wheel_based_speed.cpp"
"nmea2000_message_definitions.cpp"
"nmea2000_message_interface.cpp"
"isobus_device_descriptor_object_pool_helpers.cpp"
Expand Down
91 changes: 91 additions & 0 deletions isobus/include/isobus/isobus/isobus_ground_based_speed.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
//================================================================================================
/// @file isobus_ground_based_speed.hpp
///
/// @brief Parses and sends ground-based speed messages.
/// @author Adrian Del Grosso
///
/// @copyright 2026 The Open-Agriculture Developers
//================================================================================================
#ifndef ISOBUS_GROUND_BASED_SPEED_HPP
#define ISOBUS_GROUND_BASED_SPEED_HPP

#include "isobus/isobus/can_control_function.hpp"
#include "isobus/isobus/isobus_machine_speed_direction_constants.hpp"

namespace isobus
{
/// @brief Message normally sent by the Tractor ECU on the implement bus on construction and
/// agricultural implements providing to connected systems the current measured ground speed
/// (also includes a free-running distance counter and an indication of the direction of travel).
///
/// @note Accuracies of both wheel-based and ground-based sources can be speed-dependent and degrade at low speeds.
/// Wheel-based information might not be updated at the 100ms rate at low speeds.
class GroundBasedSpeedData
{
public:
/// @brief Constructor for a GroundBasedSpeedData
/// @param[in] sender The control function that is sending this message
explicit GroundBasedSpeedData(std::shared_ptr<ControlFunction> sender);

/// @brief Actual distance traveled by a machine, based on measurements from a sensor such as that is not susceptible to wheel slip
/// (e.g. radar, GPS, LIDAR, or stationary object tracking)
/// @note This distance is usually provided by radar.
/// @return Actual distance traveled by a machine, based on measurements from a sensor such as that is not susceptible to wheel slip (millimeters)
std::uint32_t get_machine_distance() const;

/// @brief Sets the actual distance traveled by a machine, based on measurements from a sensor such as that is not susceptible to wheel slip.
/// @note This distance is usually provided by radar.
/// @param distance The actual distance traveled by a machine (millimeters)
/// @return True if the set value was different from the stored value otherwise false
bool set_machine_distance(std::uint32_t distance);

/// @brief Returns the actual ground speed of a machine, measured by a sensor such as that is not susceptible to wheel slip in mm/s
/// @note This speed is usually provided by radar.
/// @return The actual ground speed of a machine, measured by a sensor such as that is not susceptible to wheel slip in mm/s
std::uint16_t get_machine_speed() const;

/// @brief Sets the actual ground speed of a machine, measured by a sensor such as that is not susceptible to wheel slip in mm/s
/// @note This speed is usually provided by radar.
/// @param speed The actual ground speed of a machine, measured by a sensor such as that is not susceptible to wheel slip in mm/s
/// @return True if the set value was different from the stored value otherwise false
bool set_machine_speed(std::uint16_t speed);

/// @brief Returns A measured signal indicating either forward or reverse as the direction of travel.
/// @note When the speed is zero, this indicates the last travel direction until a different
/// direction is detected or selected and engaged.
/// @return The measured direction of travel for the machine
MachineDirection get_machine_direction_of_travel() const;

/// @brief Sets a measured signal indicating either forward or reverse as the direction of travel.
/// @note The "Not Off" key switch state does not always mean "On" so use care when using it.
/// @param directionOfTravel The measured direction of travel for the machine
/// @return True if the set value was different from the stored value otherwise false
bool set_machine_direction_of_travel(MachineDirection directionOfTravel);

/// @brief Returns a pointer to the sender of the message. If an ICF is the sender, returns the ICF being used to transmit from.
/// @attention The only way you could get an invalid pointer here is if you register a partner, it sends this message, then you delete the partner and
/// call this function, as that is the only time the stack deletes a control function. That would be abnormal program flow, but at some point
/// the stack will be updated to return a shared or weak pointer instead, but for now please be aware of that limitation.
/// Eventually though the message will time-out normally and you can get a new pointer for
/// the external CF that replaces the deleted partner.
/// @returns The control function sending this instance of the guidance system command message
std::shared_ptr<ControlFunction> get_sender_control_function() const;

/// @brief Sets the timestamp for when the message was received or sent
/// @param[in] timestamp The timestamp, in milliseconds, when the message was sent or received
void set_timestamp_ms(std::uint32_t timestamp);

/// @brief Returns the timestamp for when the message was received, in milliseconds
/// @returns The timestamp for when the message was received, in milliseconds
std::uint32_t get_timestamp_ms() const;

private:
std::shared_ptr<ControlFunction> const controlFunction; ///< The CF that is sending the message
std::uint32_t timestamp_ms = 0; ///< A timestamp for when the message was released in milliseconds
std::uint32_t groundBasedMachineDistance_mm = 0; ///< Stores the ground-based speed's distance in millimeters
std::uint16_t groundBasedMachineSpeed_mm_per_sec = 0; ///< Stores the ground-based speed in mm/s
MachineDirection machineDirectionState = MachineDirection::NotAvailable; ///< Stores direction of travel.
};
} // namespace isobus

#endif // ISOBUS_GROUND_BASED_SPEED_HPP
Loading
Loading