How to access complex rosmsg elements in cpp?
I trying to access osrf_gear::Order
message elements within orderCallback
scope. The structure of the message is as following:
string order_id
osrf_gear/Shipment[] shipments
string shipment_type
string agv_id
osrf_gear/Product[] products
string type
geometry_msgs/Pose pose
geometry_msgs/Point position
float64 x
float64 y
float64 z
geometry_msgs/Quaternion orientation
float64 x
float64 y
float64 z
float64 w
The orderCallback
code is following:
void orderCallback(const osrf_gear::Order::ConstPtr &order){
if(!empty_vector_check){
orders.clear();
empty_vector_check = 1;
}
osrf_gear::Shipment order_shipments;
order_shipments = order->shipments; // IDE yells that this is an invalid way to assign an osrf_gear::Shipment message type
ROS_INFO_STREAM("order_id: " << order->order_id);
ROS_INFO_STREAM("shipment_type: " << order_shipments);
orders.push_back(*order);
}
The osrf_gear::Shipment
message structure is as following:
string shipment_type
string agv_id
osrf_gear/Product[] products
string type
geometry_msgs/Pose pose
geometry_msgs/Point position
float64 x
float64 y
float64 z
geometry_msgs/Quaternion orientation
float64 x
float64 y
float64 z
float64 w
Error message while building the package:
no known conversion for argument 1 from ‘const _shipments_type {aka const std::vector<osrf_gear::Shipment_<std::allocator<void> >, std::allocator<osrf_gear::Shipment_<std::allocator<void> > > >}’ to ‘const osrf_gear::Shipment_<std::allocator<void> >&’
/opt/ros/melodic/include/osrf_gear/Shipment.h:23:8:
My questions:
- What would be the correct syntactical way to access the
shipment[]
msg type using theosrf_gear::order
callback parameter? - I want to access the
osrf_gear::Product products
vector to know whattype
of products I have in the shipment.
Thank you in advance!