Index: mttroot/mtt/bin/mtt ================================================================== --- mttroot/mtt/bin/mtt +++ mttroot/mtt/bin/mtt @@ -14,10 +14,14 @@ ############################################################### ## Version control history ############################################################### ## $Header$ ## $Log$ +## Revision 1.304 2001/04/11 07:35:22 gawthrop +## Now uses system_cr.h in place of system.h in .c rep - +## compatible with older code +## ## Revision 1.303 2001/04/10 12:54:50 gawthrop ## Minor fixes for sensitivity versions ## ## Revision 1.302 2001/04/06 05:24:30 geraint ## -stdin for .cc reps. @@ -1099,14 +1103,16 @@ -p ) mtt_switches="$mtt_switches $1"; print='-p';; -c ) + fixcc='-fixcc' mtt_switches="$mtt_switches $1"; matrix_smxa="-matrix"; computation=c ;; -cc ) + fixcc='-fixcc' mtt_switches="$mtt_switches $1"; matrix_smxa="-matrix"; computation=cc ;; -o ) mtt_switches="$mtt_switches $1"; @@ -1182,10 +1188,11 @@ -sub ) mtt_switches="$mtt_switches $1 $2"; sub='-sub'; subsystem="_"$2; shift;; -oct ) + fixcc='-fixcc' mtt_switches="$mtt_switches $1"; using_oct=yes; m=oct ;; -opt ) mtt_switches="$mtt_switches $1"; @@ -1913,11 +1920,11 @@ echo Compiling mtt_\$*.cc ${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $< -DSTANDALONE $define_octave_dev # Generates code to write reduce code $1_ode_write.r: $1_def.m - def2write_r $1 $2 + def2write_r $1 $2 $computation ifeq ("$sensitivity","sensitivity") ifeq ("$level","0") $1_abg.fig: $sys_abg.fig abg2sensitivity_fig $sys_s @@ -2343,11 +2350,11 @@ endif ifeq ($rdae_is_dae,1) echo Copying $1_rdae.r to $1_dae.r cp $1_rdae.r $1_dae.r else - rdae2dae_r ${Subsystem}; tidy ${Subsystem}_dae.r + rdae2dae_r ${fixcc} ${Subsystem}; tidy ${Subsystem}_dae.r endif $1_dae.m: $1_def.r $1_dae.r $1_sympars.txt dae_r2m $1; matlab_tidy $1_dae.m; matlab_tidy $1_daeo.m $1_dae.c: $1_def.r $1_dae.r $1_sympar.r @@ -2704,17 +2711,17 @@ #SUMMARY smxtx Sparse computation of ATx (m) $1_smx.r: $1_def.r $1_def.m $1_ode.r $1_subs.r ode2smx_lang $1 r; tidy $1_smx.r $1_smx.m: $1_def.r $1_def.m $1_cse.r $1_sympars.txt $1_subs.r - cse2smx_lang $optimise -parameters $1 smx m + cse2smx_lang $fixcc $optimise -parameters $1 smx m $1_smxa.m: $1_def.r $1_def.m $1_cse.r $1_sympars.txt $1_subs.r - cse2smx_lang $optimise -parameters $matrix_smxa $1 smxa m + cse2smx_lang $fixcc $optimise -parameters $matrix_smxa $1 smxa m $1_smxax.m: $1_def.r $1_def.m $1_cse.r $1_sympars.txt $1_subs.r - cse2smx_lang $optimise -parameters $1 smxax m + cse2smx_lang $fixcc $optimise -parameters $1 smxax m #SUMMARY smc controller form state matrices etc. - siso only (r) #SUMMARY smc controller form state matrices etc. - siso only (tex) #SUMMARY smc* controller form state matrices etc. - siso only (m) #SUMMARY smc* controller form state matrices etc. - siso only (view) Index: mttroot/mtt/bin/trans/cse2smx_lang ================================================================== --- mttroot/mtt/bin/trans/cse2smx_lang +++ mttroot/mtt/bin/trans/cse2smx_lang @@ -27,10 +27,14 @@ ;; -optimise) optimise='LOAD SCOPE; ON GENTRANOPT;'; iname='INAME mtt_o;'; ;; + -fixcc ) + include=`echo 'in "'$MTT_LIB'/reduce/fix_c.r";'` + blurb2='fixing c and cc code'; + ;; *) echo $1 is an unknown option exit;; esac shift @@ -80,11 +84,11 @@ # Inform user if [ -n "$optimise" ]; then blurbopt=' using code optimisation' fi -echo Creating $1_$rep.$lang $blurb $blurbopt +echo Creating $1_$rep.$lang $blurb $blurbopt $blurb2 #echo Creating $1_smxx.$lang #echo Creating $1_smxtx.$lang # Remove the old log file rm -f cse2smx_r.log @@ -95,10 +99,13 @@ # Use reduce to accomplish the transformation $SYMBOLIC << EOF >cse2smx_lang.log lang := $lang; + +%% Fixes for c and cc (if needed) +$include; in "$1_subs.r"; in "$1_def.r"; in "$1_cse.r"; in "$1_cr.r"; Index: mttroot/mtt/bin/trans/def2write_r ================================================================== --- mttroot/mtt/bin/trans/def2write_r +++ mttroot/mtt/bin/trans/def2write_r @@ -11,10 +11,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.6 2000/11/29 20:48:53 peterg +## Zapped unnecessary Npar creation +## ## Revision 1.5 2000/11/09 10:12:24 peterg ## Removed debugging line ## ## Revision 1.4 2000/10/14 16:19:54 peterg ## Just optimize one line at a time ... @@ -27,11 +30,10 @@ ## ## Revision 1.1 2000/10/10 09:07:32 peterg ## Initial revision ## ############################################################### - sys=$1 # System name rep=$2 # System representation # Inform User @@ -92,10 +94,11 @@ exit esac # Write out the code echo 'off echo$ load scope$' >$1_$2_write.r + for matrix in $matrices; do n=`first "$ns"`; ns=`rest "$ns"` m=`first "$ms"`; ms=`rest "$ms"` is=`n2m 1 $n`; js=`n2m 1 $m`; Index: mttroot/mtt/bin/trans/rdae2dae_r ================================================================== --- mttroot/mtt/bin/trans/rdae2dae_r +++ mttroot/mtt/bin/trans/rdae2dae_r @@ -12,10 +12,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.6 2001/02/03 13:40:45 gawthrop +## Added explicit MTTNu +## ## Revision 1.5 2000/12/28 12:39:02 peterg ## Put under RCS ## ## Revision 1.4 2000/09/04 08:42:53 peterg ## Put in extra echo to space output @@ -86,10 +89,14 @@ info=info;; -partition ) partition=yes; blurb='with partitioning'; ;; + -fixcc ) + include=`echo 'in "'$MTT_LIB'/reduce/fix_c.r";'` + blurb2='fixing c and cc code'; + ;; *) echo "$1 is an invalid argument - ignoring"; exit ;; esac shift @@ -112,17 +119,20 @@ rdaename=$sysname"_rdae.r" daename=$sysname"_dae.r" logname="rdae2dae.log" # Inform user -echo Creating $daename +echo Creating $daename $blurb $blurb2 # Remove the old log file rm -f $logname # Use symbolic algebra to accomplish the transformation $SYMBOLIC >$logname << EOF + +% Fix c code if required +$include %Read the formatting function in "$MTTPATH/trans/reduce_matrix.r"; % CRs Index: mttroot/mtt/cc/include/useful-functions.hh ================================================================== --- mttroot/mtt/cc/include/useful-functions.hh +++ mttroot/mtt/cc/include/useful-functions.hh @@ -1,5 +1,7 @@ +#define pi 3.14159 // Predefine pi + #ifndef HAVE_USEFUL_FUNCTIONS_HH #define HAVE_USEFUL_FUNCTIONS_HH #ifdef __CPLUSPLUS Index: mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/gRODa/gRODa_abg.fig ================================================================== --- mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/gRODa/gRODa_abg.fig +++ mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/gRODa/gRODa_abg.fig @@ -87,47 +87,47 @@ 8550 5400 9225 6075 8955 6075 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 8685 5265 8415 5535 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 3 3375 5175 2025 3825 2250 3825 -4 1 -1 0 0 0 20 0.0000 4 195 150 5628 5268 1\001 -4 1 -1 0 0 0 20 0.0000 4 195 315 6933 5268 I:J\001 -4 1 -1 0 0 0 20 0.0000 4 195 150 2927 5312 1\001 -4 1 -1 0 0 0 20 0.0000 4 195 150 2972 2792 0\001 -4 1 -1 0 0 0 20 0.0000 4 195 150 2927 7742 0\001 -4 1 -1 0 0 0 20 0.0000 4 195 150 8328 5313 1\001 -4 1 -1 0 0 0 20 0.0000 4 195 150 8373 2793 0\001 -4 1 -1 0 0 0 20 0.0000 4 195 150 8328 7743 0\001 -4 1 -1 0 0 0 20 0.0000 4 270 735 9676 5266 I:m_y\001 -4 1 -1 0 0 0 20 0.0000 4 240 735 1531 5221 I:m_x\001 -4 1 -1 0 0 0 20 0.0000 4 195 1170 4636 4141 EMTF:c1\001 -4 1 -1 0 0 0 20 0.0000 4 195 1170 4681 6391 EMTF:c2\001 -4 1 -1 0 0 0 20 0.0000 4 195 1155 7156 4141 EMTF:s1\001 -4 1 -1 0 0 0 20 0.0000 4 195 1155 7156 6391 EMTF:s2\001 -4 1 5 0 0 0 20 0.0000 4 195 150 3603 5313 0\001 -4 1 26 0 0 0 16 0.0000 4 210 330 6751 4456 [in]\001 -4 1 26 0 0 0 16 0.0000 4 210 450 6751 3781 [out]\001 -4 1 26 0 0 0 16 0.0000 4 210 330 6751 6076 [in]\001 -4 1 26 0 0 0 16 0.0000 4 210 450 6751 6706 [out]\001 -4 1 26 0 0 0 16 0.0000 4 210 570 6211 6526 [mod]\001 -4 1 5 0 0 0 20 0.0000 4 210 990 4681 5266 INTF:th\001 +4 1 -1 0 0 0 20 0.0000 4 195 135 5628 5268 1\001 +4 1 -1 0 0 0 20 0.0000 4 195 270 6933 5268 I:J\001 +4 1 -1 0 0 0 20 0.0000 4 195 135 2927 5312 1\001 +4 1 -1 0 0 0 20 0.0000 4 195 135 2972 2792 0\001 +4 1 -1 0 0 0 20 0.0000 4 195 135 2927 7742 0\001 +4 1 -1 0 0 0 20 0.0000 4 195 135 8328 5313 1\001 +4 1 -1 0 0 0 20 0.0000 4 195 135 8373 2793 0\001 +4 1 -1 0 0 0 20 0.0000 4 195 135 8328 7743 0\001 +4 1 -1 0 0 0 20 0.0000 4 255 660 9676 5266 I:m_y\001 +4 1 -1 0 0 0 20 0.0000 4 255 660 1531 5221 I:m_x\001 +4 1 -1 0 0 0 20 0.0000 4 195 1110 4636 4141 EMTF:c1\001 +4 1 -1 0 0 0 20 0.0000 4 195 1110 4681 6391 EMTF:c2\001 +4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 4141 EMTF:s1\001 +4 1 -1 0 0 0 20 0.0000 4 195 1095 7156 6391 EMTF:s2\001 +4 1 5 0 0 0 20 0.0000 4 195 135 3603 5313 0\001 +4 1 26 0 0 0 16 0.0000 4 210 345 6751 4456 [in]\001 +4 1 26 0 0 0 16 0.0000 4 210 465 6751 3781 [out]\001 +4 1 26 0 0 0 16 0.0000 4 210 345 6751 6076 [in]\001 +4 1 26 0 0 0 16 0.0000 4 210 465 6751 6706 [out]\001 +4 1 26 0 0 0 16 0.0000 4 210 585 6211 6526 [mod]\001 +4 1 5 0 0 0 20 0.0000 4 195 960 4681 5266 INTF:th\001 4 1 1 1 0 0 20 0.0000 4 195 210 2925 10035 X\001 -4 1 1 1 0 32 20 0.0000 4 150 195 5580 9990 a\001 +4 1 1 1 0 32 20 0.0000 4 135 180 5580 9990 a\001 4 1 1 1 0 0 20 0.0000 4 195 210 8280 9990 Y\001 -4 2 26 0 0 0 16 0.0000 4 210 570 3960 4140 [mod]\001 -4 2 26 0 0 0 16 0.0000 4 210 570 6345 4095 [mod]\001 -4 2 26 0 0 0 16 0.0000 4 210 570 3960 6210 [mod]\001 -4 1 26 0 0 0 16 0.0000 4 210 330 4590 4455 [in]\001 -4 1 26 0 0 0 16 0.0000 4 210 450 4545 3780 [out]\001 -4 1 26 0 0 0 16 0.0000 4 210 450 4590 6660 [out]\001 -4 0 26 0 0 0 16 0.0000 4 210 330 4365 6030 [in]\001 -4 1 4 0 0 0 20 0.0000 4 270 1485 2971 1216 SS:[xTip_a]\001 -4 1 4 0 0 0 20 0.0000 4 270 1500 2971 9361 SS:[xTip_b]\001 -4 1 4 0 0 0 20 0.0000 4 285 1485 8372 1217 SS:[yTip_a]\001 -4 1 4 0 0 0 20 0.0000 4 285 1500 8417 9362 SS:[yTip_b]\001 -4 1 4 0 0 0 20 0.0000 4 270 2250 5671 1216 SS:[angularTip_a]\001 -4 1 4 0 0 0 20 0.0000 4 270 2265 5671 9361 SS:[angularTip_b]\001 -4 1 1 1 0 0 20 0.0000 4 255 630 1350 2700 Tip a\001 -4 1 1 1 0 0 20 0.0000 4 195 1470 1260 6300 Mass centre\001 -4 1 1 1 0 0 20 0.0000 4 270 645 1350 9855 Tip b\001 -4 1 -1 0 0 0 20 0.0000 4 270 810 9360 6345 SS:mg\001 -4 2 4 0 0 0 20 0.0000 4 270 1290 1935 3735 SS:[angle]\001 +4 2 26 0 0 0 16 0.0000 4 210 585 3960 4140 [mod]\001 +4 2 26 0 0 0 16 0.0000 4 210 585 6345 4095 [mod]\001 +4 2 26 0 0 0 16 0.0000 4 210 585 3960 6210 [mod]\001 +4 1 26 0 0 0 16 0.0000 4 210 345 4590 4455 [in]\001 +4 1 26 0 0 0 16 0.0000 4 210 465 4545 3780 [out]\001 +4 1 26 0 0 0 16 0.0000 4 210 465 4590 6660 [out]\001 +4 0 26 0 0 0 16 0.0000 4 210 345 4365 6030 [in]\001 +4 1 4 0 0 0 20 0.0000 4 255 1380 2971 1216 SS:[xTip_a]\001 +4 1 4 0 0 0 20 0.0000 4 255 1380 2971 9361 SS:[xTip_b]\001 +4 1 4 0 0 0 20 0.0000 4 255 1380 8372 1217 SS:[yTip_a]\001 +4 1 4 0 0 0 20 0.0000 4 255 1380 8417 9362 SS:[yTip_b]\001 +4 1 4 0 0 0 20 0.0000 4 255 2130 5671 1216 SS:[angularTip_a]\001 +4 1 4 0 0 0 20 0.0000 4 255 2130 5671 9361 SS:[angularTip_b]\001 +4 1 1 1 0 0 20 0.0000 4 255 600 1350 2700 Tip a\001 +4 1 1 1 0 0 20 0.0000 4 195 1380 1260 6300 Mass centre\001 +4 1 1 1 0 0 20 0.0000 4 255 600 1350 9855 Tip b\001 +4 1 -1 0 0 0 20 0.0000 4 255 720 9360 6345 Se:mg\001 +4 2 4 0 0 0 20 0.0000 4 255 1200 1935 3735 SS:[angle]\001 Index: mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/gRODa/gRODa_lbl.txt ================================================================== --- mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/gRODa/gRODa_lbl.txt +++ mttroot/mtt/lib/comp/compound/Mechanical/Mechanical-2D/gRODa/gRODa_lbl.txt @@ -31,10 +31,13 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ +% %% Revision 1.1 1999/08/05 08:04:40 peterg +% %% Initial revision +% %% % %% Revision 1.3 1998/11/30 10:47:53 peterg % %% Added extra a_a and a_b aliases % %% % %% Revision 1.2 1998/11/25 13:55:42 peterg % %% Added missig attribute field m*g,internal @@ -76,12 +79,15 @@ s1 lsin flow,l_a s2 lsin flow,l_b c1 lcos flow,l_a c2 lcos flow,l_b -% Component type SS - mg SS m*g,internal + +% Component type Se + mg SS m*g + + [angularTip_a] SS external,external [angularTip_b] SS external,external [xTip_a] SS external,external [xTip_b] SS external,external [yTip_a] SS external,external Index: mttroot/mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_subs.r ================================================================== --- mttroot/mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_subs.r +++ mttroot/mtt/lib/examples/Identification/idNonlinearTanks/idNonlinearTanks_subs.r @@ -6,14 +6,18 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ +% %% Revision 1.1 2001/04/05 12:00:18 gawthrop +% %% Identification example +% %% % %% Revision 1.1 2000/12/28 09:13:38 peterg % %% Initial revision % %% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Put algebraic substitution commands here -FOR ALL x,y LET x^y = pow(x,y); +%The following is now done automatically +% FOR ALL x,y LET x^y = pow(x,y); END; Index: mttroot/mtt/lib/examples/Identification/idRC/sidRC_subs.r ================================================================== --- mttroot/mtt/lib/examples/Identification/idRC/sidRC_subs.r +++ mttroot/mtt/lib/examples/Identification/idRC/sidRC_subs.r @@ -6,17 +6,22 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ +% %% Revision 1.1 2001/04/05 11:57:29 gawthrop +% %% Identification example +% %% % %% Revision 1.1 2000/12/28 09:13:38 peterg % %% Initial revision % %% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Put algebraic substitution commands here -FOR ALL x,y LET x^y = pow(x,y); % Use the pow function + +%The following is now done automatically +%FOR ALL x,y LET x^y = pow(x,y); % Use the pow function -ON ROUNDED; % No integer output +%ON ROUNDED; % No integer output END; Index: mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/Cart_abg.fig ================================================================== --- mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/Cart_abg.fig +++ mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/Cart_abg.fig @@ -5,19 +5,10 @@ A4 100.00 Single -2 1200 2 -6 90 3915 6615 4320 -2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3 - 2475 4050 3825 4050 3600 4275 -2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3 - 4275 4050 5625 4050 5400 4275 -4 1 0 100 0 18 20 0.0000 4 210 165 4050 4140 1\001 -4 1 4 100 0 18 20 0.0000 4 285 870 6165 4140 SS:[y]\001 -4 2 0 100 0 18 20 0.0000 4 285 2310 2430 4140 Sf:zero_velocity\001 --6 2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3 4050 2925 4050 1575 4275 1800 2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3 4275 3150 5625 3150 5400 3375 2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3 @@ -32,18 +23,27 @@ 3825 2925 2870 1970 2870 2289 2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3 4288 2957 5243 2002 5243 2320 2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3 6525 3150 7875 3150 7650 3375 -4 1 1 101 0 3 20 0.0000 4 270 1290 4140 3600 x-velocity\001 -4 1 0 100 0 18 20 0.0000 4 210 165 4050 3240 1\001 -4 1 4 100 0 18 20 0.0000 4 285 1425 1710 3240 SS:[drive]\001 -4 1 1 101 0 3 20 0.0000 4 270 1275 4185 4500 y-velocity\001 -4 1 1 101 0 3 20 0.0000 4 270 2130 4050 5490 angular-velocity\001 -4 1 0 100 0 18 20 0.0000 4 210 165 4050 5040 1\001 -4 1 4 100 0 18 20 0.0000 4 285 870 6165 5040 SS:[a]\001 -4 2 0 100 0 18 20 0.0000 4 300 780 2430 5040 R:r_p\001 -4 1 0 100 0 18 20 0.0000 4 285 765 2835 1845 R:r_c\001 -4 1 4 100 0 18 20 0.0000 4 285 870 4050 1440 SS:[x]\001 -4 1 0 100 0 18 20 0.0000 4 285 795 5355 1845 I:m_c\001 -4 1 0 100 0 18 20 0.0000 4 225 660 6075 3240 INTF\001 -4 0 0 100 0 18 20 0.0000 4 225 1665 8010 3240 De:Position\001 +2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5 + 9900 5850 225 5850 225 900 9900 900 9900 5850 +2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3 + 2475 4050 3825 4050 3600 4275 +2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3 + 4275 4050 5625 4050 5400 4275 +4 1 1 101 0 3 20 0.0000 4 270 1155 4140 3600 x-velocity\001 +4 1 0 100 0 18 20 0.0000 4 195 150 4050 3240 1\001 +4 1 4 100 0 18 20 0.0000 4 270 1320 1710 3240 SS:[drive]\001 +4 1 1 101 0 3 20 0.0000 4 270 1125 4185 4500 y-velocity\001 +4 1 1 101 0 3 20 0.0000 4 270 1905 4050 5490 angular-velocity\001 +4 1 0 100 0 18 20 0.0000 4 195 150 4050 5040 1\001 +4 1 4 100 0 18 20 0.0000 4 270 825 6165 5040 SS:[a]\001 +4 2 0 100 0 18 20 0.0000 4 270 735 2430 5040 R:r_p\001 +4 1 0 100 0 18 20 0.0000 4 270 720 2835 1845 R:r_c\001 +4 1 4 100 0 18 20 0.0000 4 270 825 4050 1440 SS:[x]\001 +4 1 0 100 0 18 20 0.0000 4 270 735 5355 1845 I:m_c\001 +4 1 0 100 0 18 20 0.0000 4 210 630 6075 3240 INTF\001 +4 0 0 100 0 18 20 0.0000 4 210 1590 8010 3240 De:Position\001 +4 1 0 100 0 18 20 0.0000 4 195 150 4050 4140 1\001 +4 1 4 100 0 18 20 0.0000 4 270 825 6165 4140 SS:[y]\001 +4 2 0 100 0 18 20 0.0000 4 270 2190 2430 4140 Sf:zero_velocity\001 Index: mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/Cart_lbl.txt ================================================================== --- mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/Cart_lbl.txt +++ mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/Cart_lbl.txt @@ -1,21 +1,28 @@ %% Label file for system Cart (Cart_lbl.txt) %SUMMARY Cart -%DESCRIPTION +%DESCRIPTION Simple cart model % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ +% %% Revision 1.1 2000/12/28 18:00:45 peterg +% %% To RCS +% %% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Port aliases -%ALIAS %ALIAS in drive %ALIAS pendulum|out x,y,a +%UNITS drive translational N m/s +b%UNITS x translational N m/s +%UNITS y translational N m/s +%UNITS a rotational N*m radian/s + % Argument aliases %ALIAS $1 m_c %% Each line should be of one of the following forms: @@ -36,13 +43,13 @@ [a] SS external,external [drive] SS external,external [x] SS external,external [y] SS external,external -% Component type Df - v_c SS external +% Component type De + Position SS external % Component type Sf zero_velocity SS 0 Index: mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_abg.fig ================================================================== --- mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_abg.fig +++ mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_abg.fig @@ -9,16 +9,20 @@ 1200 2 6 3780 4005 3870 4545 2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 2 3825 4050 3825 4500 -6 +1 4 0 2 1 7 51 0 -1 0.000 1 0.0000 3700 4909 203 203 3497 4909 3903 4909 +1 4 0 2 1 7 51 0 -1 0.000 1 0.0000 4817 4902 203 203 4614 4902 5020 4902 2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3 2475 4275 3825 4275 3600 4500 2 4 0 2 1 7 101 0 -1 0.000 0 0 7 0 0 5 5175 4725 3375 4725 3375 3825 5175 3825 5175 4725 2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3 4275 4050 5230 3095 5230 3414 2 1 0 2 1 7 101 0 -1 0.000 0 0 -1 0 0 5 4477 3712 5872 2317 6052 2497 4702 3847 4522 3667 -4 1 0 100 0 18 20 0.0000 4 225 600 4275 4365 Cart\001 -4 1 0 100 0 18 20 0.0000 4 225 645 2070 4365 Se:F\001 -4 1 0 100 0 18 20 0.0000 4 225 1440 5355 3060 InvertedPendulum\001 +2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5 + 6750 5400 1125 5400 1125 2025 6750 2025 6750 5400 +4 1 0 100 0 18 20 0.0000 4 210 570 4275 4365 Cart\001 +4 1 0 100 0 18 20 0.0000 4 270 840 2070 4365 SS:[F]\001 +4 1 0 100 0 18 20 0.0000 4 210 2445 5355 3060 InvertedPendulum\001 Index: mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_input.txt ================================================================== --- mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_input.txt +++ mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_input.txt @@ -1,14 +1,10 @@ -# -*-octave-*- Put Emacs into octave-mode -# Input specification (InvertedPendulumOnCart_input.txt) -# Generated by MTT at Thu Aug 5 09:17:30 BST 1999 -############################################################### -## Version control history -############################################################### -## $Id$ -## $Log$ -############################################################### - -# Set the inputs -## Removed by MTT on Fri Nov 10 14:31:10 GMT 2000: mttu(1) = 1.0*t<1 -1.0*((t>=1)&&(t<2)); # u (InvertedPendulumOnCart_F) - -invertedpendulumoncart_f_1_u = 1.0*t<1 -1.0*((t>=1)&&(t<2)); +## -*-octave-*- Put Emacs into octave-mode ## + +## +## System InvertedPendulumOnCart, representation input, language txt; +## File idInvertedPendulumOnCart_input.txt; +## Generated by MTT on Thu Apr 5 15:27:30 BST 2001; + + + +InvertedPendulumOnCart_f = 1.0*(t<1); # Force for 1 sec Index: mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_lbl.txt ================================================================== --- mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_lbl.txt +++ mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_lbl.txt @@ -1,18 +1,23 @@ %% Label file for system InvertedPendulumOnCart (InvertedPendulumOnCart_lbl.txt) %SUMMARY InvertedPendulumOnCart -%DESCRIPTION +%DESCRIPTION An Inverted Pendulum on a Cart % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ +% %% Revision 1.1 2000/12/28 18:00:45 peterg +% %% To RCS +% %% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Port aliases +%ALIAS in F +%UNITS F translational N m/s % Argument aliases %% Each line should be of one of the following forms: % a comment (ie starting with %) @@ -19,11 +24,11 @@ % component-name cr_name arg1,arg2,..argn % blank % ---- Component labels ---- -% Component type Se - F SS external +% Component type SS + [F] SS external,internal Index: mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_subs.r ================================================================== --- mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_subs.r +++ mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulumOnCart_subs.r @@ -6,15 +6,22 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ +% %% Revision 1.2 2001/04/02 10:57:57 gawthrop +% %% Added missing ; +% %% % %% Revision 1.1 2000/12/28 18:00:45 peterg % %% To RCS % %% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Put algebraic substitution commands here for all x let cos(x)^2+sin(x)^2 = 1; + +FOR ALL x,y LET x^y = pow(x,y); % Use the pow function + +ON ROUNDED; % No integer output END; Index: mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulum_abg.fig ================================================================== --- mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulum_abg.fig +++ mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulum_abg.fig @@ -33,14 +33,16 @@ 4 1 4 100 0 18 14 0.0000 4 210 510 4950 4725 [y_a]\001 4 1 4 100 0 18 14 0.0000 4 210 510 6075 4725 [a_a]\001 -6 2 1 0 2 0 7 100 0 -1 0.000 0 0 -1 0 0 3 6840 4950 8190 4950 7965 5175 -4 1 4 100 0 18 20 0.0000 4 285 870 3825 7065 SS:[x]\001 -4 1 4 100 0 18 20 0.0000 4 285 870 4950 7065 SS:[y]\001 -4 1 4 100 0 18 20 0.0000 4 285 870 6075 7065 SS:[a]\001 -4 1 0 100 0 18 20 0.0000 4 285 1590 4964 5040 gRODa:rod\001 -4 1 0 100 0 18 20 0.0000 4 285 960 3825 3015 Se:x_0\001 -4 1 0 100 0 18 20 0.0000 4 285 960 4950 3015 Se:y_0\001 -4 1 0 100 0 18 20 0.0000 4 285 960 6030 3015 Se:a_0\001 +2 4 0 2 31 7 101 0 -1 0.000 0 0 7 0 0 5 + 9675 7425 3150 7425 3150 2475 9675 2475 9675 7425 +4 1 4 100 0 18 20 0.0000 4 270 825 3825 7065 SS:[x]\001 +4 1 4 100 0 18 20 0.0000 4 270 825 4950 7065 SS:[y]\001 +4 1 4 100 0 18 20 0.0000 4 270 825 6075 7065 SS:[a]\001 +4 1 0 100 0 18 20 0.0000 4 270 1545 4964 5040 gRODa:rod\001 +4 1 0 100 0 18 20 0.0000 4 270 915 3825 3015 Se:x_0\001 +4 1 0 100 0 18 20 0.0000 4 270 915 4950 3015 Se:y_0\001 +4 1 0 100 0 18 20 0.0000 4 270 915 6030 3015 Se:a_0\001 4 1 4 100 0 18 14 0.0000 4 210 270 6660 4995 [a]\001 -4 1 0 100 0 18 20 0.0000 4 225 1200 8865 5040 De:theta\001 +4 1 0 100 0 18 20 0.0000 4 210 1140 8865 5040 De:theta\001 Index: mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulum_lbl.txt ================================================================== --- mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulum_lbl.txt +++ mttroot/mtt/lib/examples/Mechanical/Mechanical-2D/InvertedPendulumOnCart/InvertedPendulum_lbl.txt @@ -5,15 +5,23 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ +% %% Revision 1.1 2000/12/28 18:00:45 peterg +% %% To RCS +% %% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Port aliases -%ALIAS in x,y,a +%UNITS x translational N m/s +%UNITS y translational N m/s +%UNITS a rotational N*m radian/s + + +%ALIAS in|cart x,y,a % Argument aliases %% Each line should be of one of the following forms: ADDED mttroot/mtt/lib/reduce/fix_c.r Index: mttroot/mtt/lib/reduce/fix_c.r ================================================================== --- /dev/null +++ mttroot/mtt/lib/reduce/fix_c.r @@ -0,0 +1,18 @@ +%% Fixes for c-code generation + +ON ROUNDED$ % No integer output + +%% Changes x^y to pow(x,y) + OPERATOR pow$ + FOR ALL x,y LET x^y = pow(x,y)$ % Use the pow function + + %% Derivatives + FOR ALL f,g,x LET df(pow(f,g),x)= + pow(f,g-1) * (df(f,x)*g + df(g,x)*f*log(f))$ + + %% Special cases + FOR ALL x LET pow(x,0) = 1$ + FOR ALL x LET pow(x,1) = x$ + + +END$