@@ -43,6 +43,11 @@ def gz_node():
4343 return Node ()
4444
4545
46+ def celsius_to_kelvin (value ):
47+ ZERO_CELSIUS_KELVIN = float (273.15 )
48+ return ZERO_CELSIUS_KELVIN + value
49+
50+
4651class JointStates :
4752 def __init__ (self , world , model , debug ):
4853
@@ -153,7 +158,7 @@ def _pub_esc_status(self):
153158 msg .error_count = 0
154159 msg .voltage = 4.0 * 4.2
155160 msg .current = 5.0
156- msg .temperature = 45.0 + 273.15
161+ msg .temperature = celsius_to_kelvin ( 45.0 )
157162 msg .power_rating_pct = 50
158163
159164 msg .esc_index = 0
@@ -183,21 +188,56 @@ def set_rpm(self, esc_index, rpm):
183188# converters
184189def to_uavcan_equipment_air_data_StaticPressure ():
185190 msg = dronecan .uavcan .equipment .air_data .StaticPressure ()
191+ msg .static_pressure = 0.0
192+ msg .static_pressure_variance = 0.0
186193 return msg
187194
188195
189196def to_uavcan_equipment_air_data_StaticTemperature ():
190197 msg = dronecan .uavcan .equipment .air_data .StaticTemperature ()
198+ msg .static_temperature = 0.0
199+ msg .static_temperature_variance = 0.0
191200 return msg
192201
193202
194203def to_uavcan_equipment_power_BatteryInfo ():
195204 msg = dronecan .uavcan .equipment .power .BatteryInfo ()
205+ # Kelvin
206+ msg .temperature = celsius_to_kelvin (20.0 )
207+ # Volt
208+ msg .voltage = 6 * 4.0
209+ # Ampere
210+ msg .current = 0.0
211+ # Watt
212+ msg .average_power_10sec = 0.0
213+ # Watt hours
214+ msg .remaining_capacity_wh = 0.0
215+ # Watt hours
216+ msg .full_charge_capacity_wh = 0.0
217+ # hours
218+ msg .hours_to_full_charge = 0.0
219+ msg .status_flags = msg .STATUS_FLAG_IN_USE
220+ msg .state_of_health_pct = msg .STATE_OF_HEALTH_UNKNOWN
221+ msg .state_of_charge_pct = 100
222+ msg .state_of_charge_pct_stdev = 1
223+ msg .battery_id = 0
224+ msg .model_instance_id = 0
225+ msg .model_name = "MODEL_NAME_UNKNOWN"
196226 return msg
197227
198228
199229def to_ardupilot_equipment_power_BatteryInfoAux ():
200230 msg = dronecan .ardupilot .equipment .power .BatteryInfoAux ()
231+ msg .timestamp .usec = msg .timestamp .UNKNOWN
232+ msg .voltage_cell = [4.0 for x in range (6 )]
233+ msg .cycle_count = 0
234+ msg .over_discharge_count = 0
235+ # Ampere
236+ msg .max_current = 0.0
237+ # Volt
238+ msg .nominal_voltage = 0.0
239+ msg .is_powering_off = False
240+ msg .battery_id = 0
201241 return msg
202242
203243
@@ -237,81 +277,224 @@ def to_dronecan_sensors_magnetometer_MagneticFieldStrengthHiRes():
237277
238278def to_uavcan_equipment_ice_reciprocating_Status ():
239279 msg = dronecan .uavcan .equipment .ice .reciprocating .Status ()
280+ msg .state = 0
281+ msg .flags = 0
282+ msg .engine_load_percent = 0
283+ msg .engine_speed_rpm = 0
284+ msg .spark_dwell_time_ms = 0.0
285+ msg .atmospheric_pressure_kpa = 0.0
286+ msg .intake_manifold_pressure_kpa = 0.0
287+ msg .intake_manifold_temperature = 0.0
288+ msg .coolant_temperature = 0.0
289+ msg .oil_pressure = 0.0
290+ msg .oil_temperature = 0.0
291+ msg .fuel_pressure = 0.0
292+ msg .fuel_consumption_rate_cm3pm = 0.0
293+ msg .estimated_consumed_fuel_volume_cm3 = 0.0
294+ msg .throttle_position_percent = 0
295+ msg .ecu_index = 0
296+ msg .spark_plug_usage = 0
297+ # cylinder_status=ArrayValue(type=uavcan.equipment.ice.reciprocating.CylinderStatus[<=16], items=[])
240298 return msg
241299
242300
243301def to_uavcan_equipment_esc_Status ():
244302 msg = dronecan .uavcan .equipment .esc .Status ()
303+ msg .error_count = 0
304+ # Volt
305+ msg .voltage = 0.0
306+ # Ampere
307+ msg .current = 0.0
308+ # Kelvin
309+ msg .temperature = celsius_to_kelvin (20.0 )
310+ msg .rpm = 0
311+ msg .power_rating_pct = 0
312+ msg .esc_index = 0
245313 return msg
246314
247315
248316def to_uavcan_equipment_esc_StatusExtended ():
249317 msg = dronecan .uavcan .equipment .esc .StatusExtended ()
318+ msg .input_pct = 0
319+ msg .output_pct = 0
320+ # Celsius in [-256, 255]
321+ msg .motor_temperature_degC = 20
322+ # Angle in degrees
323+ msg .motor_angle = 0
324+ msg .status_flags = 0
325+ msg .esc_index = 0
250326 return msg
251327
252328
253329def to_uavcan_equipment_gnss_Fix2 ():
254330 msg = dronecan .uavcan .equipment .gnss .Fix2 ()
331+ msg .timestamp .usec = msg .timestamp .UNKNOWN
332+ msg .gnss_timestamp .usec = msg .gnss_timestamp .UNKNOWN
333+ msg .gnss_time_standard = msg .GNSS_TIME_STANDARD_UTC
334+ msg .num_leap_seconds = msg .NUM_LEAP_SECONDS_UNKNOWN
335+ msg .longitude_deg_1e8 = 0
336+ msg .latitude_deg_1e8 = 0
337+ msg .height_ellipsoid_mm = 0
338+ msg .height_msl_mm = 0
339+ msg .ned_velocity = [0.0 , 0.0 , 0.0 ]
340+ msg .sats_used = 0
341+ msg .status = msg .STATUS_3D_FIX
342+ msg .mode = msg .MODE_DGPS
343+ msg .sub_mode = msg .SUB_MODE_DGPS_OTHER
344+ msg .covariance == []
345+ msg .pdop = float ("nan" )
346+ # dronecan.uavcan.equipment.gnss.ECEFPositionVelocity()
347+ # XYZ velocity in m/s
348+ msg .ecef_position_velocity .velocity_xyz = [0.0 , 0.0 , 0.0 ]
349+ # XYZ-axis coordinates in mm
350+ msg .ecef_position_velocity .position_xyz_mm = [0 , 0 , 0 ]
351+ # Position and velocity covariance in the ECEF frame. Units are m^2 for position,
352+ # (m/s)^2 for velocity, and m^2/s for position/velocity.
353+ msg .ecef_position_velocity .covariance = []
255354 return msg
256355
257356
258357def to_uavcan_equipment_gnss_Auxiliary ():
259358 msg = dronecan .uavcan .equipment .gnss .Auxiliary ()
359+ msg .gdop = float ("nan" )
360+ msg .pdop = float ("nan" )
361+ msg .hdop = float ("nan" )
362+ msg .vdop = float ("nan" )
363+ msg .tdop = float ("nan" )
364+ msg .ndop = float ("nan" )
365+ msg .edop = float ("nan" )
366+ msg .sats_visible = 12
367+ msg .sats_used = 8
260368 return msg
261369
262370
263371def to_ardupilot_gnss_Heading ():
264372 msg = dronecan .ardupilot .gnss .Heading ()
373+ msg .heading_valid = False
374+ msg .heading_accuracy_valid = False
375+ # radians
376+ msg .heading_rad = 0.0
377+ # radians
378+ msg .heading_accuracy_rad = 0.0
265379 return msg
266380
267381
268382def to_ardupilot_gnss_Status ():
269383 msg = dronecan .ardupilot .gnss .Status ()
384+ msg .error_codes = 0
385+ msg .healthy = False
386+ msg .status = msg .STATUS_ARMABLE
270387 return msg
271388
272389
273390def to_ardupilot_gnss_MovingBaselineData ():
274391 msg = dronecan .ardupilot .gnss .MovingBaselineData ()
392+ # length of data is set per the number of bytes for pkt in
393+ # libraries/AP_GPS/RTCM3_Parser.h
394+ msg .data = [int (0 ) for x in range (10 )]
275395 return msg
276396
277397
278398def to_ardupilot_gnss_RelPosHeading ():
279399 msg = dronecan .ardupilot .gnss .RelPosHeading ()
400+ msg .timestamp .usec = msg .timestamp .UNKNOWN
401+ msg .reported_heading_acc_available = False
402+ # degrees
403+ msg .reported_heading_deg = float ("nan" )
404+ # degrees
405+ msg .reported_heading_acc_deg = float ("nan" )
406+ # metres
407+ msg .relative_distance_m = float ("nan" )
408+ # metres
409+ msg .relative_down_pos_m = float ("nan" )
280410 return msg
281411
282412
283413def to_com_hex_equipment_flow_Measurement ():
284414 msg = dronecan .com .hex .equipment .flow .Measurement ()
415+ # Integration Interval in seconds
416+ msg .integration_interval = 0.0
417+ # Integrated Gyro Data in radians
418+ msg .rate_gyro_integral = [0.0 , 0.0 ]
419+ # Integrated LOS Data in radians
420+ msg .flow_integral = [0.0 , 0.0 ]
421+ # Flow Data Quality Lowest(0)-Highest(255) Unitless
422+ quality = 0
285423 return msg
286424
287425
288426def to_ardupilot_equipment_proximity_sensor_Proximity ():
289427 msg = dronecan .ardupilot .equipment .proximity_sensor .Proximity ()
428+ msg .sensor_id = 0
429+ msg .reading_type = msg .READING_TYPE_GOOD
430+ msg .flags = msg .FLAGS_NONE
431+ # degrees in body frame
432+ msg .yaw = 0.0
433+ # degrees in body frame
434+ msg .pitch = 0.0
435+ # metres
436+ msg .distance = 0.0
290437 return msg
291438
292439
293440def to_uavcan_equipment_range_sensor_Measurement ():
441+ roll_rad = 0.0
442+ pitch_rad = 0.0
443+ yaw_rad = 0.0
294444 msg = dronecan .uavcan .equipment .range_sensor .Measurement ()
445+ msg .timestamp .usec = msg .timestamp .UNKNOWN
446+ msg .sensor_id = 0
447+
448+ msg .beam_orientation_in_body_frame .fixed_axis_roll_pitch_yaw = [
449+ int (msg .beam_orientation_in_body_frame .ANGLE_MULTIPLIER * roll_rad ),
450+ int (msg .beam_orientation_in_body_frame .ANGLE_MULTIPLIER * pitch_rad ),
451+ int (msg .beam_orientation_in_body_frame .ANGLE_MULTIPLIER * yaw_rad ),
452+ ]
453+ msg .beam_orientation_in_body_frame .orientation_defined = True
454+ msg .field_of_view = 0.0
455+ msg .sensor_type = msg .SENSOR_TYPE_LIDAR
456+ msg .reading_type = msg .READING_TYPE_VALID_RANGE
457+ # metre
458+ msg .range = 2.0
295459 return msg
296460
297461
298462def to_dronecan_sensors_rc_RCInput ():
299463 msg = dronecan .dronecan .sensors .rc .RCInput ()
464+ msg .status = msg .STATUS_QUALITY_VALID
465+ msg .quality = 255
466+ msg .id = 0
467+ msg .rcin = [0 for x in range (16 )]
300468 return msg
301469
302470
303471def to_dronecan_sensors_rpm_RPM ():
304472 msg = dronecan .dronecan .sensors .rpm .RPM ()
473+ msg .sensor_id = 0
474+ msg .flags = msg .FLAGS_UNHEALTHY
475+ msg .rpm = 0.0
305476 return msg
306477
307478
308479def to_uavcan_equipment_actuator_Status ():
309480 msg = dronecan .uavcan .equipment .actuator .Status ()
481+ msg .actuator_id = 0
482+ # metre or radian
483+ msg .position = float ("nan" )
484+ # Newton or Newton metre
485+ msg .force = float ("nan" )
486+ # metre per second or radian per second
487+ msg .speed = float ("nan" )
488+ msg .power_rating_pct = msg .POWER_RATING_PCT_UNKNOWN
310489 return msg
311490
312491
313492def to_uavcan_equipment_device_Temperature ():
314493 msg = dronecan .uavcan .equipment .device .Temperature ()
494+ msg .device_id = 0
495+ # Kelvin
496+ msg .temperature = celsius_to_kelvin (20.0 )
497+ msg .error_flags = 0
315498 return msg
316499
317500
0 commit comments