Attention: Answers.ros.org is deprecated as of August the 11th, 2023. Please visit robotics.stackexchange.com to ask a new question. This site will remain online in read-only mode during the transition and into the foreseeable future. Selected questions and answers have been migrated, and redirects have been put in place to direct users to the corresponding questions on Robotics Stack Exchange. Additional details are available here.
Use PoseArray mgs and you can use a for loop to go through the position of pose of the PoseArray to see if poseArray.pose.position of x and y is equal to the x and y of the one you are gonna add in if so then move on if not then add.
OR
Create your own msgs with a Point[] point array and go through that array.