Projet

Général

Profil

Feature #14794 » OccupancyGrid.py

Anonyme, 25/11/2022 17:13

 
#!/usr/bin/env python

import rospy
from nav_msgs.msg import OccupancyGrid
import numpy as np
from numpy import asarray
from numpy import savetxt

msg = OccupancyGrid()

def point(msg):
#global A, M
M = np.matrix(msg.data)
#print('taille de la matrice : ', M.shape) # nb ligne et colonne
A = M.reshape(1984, 1984)
#print('taille de la matrice : ', A.shape)
#print(A)
savetxt('data.csv', A, delimiter=',')



rospy.init_node('map')
rospy.Subscriber("/map", OccupancyGrid, point)
rate = rospy.Rate(10)



while not rospy.is_shutdown():
rate.sleep()

(2-2/2)