Robot Design And Control Using 3ds Max And Ez-builder


This thread is a continuation of Thread #9584


What's wrong with the original thread?


Good question.

The original thread title was "Camera Interference With Servo Movement?" That issue and the reasons for it have been addressed and a new thread direction has been established which centers on remote robot control with 3ds. Specifically software methods to achieve the goal (along with robot design). I felt a more descriptive title was in order to allow for better reader understanding of what the thread was going to be about from this point on. Not to mention future searches being more relevant. In reality there never was any "interference" from a camera in the first place. Nor would the new direction further address that issue.

That being said; in hindsight, an error on my part may have been starting the new thread myself since it is under my name now. In that regard, can the title author be changed to Mickey666Maus? Or perhaps it would it better if this thread was deleted entirely to give him the opportunity to start the new thread instead for purposes of author continuity?


Hey guys, I would have re-opened again anyways...just being on the train to Berlin without Wifi kept me from doing it! Winky
The old thread went a little off topic so I guess it was a good idea to have a new title so everyone can already eyeball what's going on here!
I do not care too much about being the author here, its a community so its more about sharing than owning I guess! Grin

We started off discussing the problems on the sleep() task being not real time due to Windows being not a real time OS...which will cause problems if you are scripting a Frame By Frame animation where a sleep task is called every 33ms.

So @WBS00001 was proposing a vector approach between keyframes, rather than sending the exact position to a servo every single frame!
The code and also the discussion of the problem can be found here Thread #9584

While being on this problem which could also be a general problem of animating movement outside of the Auto Position and just using EZ-script to create movement, we started getting more specific to the point of creating motion in an external animation package called 3ds we decided to open this thread for further discussion!

3ds max is a 3D modeling and animation software by Autodesk, it is free to use for three years if you are studying or for personal use...there are tons of tutorials on the Internet, so give it a try if you havent already checked it! Winky

I modeled and rigged a robot in 3d, it can be animated in 3ds max and the motion can be transferred....either in real time thru the EZ-Builders HTTP server, or it can be played back directly within EZ-Builder by importing the motion into EZ-Builder using an EZ-Script that @WBS00001 coded!

We will still have to do some testing and hopefully clean up my messy maxscript...but I guess we are closing in! Smile



The above video is to shows how far I got it wired up by now...My goal is to model and print a robot directly from within 3ds max and then animate it with the software and play it back fro EZ-Builder, using different motions for different commands, moods etc!

An now comes my messy piece of code...hope you can throw in some ideas on how to clean it up @WBS00001


/*creating a textfile for output*/
global txt_file = createFile "C:\Users\swann\Desktop\movement.txt"

/*unregistering previous definitions*/
--unregisterRedrawViewsCallback servo_r
unregisterTimeCallback servo_r

/* Http socket open*/
rollout httpSock "httpSock" width:0 height:0
activeXControl port "Microsoft.XMLHTTP" setupEvents:false releaseOnClose:false
createDialog httpSock pos:[-100,-100];
destroyDialog httpSock;

/* Send the values from the GUI*/
fn servo_r = (
/*first servo*/
a = ", "
b = ($HandRechts.pos.z + 9) *10
c = "Winky"
d = a+b as string +c

/* HTTP socket connect */ "GET" d false;

/*second servo*/
e = ", "
f = ($ArmLinks.pos.z + 9) *10
g = "Winky"
h = e + f as string + g

/* HTTP socket connect */ "GET" h false;

/*third servo*/
i = ", "
j = ($SchulterRechts.pos.z + 9) *10
k = "Winky"
l = i + j as string + k

/* HTTP socket connect */ "GET" l false;

/*fourth servo*/
m = ", "
n = ($Augen.pos.z +9) *10 as integer
o = "Winky"
p = m + n as string + o

/* HTTP socket connect */ "GET" p false;

--Arm to textfile
u = f as string
v = ("Servo(D8,"+ u +"Winky"Winky as string
format "%\n" v to:txt_file

print (format "%\n" v)

--Shoulder to textfile
w = 33.3333333333 as string
x = ("Sleep(" + w + "Winky"Winky as string
y = j as string
z = ("Servo(D6,"+ y +"Winky"Winky as string
format "%\n" z to:txt_file
format "%\n" x to:txt_file

print (format "%\n" z)
print (format "%\n" x)

--registerRedrawViewsCallback servo_r
registerTimeCallback servo_r


RedrawViewsCallback servo_r
The RedrawViewsCallback would update the real world robot live anytime a virtual joint is being rotated...

unregisterTimeCallback servo_r
The TimeCallback will be called if the time slider is moved to the next frame

b = ($HandRechts.pos.z + 9) *10
The weird .pos.z + 9) *10 comes from the size of my GUI... Grin

As you can see, I had to spell out all my servos separately, it would be kind of cool if this could be stringed together somehow, like having a variable on how many servos there are in total and this would be how many times the script looks for those values... assumed that proper naming within the 3d model is given! Grin

Also it would be really awesome to have a global variable that will give another name to the .txt file everytime the script is called...I am getting an error if I try to run it more than once because it already exists of course!

Hahahaha and sorry about the simley faces in my code...I really dont know how to get rid of them! Winky


Just wanted to let you know I'm working on it. I have to do a bit of reading on MaxScript to find the proper statements to re-do the code since I'm not familiar with that language. It should be possible to set up some parameters initially and use a loop to go through the servos one after another, regardless of how many there are or how they are re-arranged in the future. It may even be possible to read something from the rigging information in the model and get the info automatically.

To eliminate the "Winky" emoticons that pop up you will need to put the code between the code and /code markers. Some of the character combinations in the regular text are interpreted as emoticons otherwise. In this case I believe it's the quote symbol followed by the close parenthesis symbol.

Quick questions ...
1) Are you connected to the EZ-B via an EZ-Builder project when you run the Maxscript program?
2) If so, in which mode are you connected to the EZ-B, AP mode or Client mode?


All of this sounds very good...I did all the coding using copy and paste from stuff I found on scriptspot etc...I can get it done, but as you can see, it's like a little child trying to speak grown up language! Grin

I am connected to EZ-Builder with the HTTP server running while executing the Maxscript, this will move the servo according to the RedrawViewsCallback or TimeCallback, whichever is running while the Maxscript is operating!

I am connected in client mode.

I guess for just animating and saving the string to a texfile none of the above would matter, but it is kind of convenient to have the robot executing the movement from frame to frame along with recording it to a textfile, just to make sure the motion works properly! Smile