├── CMakeLists.txt ├── Makefile ├── README.md ├── mainpage.dox ├── manifest.xml └── script ├── mapISEN.png └── plotGpsDataOnMap.py /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.4.6) 2 | include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake) 3 | 4 | # Set the build type. Options are: 5 | # Coverage : w/ debug symbols, w/o optimization, w/ code-coverage 6 | # Debug : w/ debug symbols, w/o optimization 7 | # Release : w/o debug symbols, w/ optimization 8 | # RelWithDebInfo : w/ debug symbols, w/ optimization 9 | # MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries 10 | #set(ROS_BUILD_TYPE RelWithDebInfo) 11 | 12 | rosbuild_init() 13 | 14 | #set the default path for built executables to the "bin" directory 15 | set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) 16 | #set the default path for built libraries to the "lib" directory 17 | set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) 18 | 19 | #uncomment if you have defined messages 20 | #rosbuild_genmsg() 21 | #uncomment if you have defined services 22 | #rosbuild_gensrv() 23 | 24 | #common commands for building c++ executables and libraries 25 | #rosbuild_add_library(${PROJECT_NAME} src/example.cpp) 26 | #target_link_libraries(${PROJECT_NAME} another_library) 27 | #rosbuild_add_boost_directories() 28 | #rosbuild_link_boost(${PROJECT_NAME} thread) 29 | #rosbuild_add_executable(example examples/example.cpp) 30 | #target_link_libraries(example ${PROJECT_NAME}) 31 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | include $(shell rospack find mk)/cmake.mk -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # plotGpsOnSatelitteMap 2 | 3 | This ROS Node plot GPS data on a map 4 | 5 | ## Prerequis 6 | 7 | This node is built with catkin under ROS Indigo. It subscribe to /fix (sensor_msgs/NavSatFix Message) and plot on a map the position in "real time". 8 | 9 | This node connect to ROS_MASTER_URI and wait /fix messages. Could run when reading a bag file or during real experiment when connected to ROS_MASTER_URI. 10 | 11 | ## Usage 12 | 13 | 1. cd ~/catkin_ws/src 14 | 2. git clone https://github.com/ISENRobotics/plotGpsOnSatelitteMap.git 15 | 3. cd ~/catkin_ws 16 | 4. catkin_make 17 | 5. rosrun plotGpsOnSatelitteMap plotGpsDataOnMap.py 18 | 19 | ## Creating a map 20 | 21 | 1. With google map/earth or other, put two points (better with google earth) at bottom left and top right corners. Please Note those coordinates, they will be used to fit the image with coordinate system. 22 | 2. With the software you prefer, crop this image to fit with corner points. 23 | 3. In the main script plotGpsDataOnMap.py, in function Initialisation, put your coordinates and mapfile. 24 | 25 | Run the script under the folder script so the script could find the image file. 26 | -------------------------------------------------------------------------------- /mainpage.dox: -------------------------------------------------------------------------------- 1 | /** 2 | \mainpage 3 | \htmlinclude manifest.html 4 | 5 | \b plotGpsOnSatelitteMap 6 | 7 | 10 | 11 | --> 12 | 13 | 14 | */ 15 | -------------------------------------------------------------------------------- /manifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | plotGpsOnSatelitteMap 5 | 6 | 7 | Clément Aubry 8 | BSD 9 | 10 | http://ros.org/wiki/plotGpsOnSatelitteMap 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /script/mapISEN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ISENRobotics/plotGpsOnSatelitteMap/46721f7b9923d1f8c7ac3c8c12114c9720ddc0dd/script/mapISEN.png -------------------------------------------------------------------------------- /script/plotGpsDataOnMap.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import rospy 3 | from std_msgs.msg import String 4 | from sensor_msgs.msg import NavSatFix,NavSatStatus,TimeReference 5 | import matplotlib.pyplot as plt 6 | 7 | 8 | def callback(data): 9 | rospy.loginfo("lat [%f], lon [%f], status [%i]", data.latitude, data.longitude, data.status.status) 10 | # with open('dataBlueTeam.txt','a') as f: f.write('{0} {1} {2}\n'.format(data.latitude, data.longitude, data.status.status)) 11 | plt.scatter(x=[data.longitude], y=[data.latitude], s = 45, c='b') #sets your home position 12 | plt.show() 13 | 14 | def initialisation(): 15 | 16 | # In ROS, nodes are uniquely named. If two nodes with the same 17 | # node are launched, the previous one is kicked off. The 18 | # anonymous=True flag means that rospy will choose a unique 19 | # name for our 'listener' node so that multiple listeners can 20 | # run simultaneously. 21 | rospy.init_node('plotGpsDataOnMap') 22 | 23 | rospy.Subscriber("fix", NavSatFix, callback) 24 | 25 | #adjust these values based on your location and map, lat and long are in decimal degrees 26 | TRX = -4.49357 #top right longitude 27 | TRY = 48.40817 #top right latitude 28 | BLX = -4.49614 #bottom left longitude 29 | BLY = 48.40664 #bottom left latitude 30 | mapFile = 'mapISEN.png' 31 | imgMap = 0 32 | #now plot the data on a graph 33 | plt.xlabel('Longitude') 34 | plt.ylabel('Latitude') 35 | plt.title('POSITION (in Decimal Degrees)') 36 | 37 | #display the image under the graph 38 | #read a png file to map on 39 | imgMap = plt.imread('mapISEN.png') 40 | implot = plt.imshow(imgMap,extent=[BLX, TRX, BLY, TRY]) 41 | plt.show() 42 | 43 | # spin() simply keeps python from exiting until this node is stopped 44 | rospy.spin() 45 | 46 | if __name__ == '__main__': 47 | initialisation() 48 | --------------------------------------------------------------------------------