ntrip_ros.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 
3 import sys
4 import importlib
5 
6 import rospy
7 
8 from ntrip_client.ntrip_ros_base import NTRIPRosBase
9 from ntrip_client.ntrip_client import NTRIPClient
10 
11 # Try to import a couple different types of RTCM messages
12 _MAVROS_MSGS_NAME = "mavros_msgs"
13 _RTCM_MSGS_NAME = "rtcm_msgs"
14 have_mavros_msgs = False
15 have_rtcm_msgs = False
16 if importlib.util.find_spec(_MAVROS_MSGS_NAME) is not None:
17  have_mavros_msgs = True
18  from mavros_msgs.msg import RTCM as mavros_msgs_RTCM
19 if importlib.util.find_spec(_RTCM_MSGS_NAME) is not None:
20  have_rtcm_msgs = True
21  from rtcm_msgs.msg import Message as rtcm_msgs_RTCM
22 
24  def __init__(self):
25  # Init the node
26  super().__init__('ntrip_client')
27 
28  # Read some mandatory config
29  host = rospy.get_param('~host', '127.0.0.1')
30  port = rospy.get_param('~port', '2101')
31  mountpoint = rospy.get_param('~mountpoint', 'mount')
32 
33  # Optionally get the ntrip version from the launch file
34  ntrip_version = rospy.get_param('~ntrip_version', None)
35  if ntrip_version == '':
36  ntrip_version = None
37 
38  # If we were asked to authenticate, read the username and password
39  username = None
40  password = None
41  if rospy.get_param('~authenticate', False):
42  username = rospy.get_param('~username', None)
43  password = rospy.get_param('~password', None)
44  if username is None:
45  rospy.logerr(
46  'Requested to authenticate, but param "username" was not set')
47  sys.exit(1)
48  if password is None:
49  rospy.logerr(
50  'Requested to authenticate, but param "password" was not set')
51  sys.exit(1)
52 
53  # Initialize the client
55  host=host,
56  port=port,
57  mountpoint=mountpoint,
58  ntrip_version=ntrip_version,
59  username=username,
60  password=password,
61  logerr=rospy.logerr,
62  logwarn=rospy.logwarn,
63  loginfo=rospy.loginfo,
64  logdebug=rospy.logdebug
65  )
66 
67  # Get some SSL parameters for the NTRIP client
68  self._client.ssl = rospy.get_param('~ssl', False)
69  self._client.cert = rospy.get_param('~cert', None)
70  self._client.key = rospy.get_param('~key', None)
71  self._client.ca_cert = rospy.get_param('~ca_cert', None)
72 
73  # Set parameters on the client
74  self._client.nmea_parser.nmea_max_length = self._nmea_max_length
75  self._client.nmea_parser.nmea_min_length = self._nmea_min_length
76  self._client.reconnect_attempt_max = self._reconnect_attempt_max
77  self._client.reconnect_attempt_wait_seconds = self._reconnect_attempt_wait_seconds
78  self._client.rtcm_timeout_seconds = rospy.get_param('~rtcm_timeout_seconds', NTRIPClient.DEFAULT_RTCM_TIMEOUT_SECONDS)
79 
80 
81 if __name__ == '__main__':
82  ntrip_ros = NTRIPRos()
83  sys.exit(ntrip_ros.run())
ntrip_ros.NTRIPRos.__init__
def __init__(self)
Definition: ntrip_ros.py:24
ntrip_client.ntrip_ros_base.NTRIPRosBase
Definition: ntrip_ros_base.py:29
ntrip_ros.NTRIPRos
Definition: ntrip_ros.py:23
ntrip_client.ntrip_ros_base.NTRIPRosBase._nmea_min_length
_nmea_min_length
Definition: ntrip_ros_base.py:77
ntrip_client.ntrip_client.NTRIPClient
Definition: ntrip_client.py:25
ntrip_client.ntrip_ros_base.NTRIPRosBase._reconnect_attempt_wait_seconds
_reconnect_attempt_wait_seconds
Definition: ntrip_ros_base.py:79
ntrip_client.ntrip_ros_base.NTRIPRosBase._nmea_max_length
_nmea_max_length
Definition: ntrip_ros_base.py:76
ntrip_client.ntrip_ros_base
Definition: ntrip_ros_base.py:1
ntrip_client.ntrip_ros_base.NTRIPRosBase._reconnect_attempt_max
_reconnect_attempt_max
Definition: ntrip_ros_base.py:78
ntrip_ros.NTRIPRos._client
_client
Definition: ntrip_ros.py:54
ntrip_client.ntrip_client
Definition: ntrip_client.py:1


ntrip_client
Author(s): Parker Hannifin Corp
autogenerated on Sat Dec 21 2024 03:32:07