34 from sensor_msgs.msg
import Imu, NavSatFix, NavSatStatus
35 from nav_msgs.msg
import Odometry
36 from geometry_msgs.msg
import Quaternion, Point, Pose, Twist
38 from math
import radians, pow
42 IMU_ORIENT_COVAR = [1e-3, 0, 0,
46 IMU_VEL_COVAR = [1e-3, 0, 0,
50 IMU_ACCEL_COVAR = [1e-3, 0, 0,
54 NAVSAT_COVAR = [1, 0, 0,
58 POSE_COVAR = [1, 0, 0, 0, 0, 0,
65 TWIST_COVAR = [1, 0, 0, 0, 0, 0,
74 """ Subscribes to the directly-translated messages from the SPAN system 75 and repackages the resultant data as standard ROS messages. """ 80 self.
odom_frame = rospy.get_param(
'~odom_frame',
'odom_combined')
81 self.
base_frame = rospy.get_param(
'~base_frame',
'base_link')
90 self.
pub_imu = rospy.Publisher(
'imu/data', Imu, queue_size=1)
91 self.
pub_odom = rospy.Publisher(
'navsat/odom', Odometry, queue_size=1)
92 self.
pub_origin = rospy.Publisher(
'navsat/origin', Pose, queue_size=1, latch=
True)
93 self.
pub_navsatfix = rospy.Publisher(
'navsat/fix', NavSatFix, queue_size=1)
104 rospy.Subscriber(
'novatel_data/bestpos', BESTPOS, self.
bestpos_handler)
106 rospy.Subscriber(
'novatel_data/inscov', INSCOV, self.
inscov_handler)
107 rospy.Subscriber(
'novatel_data/inspvax', INSPVAX, self.
inspvax_handler)
113 navsat.header.stamp = rospy.Time.now()
117 navsat.status.service = NavSatStatus.SERVICE_GPS
119 position_type_to_status = {
120 BESTPOS.POSITION_TYPE_NONE: NavSatStatus.STATUS_NO_FIX,
121 BESTPOS.POSITION_TYPE_FIXED: NavSatStatus.STATUS_FIX,
122 BESTPOS.POSITION_TYPE_FIXEDHEIGHT: NavSatStatus.STATUS_FIX,
123 BESTPOS.POSITION_TYPE_FLOATCONV: NavSatStatus.STATUS_FIX,
124 BESTPOS.POSITION_TYPE_WIDELANE: NavSatStatus.STATUS_FIX,
125 BESTPOS.POSITION_TYPE_NARROWLANE: NavSatStatus.STATUS_FIX,
126 BESTPOS.POSITION_TYPE_DOPPLER_VELOCITY: NavSatStatus.STATUS_FIX,
127 BESTPOS.POSITION_TYPE_SINGLE: NavSatStatus.STATUS_FIX,
128 BESTPOS.POSITION_TYPE_PSRDIFF: NavSatStatus.STATUS_GBAS_FIX,
129 BESTPOS.POSITION_TYPE_WAAS: NavSatStatus.STATUS_GBAS_FIX,
130 BESTPOS.POSITION_TYPE_PROPAGATED: NavSatStatus.STATUS_GBAS_FIX,
131 BESTPOS.POSITION_TYPE_OMNISTAR: NavSatStatus.STATUS_SBAS_FIX,
132 BESTPOS.POSITION_TYPE_L1_FLOAT: NavSatStatus.STATUS_GBAS_FIX,
133 BESTPOS.POSITION_TYPE_IONOFREE_FLOAT: NavSatStatus.STATUS_GBAS_FIX,
134 BESTPOS.POSITION_TYPE_NARROW_FLOAT: NavSatStatus.STATUS_GBAS_FIX,
135 BESTPOS.POSITION_TYPE_L1_INT: NavSatStatus.STATUS_GBAS_FIX,
136 BESTPOS.POSITION_TYPE_WIDE_INT: NavSatStatus.STATUS_GBAS_FIX,
137 BESTPOS.POSITION_TYPE_NARROW_INT: NavSatStatus.STATUS_GBAS_FIX,
138 BESTPOS.POSITION_TYPE_RTK_DIRECT_INS: NavSatStatus.STATUS_GBAS_FIX,
139 BESTPOS.POSITION_TYPE_INS_SBAS: NavSatStatus.STATUS_SBAS_FIX,
140 BESTPOS.POSITION_TYPE_INS_PSRSP: NavSatStatus.STATUS_GBAS_FIX,
141 BESTPOS.POSITION_TYPE_INS_PSRDIFF: NavSatStatus.STATUS_GBAS_FIX,
142 BESTPOS.POSITION_TYPE_INS_RTKFLOAT: NavSatStatus.STATUS_GBAS_FIX,
143 BESTPOS.POSITION_TYPE_INS_RTKFIXED: NavSatStatus.STATUS_GBAS_FIX,
144 BESTPOS.POSITION_TYPE_INS_OMNISTAR: NavSatStatus.STATUS_GBAS_FIX,
145 BESTPOS.POSITION_TYPE_INS_OMNISTAR_HP: NavSatStatus.STATUS_GBAS_FIX,
146 BESTPOS.POSITION_TYPE_INS_OMNISTAR_XP: NavSatStatus.STATUS_GBAS_FIX,
147 BESTPOS.POSITION_TYPE_OMNISTAR_HP: NavSatStatus.STATUS_SBAS_FIX,
148 BESTPOS.POSITION_TYPE_OMNISTAR_XP: NavSatStatus.STATUS_SBAS_FIX,
149 BESTPOS.POSITION_TYPE_PPP_CONVERGING: NavSatStatus.STATUS_SBAS_FIX,
150 BESTPOS.POSITION_TYPE_PPP: NavSatStatus.STATUS_SBAS_FIX,
151 BESTPOS.POSITION_TYPE_INS_PPP_CONVERGING: NavSatStatus.STATUS_SBAS_FIX,
152 BESTPOS.POSITION_TYPE_INS_PPP: NavSatStatus.STATUS_SBAS_FIX,
154 navsat.status.status = position_type_to_status.get(bestpos.position_type,
155 NavSatStatus.STATUS_NO_FIX)
158 navsat.latitude = bestpos.latitude
159 navsat.longitude = bestpos.longitude
162 navsat.altitude = bestpos.altitude + bestpos.undulation
163 navsat.position_covariance[0] = pow(2, bestpos.latitude_std)
164 navsat.position_covariance[4] = pow(2, bestpos.longitude_std)
165 navsat.position_covariance[8] = pow(2, bestpos.altitude_std)
166 navsat.position_covariance_type = NavSatFix.COVARIANCE_TYPE_DIAGONAL_KNOWN
169 self.pub_navsatfix.publish(navsat)
174 utm_pos = geodesy.utm.fromLatLong(inspvax.latitude, inspvax.longitude)
180 self.origin.x = utm_pos.easting
181 self.origin.y = utm_pos.northing
182 self.origin.z = inspvax.altitude
183 self.pub_origin.publish(position=self.
origin)
186 odom.header.stamp = rospy.Time.now()
189 odom.pose.pose.position.x = utm_pos.easting - self.origin.x
190 odom.pose.pose.position.y = utm_pos.northing - self.origin.y
191 odom.pose.pose.position.z = inspvax.altitude - self.origin.z
196 self.
orientation = tf.transformations.quaternion_from_euler(
197 radians(inspvax.roll),
198 radians(inspvax.pitch),
199 -radians(inspvax.azimuth),
'syxz')
200 odom.pose.pose.orientation = Quaternion(*self.
orientation)
206 odom.twist.twist.linear.x = inspvax.east_velocity
207 odom.twist.twist.linear.y = inspvax.north_velocity
208 odom.twist.twist.linear.z = inspvax.up_velocity
209 TWIST_COVAR[0] = pow(2, inspvax.east_velocity_std)
210 TWIST_COVAR[7] = pow(2, inspvax.north_velocity_std)
211 TWIST_COVAR[14] = pow(2, inspvax.up_velocity_std)
212 odom.twist.covariance = TWIST_COVAR
214 self.pub_odom.publish(odom)
218 self.tf_broadcast.sendTransform(
219 (odom.pose.pose.position.x, odom.pose.pose.position.y,
220 odom.pose.pose.position.z),
222 odom.header.stamp, odom.child_frame_id, odom.header.frame_id)
230 imu.header.stamp = rospy.Time.now()
239 imu.angular_velocity.x = corrimudata.pitch_rate * self.
imu_rate 240 imu.angular_velocity.y = corrimudata.roll_rate * self.
imu_rate 241 imu.angular_velocity.z = corrimudata.yaw_rate * self.
imu_rate 242 imu.angular_velocity_covariance = IMU_VEL_COVAR
245 imu.linear_acceleration.x = corrimudata.x_accel * self.
imu_rate 246 imu.linear_acceleration.y = corrimudata.y_accel * self.
imu_rate 247 imu.linear_acceleration.z = corrimudata.z_accel * self.
imu_rate 248 imu.linear_acceleration_covariance = IMU_ACCEL_COVAR
250 self.pub_imu.publish(imu)
def inspvax_handler(self, inspvax)
def bestpos_handler(self, bestpos)
def inscov_handler(self, inscov)
def corrimudata_handler(self, corrimudata)