Difference between revisions of "OpenIGTLink/Library"
From NAMIC Wiki
Line 21: | Line 21: | ||
= Tutorial = | = Tutorial = | ||
− | ==C-code implementation== | + | ==C-code implementation (w/o socket)== |
The library contains c codes in the Source/igtlutil directory to generate Open IGT Link message byte stream. | The library contains c codes in the Source/igtlutil directory to generate Open IGT Link message byte stream. | ||
Line 27: | Line 27: | ||
To send transform | To send transform | ||
+ | #include "igtl_util.h" | ||
#include "igtl_header.h" | #include "igtl_header.h" | ||
#include "igtl_transform.h" | #include "igtl_transform.h" | ||
− | /* pack data body */ | + | /********** pack data body **********/ |
igtl_float32 transform[12]; | igtl_float32 transform[12]; | ||
Line 40: | Line 41: | ||
} | } | ||
− | igtl_transform_convert_byte_order(transform); | + | igtl_transform_convert_byte_order(transform); /* convert endian if necessary */ |
+ | |||
+ | /********** pack data body **********/ | ||
+ | |||
+ | igtl_header header; | ||
+ | igtl_uint64 crc = crc64(0, 0, 0LL); /* initial crc */ | ||
+ | header.version = IGTL_HEADER_VERSION; | ||
+ | header.timestamp = 0; | ||
+ | header.body_size = GetBodyPackSize(); | ||
+ | header.crc = crc64((unsigned char*)m_Body, GetBodyPackSize(), crc); | ||
+ | |||
+ | strncpy(header.name, "TRANSFORM", 12); /* Device Type: should be "TRANSFORM" */ | ||
+ | strncpy(header.device_name, "Tracker", 20); /* Device name */ | ||
+ | |||
+ | igtl_header_convert_byte_order(h); /* convert endian if necessary */ |
Revision as of 21:42, 23 June 2008
Home < OpenIGTLink < LibrarySource code
An Open Source implementation of the OpenIGTLink protocol is available at
http://www.na-mic.org/svn/NAMICSandBox/trunk/OpenIGTLink/
License
This code is distributed under the new BSD License.
Design
Building instructions
Tutorial
C-code implementation (w/o socket)
The library contains c codes in the Source/igtlutil directory to generate Open IGT Link message byte stream.
To send transform
#include "igtl_util.h" #include "igtl_header.h" #include "igtl_transform.h" /********** pack data body **********/ igtl_float32 transform[12]; for (int i = 0; i < 3; i ++) { transform[i] = matrix[i][0]; transform[i+3] = matrix[i][1]; transform[i+6] = matrix[i][2]; transform[i+9] = matrix[i][3]; } igtl_transform_convert_byte_order(transform); /* convert endian if necessary */ /********** pack data body **********/ igtl_header header; igtl_uint64 crc = crc64(0, 0, 0LL); /* initial crc */ header.version = IGTL_HEADER_VERSION; header.timestamp = 0; header.body_size = GetBodyPackSize(); header.crc = crc64((unsigned char*)m_Body, GetBodyPackSize(), crc); strncpy(header.name, "TRANSFORM", 12); /* Device Type: should be "TRANSFORM" */ strncpy(header.device_name, "Tracker", 20); /* Device name */ igtl_header_convert_byte_order(h); /* convert endian if necessary */