PoseArray not getting published
Hi, so I'm trying to find the shortest path from source to destination using dijkstra's algorithm.
In this program, I intend to first store the path in an array from which I retrieve it and publish it as a Pose Array. However, when I run this program I see no PoseArray topics.
I am trying to publish it from inside the dijkstra function.
#include <ros/ros.h>
#include <math.h>
#include <queue>
#include <vector>
#include <std_msgs/String.h>
#include <geometry_msgs/Pose.h>
#include <geometry_msgs/PoseArray.h>
#include <nav_msgs/OccupancyGrid.h>
#include <nav_msgs/GetMap.h>
#include <ros/console.h>
#define FMAX 999999999.99
int rows = 1000, columns = 1000, size = rows * columns;
bool visited[1000000];
float distance[1000000];
int prev[1000000];
int source = 15100, destination = 990500; // Random source and destination
.
.
.
void dijkstra(const nav_msgs::OccupancyGrid& map)
{
prev[source] = 0;
node first = {source, 0.0};
pq.push(first);
while(!pq.empty())
{
.
.
int rr, cc;
for(int i = 0; i < 8; i++) // to calculate neighbours
{
.
.
.
.
}
}
poseArray.poses = pose_vector;
ros::NodeHandle n("~");
ros::Publisher pose_array_pub = n.advertise<geometry_msgs::PoseArray>("/poseArray", 1);
pose_array_pub.publish(poseArray);
}
int main(int argc, char **argv)
{
init();
distance[source] = 0;
visited[source] = true;
ros::init(argc, argv, "dijkstra");
ros::NodeHandle n("~");
ros::ServiceClient client = n.serviceClient<nav_msgs::GetMap>("/static_map");
nav_msgs::OccupancyGrid my_map = srv.response.map;
dijkstra(my_map);
ros::spin();
}
EDIT - Deleted parts of my code to make the question more relevant.