Now, I have searched for way to resolve this error but unable to do. Please tell me how to do this conversion from std_msgs/Char type to mavlink_message_t. Also please give some insight on mavlink_message_t (what type of data is it and any useful info).
try including:
mavlink.h
But look this code was bugged from the start and I can’t find the source file for it
Also you seem new to c++ so this will no doubt be a heavy lift.
If it does not work I will have no idea why, I just know you can’t cast a char to a struct.
Perhaps @JulianOes will jump in who has much more knowledge about mavlink.
Really that example should be updated or removed.
hello @jimdgit, thanks for your quick replies.
I would like to say that mavlink_message_t struct is already included via mavros_plugin.h in the file keyboard_command.cpp. I would like to include @JulianOes, @Vladimir_Ermakov o look into the code for a second. My plugin file looks like:
here __mavlink_messageis defined in file catkin_ws/devel/include/mavlink/v2.0/mavlink_type.h which is included in mavros_plugins.h at the top of plugin file. Can someone tell me why the error mavlink_message_t not declared in this scope appearing when already its header is included?
Moreover, i would like to point out that the function UAS_PACK_CHAN() in send_to_pixhawk function in keyboard_command.cpp is present no where in mavros, mavlink or any package in ROS installtion directory /opt/ros/melodic. Can you tell me what is it doing and where is it defined in mavlink or mavros or any related package.
Any help is appreciated.
I am also following the same example and receiving the same error message as OP. Has there been any movement in correcting the root cause and pushing the fix? A working end-to-end tutorial is extremely valuable.
I believe I’ve identified the problem with this example. The current version of the example is not packaging the input into the KEY_COMMAND message the user created in the common.xml file. Using the following definition of the keyboard_cb function compiles successfully.
I now have the complete functionality working. The current version of the tutorial is way out of date. I found the following issues while working through it:
The callback function ‘keyboard_cb’ is missing steps to create a msg and add data to the field (see above post)
The CMake file for the keyboard module has “platforms__common” as a dependency. I could not get it to compile with it included. Removing it worked fine.
There is no “timestamp” field in the key_command msg template. This is required for an assertion check to pass. This field is also used by a later function in the current version of the tutorial so it is a clear omission. This field also needs to be defined in the xml files for PX4 and MAVROS.
The names of the included header files for the PX4 side of the implementation look to be for an older version. For example include <px4_config.h> did not work but include <px4_platform_common/config.h> did.
Targeting a test deployment for SITL is an easier test than assuming access to hardware. I was able to get it running with jamvsim SITL.
The template used for the PX4 key_receiver module is out of date. The “while(true)” is gross.
Hey Yfrikha, which problem are you having? The bulleted list I posted should capture all the issues I came across while troubleshooting. You should be able to follow the current buggy version of the tutorial and reference my list to see which steps and files should be modified to get it working. Let me know if something’s not clear enough and I’ll see what I can do to help you out.
Hey Ryan !
I also encountered the same problem when doing this experiment. It has been solved with your help. Thank you very much, but in the last step, I checked my subscription module and found that there was no data. What is the possible reason?
Hi,
I can’t compile Pixhawk code when I add a new message following the same tutorial. https://docs.px4.io/master/en/ros/mavros_custom_messages.html
The error I get is as follows: “No ‘timestamp’ field found in key_command msg definition!”.
Could this example in documentation be updated so that it compiles?
I am facing the following issue while building PX4. Please help! I am new to PX4.
Ubuntu: 20.04
ROS: Neotic
And I did not find “include” directory in mavlink which was mentioned in the above reference.
./…/src/modules/mavlink/mavlink_receiver.cpp: In member function ‘void MavlinkReceiver::handle_message(mavlink_message_t*)’:
…/…/src/modules/mavlink/mavlink_receiver.cpp:270:7: error: ‘MAVLINK_MSG_ID_KEY_COMMAND’ was not declared in this scope;
@Ryan1 Hi Ryan, thanks for the great post and comments! Would you be interested in updating the documentation so that people can benefit from your experience?