Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 import rospy
00045 import roslib.message
00046 import applanix_msgs.msg
00047 import applanix_msgs.srv
00048
00049 response_codes = dict([(val, name) for name, val in applanix_msgs.msg.Ack.__dict__.items() if name.startswith("RESPONSE_")])
00050
00051
00052 def main():
00053 rospy.init_node("applanix_params")
00054
00055 gams_params = rospy.get_param('gams_params', None)
00056 if gams_params != None:
00057 req_msg = applanix_msgs.msg.GAMSParams()
00058 req_msg.antenna_separation = gams_params['antenna_separation']
00059 req_msg.baseline_vector.x = gams_params['baseline_vector']['x']
00060 req_msg.baseline_vector.y = gams_params['baseline_vector']['y']
00061 req_msg.baseline_vector.z = gams_params['baseline_vector']['z']
00062 req_msg.max_heading_error_rms = gams_params['max_heading_error_rms']
00063 call_applanix_service('gams',req_msg)
00064 rospy.loginfo("Configured GAMS params.")
00065
00066 dmi_params = rospy.get_param('dmi_params', None)
00067 if dmi_params != None:
00068 req_msg = applanix_msgs.msg.AidingSensorParams()
00069 req_msg.dmi_scale_factor = dmi_params['dmi_scale_factor']
00070 req_msg.dmi_lever_arm.x = dmi_params['dmi_lever_arm']['x']
00071 req_msg.dmi_lever_arm.y = dmi_params['dmi_lever_arm']['y']
00072 req_msg.dmi_lever_arm.z = dmi_params['dmi_lever_arm']['z']
00073 call_applanix_service('aiding_sensors',req_msg)
00074 rospy.loginfo("Configured DMI params.")
00075
00076 com_ports = rospy.get_param('com_ports', None)
00077 if com_ports != None:
00078 req_msg = applanix_msgs.msg.COMPortSetup()
00079 for port_num, port_params in enumerate(com_ports):
00080
00081 port_msg = applanix_msgs.msg.COMPortParams()
00082 port_msg.parity = port_msg.PARITY_NONE
00083 port_msg.data_stop = port_msg.DATA_8_STOP_1
00084 port_msg.flow = port_msg.FLOW_NONE
00085 port_msg.baud = getattr(port_msg, "BAUD_%s" % port_params['baud'])
00086 port_msg.input_select = getattr(port_msg, "INPUT_%s" % port_params['input'])
00087 port_msg.output_select = getattr(port_msg, "OUTPUT_%s" % port_params['output'])
00088 req_msg.port_mask |= 2 << port_num
00089 req_msg.ports.append(port_msg)
00090
00091 call_applanix_service("com_port_setup", req_msg)
00092 rospy.loginfo("Configured COM ports.")
00093
00094 base_gnss = rospy.get_param('base_gnss', None)
00095 if base_gnss != None:
00096 for base_num, base_params in enumerate(base_gnss):
00097 base_msg = applanix_msgs.msg.BaseGNSSSetup()
00098 base_msg.base_gnss_input_type = getattr(base_msg, "TYPE_%s" % base_params['type'])
00099 base_msg.datum = getattr(base_msg, "DATUM_%s" % base_params['datum'])
00100 call_applanix_service("base_gnss_%i_setup" % (base_num + 1), base_msg)
00101 rospy.loginfo("Configured base GNSS #%i." % (base_num + 1))
00102
00103 geometry = rospy.get_param('geometry', None)
00104 if geometry != None:
00105 req_msg = applanix_msgs.msg.GeneralParams()
00106 for vector_name in ['imu_lever_arm', 'primary_gnss_lever_arm', 'imu_mounting_angle', 'ref_mounting_angle', 'aux_1_gnss_lever_arm', 'aux_2_gnss_lever_arm']:
00107 if vector_name in geometry:
00108 vector = geometry[vector_name]
00109 getattr(req_msg, vector_name).x = vector['x']
00110 getattr(req_msg, vector_name).y = vector['y']
00111 getattr(req_msg, vector_name).z = vector['z']
00112 req_msg.time_types = 0x1
00113 req_msg.distance_type = 1
00114 req_msg.autostart = 1
00115 req_msg.multipath = 0
00116 call_applanix_service('general', req_msg)
00117 rospy.loginfo("Configured geometry.")
00118
00119
00120
00121 rate = rospy.get_param('rate', 10)
00122 rospy.Subscriber("subscribed_groups", applanix_msgs.msg.Groups, groups_callback)
00123
00124
00125 sensor_overrides = rospy.get_param('sensor_overrides', None)
00126 if sensor_overrides != None:
00127 override_msg = applanix_msgs.msg.AidingSensorIntegrationControl()
00128 for override_str in sensor_overrides:
00129 override_msg.override |= getattr(override_msg, "OVERRIDE_%s" % override_str)
00130 rospy.loginfo("Waiting on Fine Align before configuring sensor overrides.")
00131 proceed = [False]
00132 def _cb(msg):
00133 if msg.status_a & applanix_msgs.msg.GeneralStatus.STATUS_A_FINE_ALIGN_ACTIVE != 0:
00134 proceed[0] = True
00135 sub = rospy.Subscriber("status/general", applanix_msgs.msg.GeneralStatus, _cb)
00136 while not proceed[0]:
00137 rospy.sleep(1.)
00138 sub.unregister()
00139 call_applanix_service("aiding_sensor_integration", override_msg)
00140 rospy.loginfo("Configured sensor overrides.")
00141
00142 rospy.spin()
00143
00144
00145 def call_applanix_service(name, req):
00146 service_defn = getattr(applanix_msgs.srv, "Set" + req.__class__.__name__)
00147 rospy.wait_for_service(name)
00148 ack = rospy.ServiceProxy(name, service_defn)(req).ack
00149 if ack.response_code != applanix_msgs.msg.Ack.RESPONSE_ACCEPTED:
00150 rospy.logwarn("Parameter change call to %s resulted in error code %d (%s)." %
00151 (name, ack.response_code, response_codes[ack.response_code]))
00152 return ack
00153
00154
00155 def groups_callback(message):
00156 req_msg = applanix_msgs.msg.PortControl()
00157 req_msg.rate = rospy.get_param('rate', 10)
00158 groups = set(message.groups)
00159 groups.add(10)
00160 for group_num in groups:
00161 req_msg.groups.append(applanix_msgs.msg.OutputGroup(group=group_num))
00162 call_applanix_service("primary_data_port", req_msg)
00163