23 from geolocator_factory
import GeolocatorFactory
25 from rapp_utilities
import RappUtilities
26 from rapp_exceptions
import RappError
28 from rapp_platform_ros_communications.srv
import (
43 if rospy.has_param(
'rapp_geolocator_locate_topic'):
45 rospy.get_param(
"rapp_geolocator_locate_topic")
48 RappUtilities.rapp_print(
'Geolocator topic not found!',
'ERROR')
50 fetch_service = rospy.Service(
64 response = GeolocatorSrvResponse()
68 self._geolocator_factory.select_geolocator(req.geolocator)
69 except RappError
as err:
70 response.error = str(err)
73 results = locator.fetch_geolocation(req)
74 except RappError
as err:
75 response.error = str(err)
89 response = GeolocatorSrvResponse()
90 response.city = result[
'city']
91 response.country = result[
'country']
92 response.countryCode = result[
'countryCode']
93 response.regionName = result[
'regionName']
94 response.timezone = result[
'timezone']
95 response.zip = result[
'zip']
96 response.longtitude = result[
'longtitude']
97 response.latitude = result[
'latitude']
101 if __name__ ==
"__main__":
102 rospy.init_node(
'Geolocator')
104 RappUtilities.rapp_print(
"Geolocator node initialized")
def fetch_location_srv_callback
The callback to calculate geolocation.
_geolocator_factory
Factory that returns proper geolocator.
def _create_service_response
The callback to geolocalize.
Calculates geolocation via IP.