@@ -133,8 +133,8 @@ MissionImport::import_mission(const Json::Value& root, Autopilot autopilot)
133
133
0 .0f ,
134
134
0 .0f ,
135
135
0 .0f ,
136
- static_cast < int32_t >( std::round ( home[0 ]. asDouble () * 1e7 ) ),
137
- static_cast < int32_t >( std::round ( home[1 ]. asDouble () * 1e7 ) ),
136
+ set_int32 ( home[0 ], MAV_FRAME_GLOBAL_INT ),
137
+ set_int32 ( home[1 ], MAV_FRAME_GLOBAL_INT ),
138
138
home[2 ].asFloat (),
139
139
MAV_MISSION_TYPE_MISSION});
140
140
}
@@ -225,8 +225,8 @@ MissionImport::import_rally_points(const Json::Value& root)
225
225
item.command = MAV_CMD_NAV_RALLY_POINT;
226
226
item.frame = MAV_FRAME_GLOBAL_RELATIVE_ALT;
227
227
item.mission_type = MAV_MISSION_TYPE_RALLY;
228
- item.x = set_int32 (point[0 ]);
229
- item.y = set_int32 (point[1 ]);
228
+ item.x = set_int32 (point[0 ], item. frame );
229
+ item.y = set_int32 (point[1 ], item. frame );
230
230
item.z = set_float (point[2 ]);
231
231
232
232
rally_items.push_back (item);
@@ -281,10 +281,10 @@ MissionImport::import_simple_mission_item(const Json::Value& json_item)
281
281
item.param4 = set_float (json_item[" params" ][i]);
282
282
break ;
283
283
case 4 :
284
- item.x = set_int32 (json_item[" params" ][i]);
284
+ item.x = set_int32 (json_item[" params" ][i], item. frame );
285
285
break ;
286
286
case 5 :
287
- item.y = set_int32 (json_item[" params" ][i]);
287
+ item.y = set_int32 (json_item[" params" ][i], item. frame );
288
288
break ;
289
289
case 6 :
290
290
item.z = set_float (json_item[" params" ][i]);
@@ -363,8 +363,8 @@ MissionImport::import_polygon_geofences(const Json::Value& polygons)
363
363
MAV_CMD_NAV_FENCE_POLYGON_VERTEX_EXCLUSION;
364
364
item.frame = MAV_FRAME_GLOBAL;
365
365
item.param1 = set_float (points.size ());
366
- item.x = set_int32 (point[0 ]);
367
- item.y = set_int32 (point[1 ]);
366
+ item.x = set_int32 (point[0 ], item. frame );
367
+ item.y = set_int32 (point[1 ], item. frame );
368
368
item.mission_type = MAV_MISSION_TYPE_FENCE;
369
369
370
370
polygon_geofences.push_back (item);
@@ -390,8 +390,8 @@ MissionImport::import_circular_geofences(const Json::Value& circles)
390
390
inclusion ? MAV_CMD_NAV_FENCE_CIRCLE_INCLUSION : MAV_CMD_NAV_FENCE_CIRCLE_EXCLUSION;
391
391
item.frame = MAV_FRAME_GLOBAL;
392
392
item.param1 = set_float (radius);
393
- item.x = set_int32 (center[0 ]);
394
- item.y = set_int32 (center[1 ]);
393
+ item.x = set_int32 (center[0 ], item. frame );
394
+ item.y = set_int32 (center[1 ], item. frame );
395
395
item.mission_type = MAV_MISSION_TYPE_FENCE;
396
396
397
397
circular_geofences.push_back (item);
@@ -405,9 +405,14 @@ float MissionImport::set_float(const Json::Value& val)
405
405
return val.isNull () ? NAN : val.asFloat ();
406
406
}
407
407
408
- int32_t MissionImport::set_int32 (const Json::Value& val)
408
+ int32_t MissionImport::set_int32 (const Json::Value& val, uint32_t frame )
409
409
{
410
- return static_cast <int32_t >(val.isNull () ? 0 : (std::round (val.asDouble () * 1e7 )));
410
+ // Don't apply 10^7 conversion for MAV_FRAME_MISSION
411
+ if (frame == MAV_FRAME_MISSION) {
412
+ return static_cast <int32_t >(val.isNull () ? 0 : val.asFloat ());
413
+ } else {
414
+ return static_cast <int32_t >(val.isNull () ? 0 : (std::round (val.asDouble () * 1e7 )));
415
+ }
411
416
}
412
417
413
418
} // namespace mavsdk
0 commit comments