Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_DISCO_F746NG Graphics mbed TS_DISCO_F746NG
Target.cpp
00001 // 00002 // Target.cpp - Simple simulation of radar target 00003 // 00004 00005 #include "Target.h" 00006 #include "math.h" 00007 00008 Target::Target(int id, float speed, float direction) 00009 { 00010 Id = id; 00011 00012 _speed = speed; 00013 _direction = direction; 00014 00015 _type = 0; 00016 _lastUpdateTime = 0; 00017 } 00018 00019 00020 Target::Target(int id, float x, float y, float h, float speed, float direction) 00021 { 00022 _location.SetLocation(x, y, h); 00023 _speed = speed; 00024 _direction = direction; 00025 00026 _type = 0; 00027 _lastUpdateTime = 0; 00028 Id = id; 00029 } 00030 00031 Location Target::GetLocation() 00032 { 00033 return _location; 00034 } 00035 00036 void Target::SetLocation(float x, float y) 00037 { 00038 _location.SetLocation(x, y, _location.GetHeight()); 00039 } 00040 00041 float Target::GetX() 00042 { 00043 return _location.GetX(); 00044 } 00045 00046 float Target::GetY() 00047 { 00048 return _location.GetY(); 00049 } 00050 00051 float Target::GetAzimuth() 00052 { 00053 return _location.GetAzimuth(); 00054 } 00055 00056 float Target::GetDistance() 00057 { 00058 return _location.GetDistance(); 00059 } 00060 00061 float Target::GetDirection() 00062 { 00063 return _direction; 00064 } 00065 00066 float Target::GetSpeed() 00067 { 00068 return _speed; 00069 } 00070 00071 int Target::GetType() 00072 { 00073 return _type; 00074 } 00075 00076 void Target::UpdateLocationForTime(uint32_t currentTime) 00077 { 00078 // Calculate time period from last update 00079 uint32_t timePeriod = currentTime - _lastUpdateTime; 00080 _lastUpdateTime = currentTime; 00081 00082 float distance = _speed * timePeriod / 3600000; 00083 float dx = distance * sinf(GetDirection()); 00084 float dy = distance * cosf(GetDirection()); 00085 SetLocation(GetX() + dx, GetY() + dy); 00086 } 00087 00088 void Target::SetLocationAngular(float distance, float azimuth) 00089 { 00090 _location.SetLocationAngular(distance, azimuth, _location.GetElevation()); 00091 }
Generated on Wed Jul 13 2022 08:01:03 by
1.7.2