0
$\begingroup$

Rosanswers logo

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:

  1. What would be the correct syntactical way to access the shipment[] msg type using the osrf_gear::order callback parameter?
  2. I want to access the osrf_gear::Product products vector to know what type of products I have in the shipment.

Thank you in advance!


Originally posted by abhijelly on ROS Answers with karma: 18 on 2022-02-16

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

shipments in the order message type is a vector of type osrf_gear::Shipment. This change solved the IDE from yelling.

Have a nice day!


Originally posted by abhijelly with karma: 18 on 2022-02-16

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by gvdhoorn on 2022-02-17:\

Have a nice day!

we can only have a nice day if you would tell us what you did to resolve your question.

Comment by abhijelly on 2022-02-18:
@gvdhoorn done! hope it helps everyone have a nice day

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.