Aerospace Blockset for Xcos  

Aerospace Blockset for Xcos Commit Details

Date:2014-09-15 14:54:30 (4 years 1 month ago)
Author:Paweł Zagórski
Branch:master
Commit:402b676d45fdaf5874d898662678810a27c47e70
Parents: 6b6994478cc56b877d7fdda45b3c12f5bd3c3b17
Message:Added ELL_TO_CAR block

Changes:
Cmacros/AB_co_car2ell.sci → macros/AB_co_ell2car.sci
Cmacros/CAR_TO_ELL.sci → macros/ELL_TO_CAR.sci
Metc/aerospace_blockset.start (1 diff)
Mmacros/buildmacros.sce (1 diff)

File differences

etc/aerospace_blockset.start
4141
4242
4343
44
44
4545
4646
4747
mprintf("\tLoad reference frames palette\n");
pal = xcosPal("Reference Frames");
blocks = ["KEP_TO_CAR" "FRAME_CONVERSION" "FRAME_CONV_JACOBIAN" "FRAME_CONV_DCM" "DCM_TO_QUAT" "QUAT_TO_DCM" "QUAT_TO_AXA" "AXA_TO_QUAT" "STATION_POINTING" "TIMEFRAME_CONVERSION" "TIMEZONE_CONVERSION" "CAR_TO_ELL"];
blocks = ["KEP_TO_CAR" "FRAME_CONVERSION" "FRAME_CONV_JACOBIAN" "FRAME_CONV_DCM" "DCM_TO_QUAT" "QUAT_TO_DCM" "QUAT_TO_AXA" "AXA_TO_QUAT" "STATION_POINTING" "TIMEFRAME_CONVERSION" "TIMEZONE_CONVERSION" "CAR_TO_ELL" "ELL_TO_CAR"];
for i=1:size(blocks, "*")
h5 = ls(root_tlbx + "/images/h5/" + blocks(i) + "." + ["sod" "h5"]);
macros/AB_co_ell2car.sci
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2014 - Pawel Zagorski
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
function block=AB_co_ell2car(block,flag)
previousprot = funcprot(0)
block_name = "AB_co_ell2car";
//xcos_block_debug(block, flag, block_name);
if scicos_debug() == 2 then xcos_block_debug(block, flag, block_name); end
select flag
case 1 then
// Output computation
pos_ell = block.inptr(1);
er = block.rpar(1); // Equatorial radius of reference ellipsoid [m]
obla = block.rpar(2); // Oblateness of reference ellipsoid
[pos_car ,jacob] = CL_co_ell2car(pos_ell,er,obla);
// Set block outputs
block.outptr(1) = pos_car;
block.outptr(2) = jacob;
case 4 then
// Initialization
AB_check_param_number(block_name, block, 0, 0, 4);
case 5 then
// Ending
;
case 6 then
// Initialization, fixed-point computation
;
else
error(msprintf(gettext("%s : Incorect flag %d"), block_name, flag));
end
if scicos_debug() == 2 then xcos_block_perf(); end
//xcos_block_perf();
funcprot(previousprot);
endfunction
macros/ELL_TO_CAR.sci
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//
// This file is part of the Xcos Aerospace Blockset
//
// Copyright (C) 2014 - Pawel Zagorski
// see license.txt for more licensing informations
function [x,y,typ]=ELL_TO_CAR(job,arg1,arg2)
x=[];y=[];typ=[];
jacobian = %f; // This is different for other block using AB_fr_convert()
select job
case 'plot' then
standard_draw(arg1);
case 'getinputs' then
[x,y,typ]=standard_inputs(arg1);
case 'getoutputs' then
[x,y,typ]=standard_outputs(arg1);
case 'getorigin' then
[x,y]=standard_origin(arg1);
case 'set' then
x=arg1; //in ’set’ x is the data structure of the block
graphics=arg1.graphics;
exprs=graphics.exprs;
model=arg1.model;
while %t do
labels = ["Equatorial radius of reference ellipsoid [m]"; "Oblateness of reference ellipsoid"];
types = list('col', 1, 'col', 1);
[ok, er, obla, exprs]=getvalue(["Set ELL_TO_CAR block parameters"],labels, types, exprs);
if ~ok then break,end
//check validity of parameters
if obla>=1 then
block_parameter_error(msprintf(gettext("Wrong value for ''%s'' parameter"), gettext("Oblateness of reference ellipsoid")), ..
gettext("Value must be lower than 1"));
ok=%f;
end
if er<=0 then
block_parameter_error(msprintf(gettext("Wrong value for ''%s'' parameter"), gettext("Equatorial radius of reference ellipsoid")), ..
gettext("Value must be greater than 0"));
ok=%f;
end
//...
//[model,graphics,ok]=set_io(model,graphics,in,out,...
//clkin,clkout,in_implicit,out_implicit)
//...
if ok then
//model.ipar= [];
model.rpar= [er, obla];
graphics.exprs=exprs;
x.graphics=graphics;
x.model=model
break
else
message("Failed to update block io");
end
end
case 'define' then
er = 6378136.2999999998137355;
obla = 0.0033528106647474804902 ;
model= scicos_model();
model.sim= list('AB_co_ell2car',5);
// two inputs with a single "double" element
model.in= [3];
model.in2= [1];
model.intyp= [1];
// one output with a single "double" element
model.out= [3;3];
model.out2= [1;3];
// block parameters
model.ipar= [];
model.rpar= [er, obla];
model.opar = list();
model.blocktype='c';
model.dep_ut=[%t %f];
exprs=[
string(er);
string(obla);
];
gr_i=['txt=[''ELL_TO_CAR''];';
'xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'')'];
//gr_i=['txt=[''Frame conversion''];';
// 'xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'')'];
x=standard_define([2 2],model,exprs,gr_i);
graphics=x.graphics;
graphics.style = "fillColor=white";
//graphics.id=frame_IN+"->"+frame_OUT;
//graphics.in_label=["xyz";"V";"cjd"];
//graphics.out_label=["xyz";"V"];
x.graphics=graphics;
end
endfunction
macros/buildmacros.sce
44
55
66
7
7
88
99
1010
macros_path = get_absolute_file_path("buildmacros.sce");
tbx_build_macros(TOOLBOX_NAME, macros_path);
tbx_build_blocks(toolbox_dir, ["US76_ATM_MODEL" "PLOT_GROUNDTRACK" "PLOT_VISIBILITY" "PLOT_POLAR" "PLOT_INDICATORS" "KEPLERIAN_INPUT" "ANGLE_CONVERSION" "DISTANCE_CONVERSION" "VELOCITY_CONVERSION" "SECULAR_J2" "KEP_TO_CAR" "FRAME_CONVERSION" "FRAME_CONV_JACOBIAN" "FRAME_CONV_DCM" "CJD_TIME" "CJD_NOW" "GROUND_STATION" "STATION_VISIBILITY" "STATION_POINTING" "TIMEFRAME_CONVERSION" "TIMEZONE_CONVERSION" "SUN_MODEL" "MOON_MODEL" "KEPLERIAN_PROPAGATOR" "LYDDANE_PROPAGATOR" "VECTOR_NORMALIZATION" "VECTOR_ANGLE" "DOT_PRODUCT" "CROSS_PRODUCT" "QUAT_INPUT" "QUAT_NORM" "VECTOR_NORM" "QUAT_CONJUGATE" "QUAT_INVERT" "QUAT_PRODUCT" "AXA_TO_QUAT" "QUAT_TO_AXA" "QUAT_TO_DCM" "QUAT_QUOTIENT" "VECTOR_ROTATE" "GEOMAG_MODEL" "ROTATION_JACOBIAN" "ECLIPSE_MODEL" "ATM_DRAG_MODEL" "SOL_DRAG_MODEL" "PLANET_MODEL" "DCM_TO_QUAT" "CAR_TO_ELL"]);
tbx_build_blocks(toolbox_dir, ["US76_ATM_MODEL" "PLOT_GROUNDTRACK" "PLOT_VISIBILITY" "PLOT_POLAR" "PLOT_INDICATORS" "KEPLERIAN_INPUT" "ANGLE_CONVERSION" "DISTANCE_CONVERSION" "VELOCITY_CONVERSION" "SECULAR_J2" "KEP_TO_CAR" "FRAME_CONVERSION" "FRAME_CONV_JACOBIAN" "FRAME_CONV_DCM" "CJD_TIME" "CJD_NOW" "GROUND_STATION" "STATION_VISIBILITY" "STATION_POINTING" "TIMEFRAME_CONVERSION" "TIMEZONE_CONVERSION" "SUN_MODEL" "MOON_MODEL" "KEPLERIAN_PROPAGATOR" "LYDDANE_PROPAGATOR" "VECTOR_NORMALIZATION" "VECTOR_ANGLE" "DOT_PRODUCT" "CROSS_PRODUCT" "QUAT_INPUT" "QUAT_NORM" "VECTOR_NORM" "QUAT_CONJUGATE" "QUAT_INVERT" "QUAT_PRODUCT" "AXA_TO_QUAT" "QUAT_TO_AXA" "QUAT_TO_DCM" "QUAT_QUOTIENT" "VECTOR_ROTATE" "GEOMAG_MODEL" "ROTATION_JACOBIAN" "ECLIPSE_MODEL" "ATM_DRAG_MODEL" "SOL_DRAG_MODEL" "PLANET_MODEL" "DCM_TO_QUAT" "CAR_TO_ELL" "ELL_TO_CAR"]);
endfunction

Archive Download the corresponding diff file

Branches