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

Can't use "#include <mavlink/v2.0/common/mavlink.h>" #1981

Open
brain0071 opened this issue Aug 27, 2024 · 1 comment
Open

Can't use "#include <mavlink/v2.0/common/mavlink.h>" #1981

brain0071 opened this issue Aug 27, 2024 · 1 comment

Comments

@brain0071
Copy link

Issue details

I want to parse mavlink messages in mavros source code

mavros/src/lib/mavros.cpp

For example:

mavlink_manual_control_t

And then get some value:

packet.x = x; packet.y = y; packet.z = z; packet.r = r

I think I need use this function:mavlink_msg_manual_control_get_x", so I add this line

#include <mavlink/v2.0/common/mavlink.h>

in mavros.cpp.
but when I use catkin_make, a Error appear like this:

/opt/ros/noetic/include/mavlink/v2.0/common/common.h:2695:6: error: token ""2024.6.6"" is not valid in preprocessor expressions
 2695 | #if (MAVLINK_VERSION == 0)
      |      ^~~~~~~~~~~~~~~

and when I add this line

#undef MAVLINK_VERSION
#define MAVLINK_VERSION 2  // Replace with the correct integer version
#include <mavlink/v2.0/common/mavlink.h>"

I got a new Error:

error: ‘mavlink_message_t’ does not name a type
   85 | static inline uint16_t mavlink_msg_get_send_buffer_length(const mavlink_message_t* msg)
      |                                                                 ^~~~~~~~~~~~~~~~~
/opt/ros/noetic/include/mavlink/v2.0/protocol.h: In function ‘uint16_t mavlink_msg_get_send_buffer_length(const int*)’:
/opt/ros/noetic/include/mavlink/v2.0/protocol.h:87:11: error: request for member ‘magic’ in ‘* msg’, which is of non-class type ‘const int’
   87 |  if (msg->magic == MAVLINK_STX_MAVLINK1) {
      |           ^~~~~
/opt/ros/noetic/include/mavlink/v2.0/protocol.h:88:15: error: request for member ‘len’ in ‘* msg’, which is of non-class type ‘const int’
   88 |   return msg->len + MAVLINK_CORE_HEADER_MAVLINK1_LEN+1 + 2;
      |               ^~~
/opt/ros/noetic/include/mavlink/v2.0/protocol.h:90:37: error: request for member ‘incompat_flags’ in ‘* msg’, which is of non-class type ‘const int’
   90 |      uint16_t signature_len = (msg->incompat_flags & MAVLINK_IFLAG_SIGNED)?MAVLINK_SIGNATURE_BLOCK_LEN:0;
      |                                     ^~~~~~~~~~~~~~

MAVROS version and platform

ROS: Noetic
Ubuntu: 22.04

@vooon
Copy link
Member

vooon commented Aug 27, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants