Skip to content

Commit

Permalink
Fix RC channels count being zero, when channels values exists
Browse files Browse the repository at this point in the history
Mission Planner don't ever  set channel count
  • Loading branch information
r8d8 committed Oct 25, 2024
1 parent b490957 commit 40b1086
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 3 additions & 0 deletions mavros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ set(CMAKE_CXX_EXTENSIONS ON)
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_python REQUIRED)

find_package(PythonLibs REQUIRED)

# find mavros dependencies
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
Expand Down Expand Up @@ -67,6 +69,7 @@ include_directories(
${mavlink_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIRS}
${GeographicLib_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIRS}
)

## Check if the datasets are installed
Expand Down
9 changes: 3 additions & 6 deletions mavros/src/plugins/rc_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,17 @@ class RCIOPlugin : public plugin::Plugin
RCLCPP_INFO_EXPRESSION(
get_logger(), !has_rc_channels_msg.exchange(
true), "RC_CHANNELS message detected!");

if (channels.chancount > MAX_CHANCNT) {
RCLCPP_WARN_THROTTLE(
get_logger(), *get_clock(), 60000,
"FCU receives %u RC channels, but RC_CHANNELS can store %zu",
channels.chancount, MAX_CHANCNT);

channels.chancount = MAX_CHANCNT;
}

raw_rc_in.resize(channels.chancount);
raw_rc_in.resize(MAX_CHANCNT);

// switch works as start point selector.
switch (channels.chancount) {
switch (MAX_CHANCNT) {
// [[[cog:
// for i in range(18, 0, -1):
// cog.outl(f"case {i}: raw_rc_in[{i - 1}] = channels.chan{i}_raw; [[fallthrough]];")
Expand Down
2 changes: 2 additions & 0 deletions mavros_extras/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set(CMAKE_C_EXTENSIONS ON)
set(CMAKE_CXX_EXTENSIONS ON)

find_package(ament_cmake REQUIRED)
find_package(PythonLibs REQUIRED)

# find mavros dependencies
find_package(rclcpp REQUIRED)
Expand Down Expand Up @@ -68,6 +69,7 @@ include_directories(
${mavlink_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIRS}
${GeographicLib_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIRS}
)

if(rclcpp_VERSION VERSION_LESS 9.0.0)
Expand Down

0 comments on commit 40b1086

Please sign in to comment.