From 6b1c9175524f5cb16d3ac6d4d5485473e864af6a Mon Sep 17 00:00:00 2001 From: David Ingraham Date: Sun, 10 Dec 2023 17:19:59 -0800 Subject: [PATCH] Rover: Add Absolute Encoder Support This instantiates the absolute encoder driver in rover, for use in the AP_Windvane Driver. --- Rover/Parameters.cpp | 5 +++++ Rover/Parameters.h | 4 ++++ Rover/Rover.cpp | 3 ++- Rover/system.cpp | 2 ++ Rover/wscript | 1 + 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Rover/Parameters.cpp b/Rover/Parameters.cpp index 5d4a84fc9b08b6..24ebdbfead8a9f 100644 --- a/Rover/Parameters.cpp +++ b/Rover/Parameters.cpp @@ -703,6 +703,10 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { // @Path: mode_circle.cpp AP_SUBGROUPINFO(mode_circle, "CIRC", 57, ParametersG2, ModeCircle), + // @Group: AENC + // @Path: ../libraries/AP_AbsoluteEncoder/AP_AbsoluteEncoder.cpp + AP_SUBGROUPINFO(absoluteencoder, "AENC", 58, ParametersG2, AP_AbsoluteEncoder), + AP_GROUPEND }; @@ -758,6 +762,7 @@ ParametersG2::ParametersG2(void) #if AP_FOLLOW_ENABLED follow(), #endif + absoluteencoder(), windvane(), pos_control(attitude_control), wp_nav(attitude_control, pos_control), diff --git a/Rover/Parameters.h b/Rover/Parameters.h index 035d16f4d0ffb4..1a780329764f54 100644 --- a/Rover/Parameters.h +++ b/Rover/Parameters.h @@ -15,6 +15,7 @@ #include #include "AP_Torqeedo/AP_Torqeedo.h" #include +#include #define AP_PARAM_VEHICLE_NAME rover @@ -392,6 +393,9 @@ class ParametersG2 { // windvane AP_WindVane windvane; + // Absolute Encoder + AP_AbsoluteEncoder absoluteencoder; + // mission behave AP_Int8 mis_done_behave; diff --git a/Rover/Rover.cpp b/Rover/Rover.cpp index 82b7f46e371397..0e12b71ca5dab1 100644 --- a/Rover/Rover.cpp +++ b/Rover/Rover.cpp @@ -86,7 +86,8 @@ const AP_Scheduler::Task Rover::scheduler_tasks[] = { #if HAL_PROXIMITY_ENABLED SCHED_TASK_CLASS(AP_Proximity, &rover.g2.proximity, update, 50, 200, 27), #endif - SCHED_TASK_CLASS(AP_WindVane, &rover.g2.windvane, update, 20, 100, 30), + SCHED_TASK_CLASS(AP_AbsoluteEncoder, &rover.g2.absoluteencoder, update, 20, 100, 30), + SCHED_TASK_CLASS(AP_WindVane, &rover.g2.windvane, update, 20, 100, 31), SCHED_TASK(update_wheel_encoder, 50, 200, 36), SCHED_TASK(update_compass, 10, 200, 39), SCHED_TASK(update_logging1, 10, 200, 45), diff --git a/Rover/system.cpp b/Rover/system.cpp index 492463e8a2345a..71cfb79e123c87 100644 --- a/Rover/system.cpp +++ b/Rover/system.cpp @@ -42,6 +42,8 @@ void Rover::init_ardupilot() rssi.init(); + g2.absoluteencoder.init(); + g2.windvane.init(serial_manager); // init baro before we start the GCS, so that the CLI baro test works diff --git a/Rover/wscript b/Rover/wscript index b77de5b6e40161..bd2f69dfe2dd34 100644 --- a/Rover/wscript +++ b/Rover/wscript @@ -27,6 +27,7 @@ def build(bld): 'AP_Torqeedo', 'AC_PrecLand', 'AP_IRLock', + 'AP_AbsoluteEncoder', ], )