Commit 099a66d6 authored by Andrey Filippov's avatar Andrey Filippov

tested both directions

parent 7379a2c1
...@@ -25,7 +25,12 @@ $LATE_STOP_AZ = 30; // steps ...@@ -25,7 +25,12 @@ $LATE_STOP_AZ = 30; // steps
// Rescan azimuth after noticed a satellite during area scan // Rescan azimuth after noticed a satellite during area scan
$AZ_PLAY = 1.0; // Hysteresis caused by mechanical play (degrees) $AZ_PLAY = 1.0; // Hysteresis caused by mechanical play (degrees)
$AZ_RESCAN = 8; // (degrees) around expected center $AZ_RESCAN = 8; // (degrees) around expected center
$AZ_RESCAN_STEP = 0.25; // (degrees) $AZ_RESCAN_STEP = 0.5; // (degrees)
$EL_PLAY = 1.0; // Hysteresis caused by mechanical play (degrees)
$EL_RESCAN = 8; // (degrees) around expected center
$EL_RESCAN_STEP = 0.5; // (degrees)
$USABLE_FRACT = 0.6; // use ony samples not less than this fraction of maximal $USABLE_FRACT = 0.6; // use ony samples not less than this fraction of maximal
$USABLE_POW = 1.0; // transform (maxstrengh - strengh) by applying pow - 1.2 ...1.3 may have marginal improvements $USABLE_POW = 1.0; // transform (maxstrengh - strengh) by applying pow - 1.2 ...1.3 may have marginal improvements
$ARGMAX_OURSIDE = 0.2; // Allow argmax outside of the measured range by this fraction $ARGMAX_OURSIDE = 0.2; // Allow argmax outside of the measured range by this fraction
...@@ -98,8 +103,12 @@ if ($scan_mode){ ...@@ -98,8 +103,12 @@ if ($scan_mode){
$Success = $xml_state->Success; $Success = $xml_state->Success;
if (intval ($Success)){ if (intval ($Success)){
peakAzimuth($xml_state, $AZ_PLAY,$AZ_RESCAN, $AZ_RESCAN_STEP, $USABLE_FRACT, $USABLE_POW, $ARGMAX_OURSIDE); $Success = peakAzimuthOrElevation($xml_state, 0, $AZ_PLAY,$AZ_RESCAN, $AZ_RESCAN_STEP, $USABLE_FRACT, $USABLE_POW, $ARGMAX_OURSIDE);
$xml_state = simplexml_load_file($motosat_url); $xml_state = simplexml_load_file($motosat_url);
if (intval ($Success)){
$Success = peakAzimuthOrElevation($xml_state, 1, $EL_PLAY,$EL_RESCAN, $EL_RESCAN_STEP, $USABLE_FRACT, $USABLE_POW, $ARGMAX_OURSIDE);
$xml_state = simplexml_load_file($motosat_url);
}
} }
$xml = new SimpleXMLElement("<?xml version='1.0'?><motosat/>"); $xml = new SimpleXMLElement("<?xml version='1.0'?><motosat/>");
...@@ -147,61 +156,64 @@ header('Access-Control-Allow-Origin: *'); ...@@ -147,61 +156,64 @@ header('Access-Control-Allow-Origin: *');
printf($rslt); printf($rslt);
exit (0); exit (0);
function peakAzimuth($xml_state, $az_play,$az_range, $az_step, $fract, $pow = 1.0, $argmax_outside=0.2){ function peakAzimuthOrElevation($xml_state, $el_not_az, $azel_play, $azel_range, $azel_step, $fract, $pow = 1.0, $argmax_outside=0.2){
global $motosat_url,$dbg_file; global $motosat_url, $dbg_file;
if ($xml_state === null){ if ($xml_state === null){
$xml_state = simplexml_load_file($motosat_url); $xml_state = simplexml_load_file($motosat_url);
} }
$DishAngle = getDishAngles ($xml_state); $DishAngle = getDishAngles ($xml_state);
$az_start_center = $DishAngle[0]; $motor = $el_not_az ? 1: 0;
$direction = $el_not_az ? "ELEVATION" : "AZIMUTH";
$azel_start_center = $DishAngle[$motor];
//move to sart rescan azimuth minus mechanical play //move to sart rescan azimuth minus mechanical play
$DishAngle[0] = $az_start_center - $az_play - $az_range/2; $DishAngle[$motor] = $azel_start_center - $azel_play - $azel_range/2;
moveElAzSk_degrees($DishAngle); moveElAzSk_degrees($DishAngle);
$scan_strengths = Array(); $scan_strengths = Array();
for ($az = $az_start_center - $az_range/2; for ($azel = $azel_start_center - $azel_range/2;
$az < ($az_start_center + $az_range/2 + $az_step); $azel < ($azel_start_center + $azel_range/2 + $azel_step);
$az += $az_step){ $azel += $azel_step){
$DishAngle[0] = $az; $DishAngle[$motor] = $azel;
moveElAzSk_degrees($DishAngle); // to be on the safe side re-read xml moveElAzSk_degrees($DishAngle); // to be on the safe side re-read xml
$modem_strength= getModemStrength(); $modem_strength= getModemStrength();
$scan_strengths[] = $modem_strength; $scan_strengths[] = $modem_strength;
} }
if ($dbg_file !== null) { if ($dbg_file !== null) {
fprintf($dbg_file, "==== Azimuth scan strengths: ====\n"); fprintf($dbg_file, "==== $direction scan strengths: ====\n");
fprintf($dbg_file, print_r($scan_strengths, 1)); fprintf($dbg_file, print_r($scan_strengths, 1));
} }
$rel_argmax = findMax1d($scan_strengths, $fract, $pow, $argmax_outside); $rel_argmax = findMax1d($scan_strengths, $fract, $pow, $argmax_outside);
if ($rel_argmax !== null) { if ($rel_argmax !== null) {
$az_argmax = $az_start_center - $az_range / 2 + $az_step * $rel_argmax; $azel_argmax = $azel_start_center - $azel_range / 2 + $azel_step * $rel_argmax;
if ($dbg_file !== null) { if ($dbg_file !== null) {
fprintf($dbg_file, "reltive argmax = %f\n", $rel_argmax); fprintf($dbg_file, "reltive argmax = %f\n", $rel_argmax);
fprintf($dbg_file, "azimuth argmax = %f (was %f)\n", $az_argmax, $az_start_center); fprintf($dbg_file, "$direction argmax = %f (was %f)\n", $azel_argmax, $azel_start_center);
} }
$DishAngle[0] = $az_argmax - $az_play; $DishAngle[$motor] = $azel_argmax - $azel_play;
if ($dbg_file !== null) { if ($dbg_file !== null) {
fprintf($dbg_file, "====== Moving azimuth to compensate motor play to = %f\n", $DishAngle[0]); fprintf($dbg_file, "====== Moving $direction to compensate motor play to = %f\n", $DishAngle[$motor]);
} }
moveElAzSk_degrees($DishAngle); moveElAzSk_degrees($DishAngle);
$DishAngle[0] = $az_argmax; $DishAngle[$motor] = $azel_argmax;
if ($dbg_file !== null) { if ($dbg_file !== null) {
fprintf($dbg_file, "====== Moving azimuth to argmax position = %f\n", $DishAngle[0]); fprintf($dbg_file, "====== Moving $direction to argmax position = %f\n", $DishAngle[$motor]);
} }
moveElAzSk_degrees($DishAngle); moveElAzSk_degrees($DishAngle);
return 1; // success
} else { } else {
// for now - move back // for now - move back
if ($dbg_file !== null) { if ($dbg_file !== null) {
fprintf($dbg_file, "****** Failed to find maximum, going to known position.\n"); fprintf($dbg_file, "****** Failed to find maximum for $direction, going to known position.\n");
} }
$DishAngle[0] = $az_start_center; $DishAngle[$motor] = $azel_start_center;
moveElAzSk_degrees($DishAngle); moveElAzSk_degrees($DishAngle);
return 0; // failed
} }
return;
} }
function findMax1d($data, $fract, $pow, $frac_outside = 0.2){ function findMax1d($data, $fract, $pow, $frac_outside = 0.2){
global $dbg_file; global $dbg_file;
$min= $data[0]; $min= $data[0];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment