Skip to content

Multiple MessageType within a topic. #332

@christopherholmes

Description

@christopherholmes

Hi,

I have two ROS (.msg) files, (Point_Array.msg) and (Point.msg).

Point_Array message:
parray = []

Point message
float32 x
float32 y
float32 z

I want to populate the Point_Array message with the Point_message, the Point_Array needs to hold 10 points.

How do I build the message in my js file.

My current function looks like this:

this.Path = new ROSLIB Topic({
   ros : this.ros,
   name : '/Path'
   messageType : 'my_msgs/Point_Array'
});

var final_points = new ROSLIB.Message({
   parray : {
       Point : {
       }
   }
})

var tempArray = []

for (var i = 1; i < this.my_data.length-1; i++){
   var points = new ROSLIB.Message({
   Point : {
          x : parseFloat(my_data[i].X)
          y : parseFloat(my_data[i].Y)
          z : parseFloat(my_data[i].Z)
   }   
})

tempArray.push(points)
}

final_points = new ROSLIB.Message(tempArray)
this.Path.publish(this.final_points)

Can anyone help with this at all?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions