Arduino to Daz Studio bridge for PC-Win (mocap)

mCasualmCasual Posts: 4,605
edited October 2016 in Freebies

so if you have an Arduino

or

if you have a microcontroller that talks to the PC using the serial ports and you make it "talk" according to the special format i used


https://sites.google.com/site/mcasualsdazscripts7/mcjcomkit


1 short arduino program ( sketch )
1 PC-Win Application ( the bridge )
1 Daz Script 

The daz script is a very slightly modified version of the Wii and the Gamepad "Client" which you may want to look at !

you start the script, 
the script starts the bridge
the bridge establishes the communication with the arduino through a COM/Serial port
the arduino app starts sending the values of the 6 analog inputs ( i have an arduino Leonardo ) to the bridge
the bridge relays them to the Daz Studio script

the client receives 6 numbers between 0 and 1024

i then linked this to Aiko's Shoulder Up-Down angle

if you know arduino programming, the messaging format is simple, so you can easily add, digital input readings 

for now the only message transmitted from Daz Studio to the arduino is the sampling rate

in fact the arduino is so short here it is

int rate = 1000;char mesg[100];#define INPUT_SIZE 30  char input[INPUT_SIZE + 1];void setup(){  Serial.begin( 9600 );  Serial.setTimeout( 100 );  while( !Serial )  {  }}void loop() {  byte size = Serial.readBytes( input, INPUT_SIZE );  input[size] = 0;  char* command = strtok(input, ",\n");  int numFields = 0;  char fields[5][16];  while( command != 0 )  {    strcpy( fields[numFields], command );    ++numFields;    command = strtok(0, ",\n");  }  if( numFields > 0 )  {    if( strstr( fields[0], "HEAD" ) )    {      sprintf( mesg, "[\tHEADERS\t%ld\t%s\t%s\t%s\t%s\t%s\t%s\t]",         millis(),         "A0", "A1", "A2", "A3", "A4", "A5"        );      Serial.println( mesg );    }    else if( strstr( fields[0], "RATE" ) )    {      if( numFields >= 2 )      {        rate = atoi( fields[1] );      }    }  }  sprintf( mesg, "[\tDATA\t%ld\t%d\t%d\t%d\t%d\t%d\t%d\t]",     millis(),     analogRead( A0 ), analogRead( A1 ), analogRead( A2 ),     analogRead( A3 ), analogRead( A4 ), analogRead( A5 )   );  Serial.println( mesg );  delay( rate );}

 

image

theplan.jpg
1872 x 886 - 577K
Post edited by mCasual on

Comments

  • mCasualmCasual Posts: 4,605
    edited October 2016

    there's a one-day delay, it basically works right now but i'm having a bit of trouble making the bridge bi-directional

    so ... Thursday should be the day

    ---------

    unrelated image ( see mcjBuilderA ... them arches were done with it right in Daz Studio )

    https://sites.google.com/site/mcasualsdazscripts3/mcjbuildera

     

     

     

     

    desasquatched.jpg
    1920 x 1080 - 425K
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,605
    edited October 2016

    it's ready ! !

    it's a bit rushed i didnt test the mcjComClient recording function, but we inherited it from the wiimote/gamepad/android clients which worked fine

    https://sites.google.com/site/mcasualsdazscripts7/mcjcomkit

    mcjComClient.dsa.png
    182 x 182 - 58K
    Post edited by mCasual on
Sign In or Register to comment.