1、The CISST Software Package,Peter Kazanzides Johns Hopkins University www.cisst.org November 16, 2005,Outline,Background and Motivation Where are we going? CISST Libraries Foundation libraries Real time support Development process and tools Tour of web site,Historical Background,ERC-developed softwar
2、e was captured in: CIS library Common tools, such as logging Vectors, matrices, transformations Interface to tracking systems Numerical methods, registration, MRC library Common interface to different robots Essentially a “wrapper” around API for hardware that provides low-level control,Robot Contro
3、ller Architecture,Supervisory/Trajectory Control (100 Hz),Application (non-real-time),Hardware,Interpolate Setpoint,Compute Control,Read Sensors,Servo Control (1000 Hz),Application,API,Motivation for CISST Package,Improve process, design, testing, portability, maintainability for open source release
4、 and to facilitate clinical use: Programming standards Design reviews Portable build tools Automated testing User documentationEnable the development of real-time software for physical devices such as robots and trackers,Motivation for Real Time Support,Motivated by transition from motion controller
5、 boards (with processor and vendors software) to I/O boards (no processor) and research software,Motion Controller Boards (intelligent hardware),I/O Boards (non-intelligent),Example: Teleoperation of Snake Robot,LoPoMoCo,Control PC (RTAI/Linux),I/O and Amps,I/O and Amps,LoPoMoCo,Control PC (RTAI/Lin
6、ux),Master Robots,Slave Robots,Example: Image-Guided Robot for Rodent Research,PC (Windows),Robot,3D Slicer,Where are we going?,C+ Software Libraries cisst libraries other libraries,Frameworks Based on system complexity Component of larger system,Binary components hardware interfaces research algori
7、thms,static linking,frozen spots,hot spots,Distributed Interface,dynamic loading,CISST Libraries,(Mostly) Stable Open source* Sept 2005 cisstInteractive Nov 2005 Beta version Open source Jan 2006 Work in process cisstTracker Jan 2006 cisstMRC June 2006,*www.cisst.org, current license based on Slicer
8、 2.x, goal is Slicer 3.0,cisstVector,Vectors, Matrices and Transformations Extensive use of C+ templates (metaprogramming) Fixed size and dynamic Fixed size especially suited for real-time code Operations on slices and sub-regions References to vectors and matrices Improves interoperability with oth
9、er libraries Matrices in row-major or column-major format C+ wrapping of NetLib (numerical methods, including CLAPACK, MINPACK),Fixed Size Vectors and Matrices,Templated by: Element type (int, double, etc.) Dimension (number of rows, columns, etc.) Efficiency considerations (for templated dimension)
10、: Loop is easy, but not efficient for small vectors: int Sum() sum = 0for (i=0; i _size; i+)sum += datai;return sum; Recursive function also not efficient: int RecursiveSum(int size)return (size = 1) ? data0: RecursiveSum(size-1) + datasize-1; int Sum() return RecursiveSum(_size); Recursive template
11、 (template metaprogramming) is efficient: Compiler “unwraps” recursive template into straight-line code,Fixed Size Vectors and Matrices,Operations provided by “recursive engines”: Classify operations by: Number of operands Type of operands Type of result Storage location for result Small number of e
12、ngines handle all operations Example: same engine for addition, subtraction, ,cisstNumerical,C+ Interface to NetLib code (Fortran) Versions for fixed size and dynamic operands Can pre-allocate solution object More efficient if multiple calls made vctDynamicMatrix A(rows,cols,VCT_COL_MAJOR); nmrSVDSo
13、lutionDynamic solution; solution.Allocate(A); while (1) vctRandom(A,0.0,10.0);nmrSVD(A, solution); / A = U*S*Vcout solution.GetU() ,cisst vs. VNL,cisstVector/cisstNumerical benefits: More efficient fixed size vectors (few loops) Stride allows operations on slices (e.g., can access matrix columns as
14、vectors) Matrices can be in column-major format (more efficient with NetLib) VNL benefits: Mature package, larger development community More features (polynomials, Matlab file I/O, ) Support for more compilers,Python Interface,Automatic wrapping of C+ for Python (Swig) Object registry to share objec
15、ts between languages Can load cisst libraries into Python shell Can start Python shell from C+ program GUI features provided by cisstInteractive (using wxWidgets),Device Interface,Device Hierarchies:,Tracker Tool GetPosition,Robot Tool GetPosition MoveToPosition,Should be able to use robot in place
16、of a tracker,Device Interface,Our solution: query with string to obtain command object (Command Pattern),Tracker Tool Provides,Robot Tool Provides,ddiDeviceInterface Configure Provides GetMethodByName,Initialize (e.g., from XML),Return list of implemented operations (strings),Return command object f
17、or specified operation (string),Abstract Base Class, “GetPosition” , “GetPosition”, “MoveToPosition” ,Device Interface, dev = ptr to device devConfigure(); cmd = devGetMethodByName(“GetPosition”); ,public:void Startup();,void Run(); ;, cmdExecute(data); ,class myTask : public rtsTask private:ddiDevi
18、ceInterface* dev;ddiCommand* cmd;,Non-real-time,Real-time,Real Time Support,Devices and Tasks should be interchangeable: Example: Servo control via an intelligent device or via a software task Solution: Task class derived from device class, but also includes a device,ddiDeviceInterface,rtsTask,Real
19、Time Support,Maintain time history of important state data State Data Table (SDT), indexed by time and data id,Task communication with Command Pattern: Read from Task SDT or Device Write to Task Mailbox or Device Command object can handle remote communications,High-level task (low frequency),Low-lev
20、el task (high frequency),Device Interface,mailbox,SDT,mailbox,SDT,Hardware,Command objects,Command objects,cisstRealTime,Development Tools,CTest,Build Environment,LaTeX,Doxygen,SWIG,Compile,Compile,Library Binaries (static & dynamic, e.g., cisstVector, cisstCommon),Test Programs,Applications,Optiona
21、l Interpreter (IRE),Wrapped Source,Formatted Documentation (e.g., pdf, html),(e.g., VC+, gcc/make),Link,CVSTrac (bug/feature requests),CMake,CVS Repository (source control),CMake Build Instructions,Documentation,Libraries,Test App,Applications,Scripts,Dart2 (dashboard),Quick Tour of the Web Site,www
22、.cisst.org/resources/software,Development Summary,Tools adequately manage implementation, (unit) testing and maintenance phases of development Automated testing will be hard for physical devices Much documentation is manually created (not enforced by the process) Requirements, risk analysis, (high-level) design, validation User guide, tutorial, quickstart We needed Dart sooner than we expected! gcc is getting pickier! Windows static/shared libraries (dll export),