Packing/unpacking raw mavlink messages from mavros mavlink/from

I would like to understand how to pack and unpack raw mavlink messages from mavros’s mavlink/to and mavlink/from topics (outside of a mavros plugin).

I know there exists a function to convert mavlink_message_t structs to the mavros_msgs::Mavlink object, but (with a new version of mavros?) it is unclear how to convert from specific mavlink message types to mavlink_message_t from a specific message type. I have done this previously by just using the mavlink c-types, for example, just by including mavros/utils

        #include <mavros/utils.h>
        mavlink_mission_item_t waypoint_msg;   
        // ... fill in message fields 
        mavlink_message_t packet;
        mavlink_msg_mission_item_encode(255, 1, &packet, &waypoint_msg);

But now those types are no longer available? I see in the mavros source code that the specific message types are represented as subclasses of a mavlink::Message base class (e.g. mavlink::common::msg::MISSION_ITEM), but I do not see methods to pack/unpack them. My attempts to compile while including the underlying mavlink headers have all failed so far.

Hi,
Have u found Solution to your Problem
I hav now the same Problem

Thanks for ur Replay
I work with mavros 0,18
when I want to use encode function from mavlink like in your code it gives me an error
u can see https://github.com/ethz-asl/rotors_simulator/issues/468