Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RC channels count being zero, when channels values exists #2006

Open
wants to merge 1 commit into
base: ros2
Choose a base branch
from
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
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}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What for? There no native python extension or calling python code from the c++.

)

## 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