How to send a command to Chai3d from matlab?
I am currently using chai3d to control a novint falcon and have it set to perform different movements when a key is pressed. But how can I send these key commands to chai3d from within matlab?
I am by no means a programmer but I can write matlab code. The aim is to integrate the falcon into a brain computer interface.
The way to interface CHAI 3D with Matlab is to write your CHAI3D application as a shared library (a DLL on Windows) with various functions to initialize, run, and control the application. You can then use C-Mex in Matlab to call the relevant DLL functions when a Matlab event occurs (e.g. a key press event). You can find more information on how to call a DLL from Matlab on the Mathworks website at ch.mathworks.com/matlabcentral/answers/94347
I've not used DLL files before but I will certainly look into this option.
At the moment I have a very simple set up. A .cpp visual studio file loads chai 3d and key presses move the arm left and right etc. During the whole BCI process matlab uses a mex file I found called textInject to send the key presses to the chai 3d window when a certain prediction is made. which is rather crude :)
Where do I start when creating a DLL file? By the sounds of it they are a collection of executable functions almost.
Edit: sorry should have read through the link first, looks like they are .c files that are used to create the .dll within matlab.
I am using the standard devices code from the CHAI 3D visualization and haptics libraries. When a key is pressed and the arm is given a new position can I specify the velocity of this movement?
If possible would I add said code inside these sections?,
if ( key == '1' )
desiredPosition = cVector3d(0,-0.055,0);
I have never written C code before so kinda lost. I notice there is a linearVelocity variable though?
CHAI3D cannot robotically control the haptic device to move to a particular position with a single command. You can implement something similar using a spring and some viscosity, as shown in example 01-mydevice.cpp. The ::getLinearVelocity() method allows you to measure (not set) the haptic device velocity in order to compute the viscous force.
Please note that all CHAI3D applications require a haptic loop that runs continuously in order to control the haptic device smoothly. I invite you to look at the documentation overview and review the source code examples provided.