[Rtai] Question for RTAI-Lab custom block
Roberto Bucher
roberto.bucher at supsi.ch
Tue May 12 18:38:01 CEST 2009
scicos_block4.h allows to have different types in input and output blocks. Thus
you can't directly use commands like
block->outptr[0][0]=block->inptr[0][0];
but you must proceed as following:
double *u = block->inptr[0];
double *y = block->outptr[0];
y[0] = u[0];
Attached you find an example with a non linear differential equation (inverted
pendulum).
Best regards
Roberto Bucher
On Tuesday 12 May 2009 12:44:10 Atsushi Satoh wrote:
> Hello,
>
> I'm trying to make a custom block using "C RTAI block". However, I'm
> confused by the error "Sorry compilation problem".
>
> I've been using RTAI for my projects, but newbie for a custom block. My
> first block is a unitary gain block because I think it is the easiest
> start.
>
> I set block parameters as follows. The only change is the last one,
> "time dependence". The output of the gain block should be
> time-dependent signal, so I changed it to "y".
>
> ------------------------------------------------
> simulation function:toto
> in block implicit?:n
> input ports size:1
> output ports size:1
> input event ports sizes:[]
> output event ports sizes:[]
> initial continuous state:[]
> number of zero crossing surfaces:0
> initial discrete state:[]
> Real parameters vector:[]
> Integer parrameters vector (<0 for no firing):[]
> direct feedthrough(y or n):y
> time dependence(y or n):y
> ------------------------------------------------
>
> My code is as follows. Actually I added just one line (line 13) to
> skeleton code. After closing the editor window of C block by clicking
> "OK", scicos returns the message "Sorry compilation problem".
>
> ------------------------------------------------
> #include <math.h>
> #include <stdlib.h>
> #ifndef MODEL
> #include <scicos/scicos_block4.h>
> #endif
>
> void toto(scicos_block *block,int flag)
> {
> if (flag == 4) { /* initialization */
> toto_bloc_init(block,flag);
>
> } else if(flag == 1) { /* output computation*/
> block->outptr[0][0]=block->inptr[0][0];
> set_block_error(toto_bloc_outputs(block,flag));
> } else if (flag == 5) { /* ending */
> set_block_error(toto_bloc_ending(block,flag));
> }
> }
>
> int toto_bloc_init(scicos_block *block,int flag)
> {
> return 0;}
> int toto_bloc_outputs(scicos_block *block,int flag)
> {
> return 0;}
> int toto_bloc_ending(scicos_block *block,int flag)
> {
> return 0;}
> ------------------------------------------------
>
>
> Maybe this is a stupid question, but I couldn't found any proved example.
>
> My system is;
> openSUSE10.3
> kernel:2.6.22.19
> CPU:Intel Celeron
> RTAI version:3.6.2
> Scilab version:4.1.2
> gcc version:4.3.1 20080507 (prerelease)
> libc version:2.8
>
> I appreciate any help or suggestion.
>
>
> Thank you in advance.
>
> Atsushi SATOH
>
> Department of Mechanical system,
> Faculty of Engineering,
> Iwate University
>
> _______________________________________________
> Rtai mailing list
> Rtai at rtai.org
> https://mail.rtai.org/cgi-bin/mailman/listinfo/rtai
--
University of Applied Sciences of Southern Switzerland
Dept. Innovative Technologies
CH-6928 Lugano-Manno
http://web.dti.supsi.ch/~bucher
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pend_sim.cos
Type: application/octet-stream
Size: 80520 bytes
Desc: not available
URL: <http://mail.rtai.org/pipermail/rtai/attachments/20090512/c93bf240/attachment-0001.obj>
More information about the Rtai
mailing list