Commit edd3d613 authored by Andrey Filippov's avatar Andrey Filippov

Adding 2D scan

parent 3ed6ebc5
......@@ -31,9 +31,15 @@ $EL_PLAY = 1.0; // Hysteresis caused by mechanical play (degrees)
$EL_RESCAN = 8; // (degrees) around expected center
$EL_RESCAN_STEP = 0.5; // (degrees)
$AZ_2D_RANGE = 2.0; // degrees 2D peaking scan azimuth (full range)
$EL_2D_RANGE = 3.0; // degrees 2D peaking scan alevation (full range)
$AZ_2D_STEP = 0.25; // degrees
$EL_2D_STEP = 0.4; // degrees
$ADJUST_2D = 1; // 1 - adjust 2D, 0 - skip (only separate azimuth and elevation
$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
$ARGMAX_OURSIDE = 0.2; // Allow argmax outside of the measured range by this fraction
$ARGMAX_OURSIDE_2D = 0.0; // Allow argmax outside of the measured range by this fraction during 2D peaking
/*
http://192.168.1.250/motor.xml?Action=ElUp&Distance=0.5&Units=1 0.5 degree up
......@@ -66,7 +72,8 @@ if (true) {
for ($i= 0; $i < $rows; $i++){
$line = $arr;
for ($j= 0; $j < $cols; $j++){
$line[$j] *= $arr[$i]/51;
$i1 = ($i + 10) % $rows;
$line[$j] *= $arr[$i1]/51;
$line[$j] += rand(-10,10);
if ($line[$j] <1){
$line[$j] = 1;
......@@ -127,6 +134,14 @@ if ($scan_mode){
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);
$DishAngle1D = $xml_state->DishAngle;
if (intval ($Success) && $ADJUST_2D){
$Success = peak2D($xml_state, $AZ_PLAY, $EL_PLAY, $AZ_2D_RANGE, $EL_2D_RANGE, $AZ_2D_STEP, $EL_2D_STEP, $USABLE_FRACT, $USABLE_POW, $ARGMAX_OURSIDE_2D);
$xml_state = simplexml_load_file($motosat_url);
if ($Success){
$DishAngle2D = $xml_state->DishAngle;
}
}
}
}
......@@ -137,6 +152,12 @@ if ($scan_mode){
$xml->addChild ('Success',(string) $Success );
$xml->addChild ('SignalQuality',(string) $SignalQuality );
if (isset($DishAngle1D)){
$xml->addChild ('DishAngle1D',$xml_state->$DishAngle1D );
}
if (isset($DishAngle2D)){
$xml->addChild ('DishAngle2D',$xml_state->$DishAngle2D );
}
$xml->addChild ('DishAngle',$xml_state->DishAngle );
$xml->addChild ('DishCount',$xml_state->DishCountt );
$xml->addChild ('busy',(string) $busy );
......@@ -175,6 +196,75 @@ header('Access-Control-Allow-Origin: *');
printf($rslt);
exit (0);
function peak2D($xml_state, $az_play, $el_play, $az_range, $el_range, $az_step, $el_step, $fract, $pow = 1.0, $argmax_outside=0.0){
global $motosat_url, $dbg_file;
if ($xml_state === null){
$xml_state = simplexml_load_file($motosat_url);
}
$DishAngle = getDishAngles ($xml_state);
$azel_start_center = $DishAngle;
//move to sart rescan azimuth minus mechanical play
$DishAngle[0] = $azel_start_center[0] - $az_play - $az_range/2;
$DishAngle[1] = $azel_start_center[1] - $el_play - $el_range/2;
moveElAzSk_degrees($DishAngle);
$scan_strengths = Array();
for ($el = $azel_start_center[1] - $el_range / 2; $el < ($azel_start_center[1] + $el_range / 2 + $el_step); $el += $el_step) {
$scan_strengths_line = Array();
$DishAngle[1] = $el;
for ($az = $azel_start_center[0] - $az_range / 2; $az < ($azel_start_center[0] + $az_range / 2 + $az_step); $az += $az_step) {
$DishAngle[0] = $az;
moveElAzSk_degrees($DishAngle); // to be on the safe side re-read xml
$modem_strength = getModemStrength();
$scan_strengths_line[] = $modem_strength;
}
$scan_strengths[] = $scan_strengths_line;
}
if ($dbg_file !== null) {
fprintf($dbg_file, "==== 2D scan strengths: ====\n");
fprintf($dbg_file, print_r($scan_strengths, 1));
}
// $rel_argmax = findMax1d($scan_strengths, $fract, $pow, $argmax_outside);
$rel_argmax = findMax2d($scan_strengths, $fract, $pow, $argmax_outside); // $pow not yet used
$azel_argmax = $azel_start_center;
$success = 0;
if ($rel_argmax !== null) {
$azel_argmax = array(
$azel_start_center[0] - $az_range / 2 + $az_step * $rel_argmax[0],
$azel_start_center[1] - $el_range / 2 + $el_step * $rel_argmax[1]
);
$success = 1;
} else {
if ($dbg_file !== null) {
fprintf($dbg_file, "****** Failed to find maximum for 2d peaking, going to known position.\n");
}
}
if ($dbg_file !== null) {
fprintf($dbg_file, "reltive argmax = [az=%f, el=%f]\n", $rel_argmax[0], $rel_argmax[1]);
fprintf($dbg_file, " argmax = [az=%f, el=%f] (was [az=%f, el=%f])\n", $azel_argmax[0], $azel_argmax[1], $azel_start_center[0], $azel_start_center[1]);
}
$DishAngle[0] = $azel_argmax[0] - $az_play;
$DishAngle[1] = $azel_argmax[1] - $el_play;
if ($dbg_file !== null) {
fprintf($dbg_file, "====== Moving to compensate az/el motors play to [az=%f, el=%f]\n", $DishAngle[0], $DishAngle[1]);
}
moveElAzSk_degrees($DishAngle);
$DishAngle[0] = $azel_argmax[0];
$DishAngle[1] = $azel_argmax[1];
if ($dbg_file !== null) {
fprintf($dbg_file, "====== Moving to argmax position = [az=%f, el=%f]\n", $DishAngle[0], $DishAngle[1]);
}
moveElAzSk_degrees($DishAngle);
return $success; // success
}
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;
if ($xml_state === null){
......
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