0
\$\begingroup\$

I'm learning ROS and I'm trying to populate data from my server to spinner. my JSON is:

{"topic": "/waypoints", "msg": {"waypoints": [{"header": {"stamp": {"secs": 0, "nsecs": 0}, "frame_id": "map", "seq": 0}, "pose": {"position": {"y": -140.901899144836, "x": 44.36469369653882, "z": 0.0}, "orientation": {"y": 0.0, "x": 0.0, "z": 0.5062775131960053, "w": 0.8623706161692133}}, "name": "A"}, {"header": {"stamp": {"secs": 0, "nsecs": 0}, "frame_id": "map", "seq": 0}, "pose": {"position": {"y": -102.30524463734227, "x": 51.282396271771304, "z": 0.0}, "orientation": {"y": 0.0, "x": 0.0, "z": 0.6926372547579506, "w": 0.721286096719859}}, "name": "B"}]}, "op": "publish"}

And I've already serialized the msg type(data) of the waypoints

public class WaypointList {

@SerializedName("header")
@Expose
public Header header;
@SerializedName("pose")
@Expose
public Pose pose;
@SerializedName("name")
@Expose
public String name;
@SerializedName("secs")
@Expose
public int secs;
@SerializedName("nsecs")
@Expose
public int nsecs;
@SerializedName("position")
@Expose
public Position position;
@SerializedName("orientation")
@Expose
public Orientation orientation;
@SerializedName("y")
@Expose
public float y;
@SerializedName("x")
@Expose
public float x;
@SerializedName("z")
@Expose
public float z;
@SerializedName("w")
@Expose
public float w;
@SerializedName("stamp")
@Expose
public Stamp stamp;
@SerializedName("frame_id")
@Expose
public String frameId;
@SerializedName("seq")
@Expose
public int seq;
@SerializedName("waypoints")
@Expose
public List<WaypointList> waypoints = null;

/**
 * No args constructor for use in serialization
 *
 */
public WaypointList() {
}

/**
 *
 * @param waypoints
 */
public WaypointList(List<WaypointList> waypoints, Stamp stamp, String frameId, int seq, float y, float x, float z, float w, Position position, Orientation orientation, int secs, int nsecs, Header header, Pose pose, String name) {
    super();
    this.header = header;
    this.pose = pose;
    this.name = name;
    this.secs = secs;
    this.nsecs = nsecs;
    this.position = position;
    this.orientation = orientation;
    this.y = y;
    this.x = x;
    this.z = z;
    this.w = w;
    this.stamp = stamp;
    this.frameId = frameId;
    this.seq = seq;
    this.waypoints = waypoints;
}

Now I'm trying to get the list of the waypoint names and display it to my spinner. Please help me out. Thanks in Advance.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.