CHAI3DCHAI3D

normal spring coefficient

More
25 Feb 2017 15:18 #1

i am working with novint falcon device using force dimension library.
i want to know how to determine the spring coefficient "k".i try to get it using this code but it is not fixed.

#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include "drdc.h"
#include "dhdc.h"


using namespace std;
int
main (int  argc,
      char **argv)
{
	double mx,my,mz;
  double mx1, my1, mz1;
 double dx,dy,dz;
  double fmxx,fmyy,fmzz;
  double kx,ky,kz ;
  double time;
  int    done    = 0;

 


    // open device
      drdOpen  ( )  ;

  // start robot control loop
   (drdStart()) ;
  

    dhdGetPosition(&mx1,&my1,&mz1,-1);


  //  loop
  while (!done) {
    //get pos


    dhdGetPosition(&mx,&my,&mz,-1);
	//get force
	dhdGetForce(&fmxx, &fmyy, &fmzz,-1);

	////
	dx=mx-mx1;
	dy=my-my1;
	dz=mz-mz1;
	
	kx=fmxx/dx;
	ky=fmyy/dy;
	kz=fmzz/dz;
	
// print 

    
     printf ("k(%+0.01f %+0.01f %+0.01f)    \r",kx,ky,kz);

	


    
  
  }
 
 
  // close the connection
  drdClose() ;
  

   // exit
//  printf ("\ndone.\n");
  return 0;
}
is it the right way?

Please Log in or Create an account to join the conversation.

More
02 Mar 2017 17:33 #2

Are you holding the device at a desired position?

Please Log in or Create an account to join the conversation.

More
03 Mar 2017 09:30 #3

actually when i run the code the robot is stuck in a random position, even if i want to move it i can't.
the " printf ("k(%+0.01f %+0.01f %+0.01f) \r",kx,ky,kz)" the values of k keep changing until it stabilize to these numbers " k<+23080.0 +2081.8 -809.0>


but i wonder if is it the right way to extract the k spring coefficient (f=k*x)?

Please Log in or Create an account to join the conversation.

More
03 Mar 2017 10:20 #4

Your equation is theoretically correct, and will measure the apparent stiffness on each axis at your current regulation target. However, there are a few things you need to be careful of when implementing it.

  • When you call drdStart(), the Falcon will hold its current position. This means that, if you leave the end-effector alone, your measured position (mx, my ,mz) will be the same (or very close to) your initial reference position (mx1, my1, mz1). Similarly, when the Falcon is near or at its target position, the force applied (fmxx, fmyy, fmzz) will be very small (at least in the XY plane, since some amount of force is required on Z to provide gravity compensation).
    The consequence is that your equations for kx and ky will look like this:
    kx = fmxx/(mx-mx1) ≈ 0.0/0.0;
    and are therefore ill-conditioned. Make sure that you only compute K when your measured position is some distance away from your reference position so that both the force and distance are meaningful.

  • Also, keep in mind that the force returned by dhdGetForce() is a combination of the position regulation force (which may include other terms than just static stiffness, especially when in motion) and the gravity compensation forces. This means that your equations will only give you a valid stiffness value in X and Y (Z has gravity compensation), and in static conditions (when the end-effector is not moving, but is away from its target regulation position). To get a meaningfull fmzz force that you can use in computing kz, you need to measure fmzz_gravity (which is fmzz at the target position and in static condition), and use fmzz_real = (fmzz - fmzz_gravity) to compute the Z stiffness when away from the target position.

Please Log in or Create an account to join the conversation.

More
03 Mar 2017 14:31 #5

fmzz_gravity is defined as fmzz at the target position and in static condition.
this how the new code look like

#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include "drdc.h"
#include "dhdc.h"


using namespace std;
int
main (int argc,
char **argv)
{
double mx,my,mz;
double mx1, my1, mz1;
double dx,dy,dz;
double fmxx,fmyy,fmzz;
double kx,ky,kz ;
double time;
int done = 0;
double fmzz_gravity;

// open device
drdOpen ( ) ;

dhdGetPosition(&mx1,&my1,&mz1,-1);
dhdGetForce(&fmxx,&fmyy,&fmzz_gravity,-1);

// loop
while (!done) {
//get pos

dhdGetPosition(&mx,&my,&mz,-1);
//get force
dhdGetForce(&fmxx, &fmyy, &fmzz,-1);

////
dx=mx-mx1;
dy=my-my1;
dz=mz-mz1;

kx=fmxx/dx;
ky=fmyy/dy;
kz=(fmzz - fmzz_gravity)/dz;

// print 
printf ("k(%+0.01f %+0.01f %+0.01f) \r",kx,ky,kz);
}

// close the connection
drdClose() ;

// exit
// printf ("\ndone.\n");
return 0;
}

is there any problem if i keep the same fmxx and fmyy before and after the loop?

Please Log in or Create an account to join the conversation.

More
09 Mar 2017 18:13 #6

is the relationship between force and displacement for haptic devices (novint falcon ,omega....) linear f=kx ,or nonlinear ?

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum