Interfacing Kflop with Blender

Moderators: TomKerekes, dynomotion

Post Reply
cyprian21
Posts: 13
Joined: Fri Nov 29, 2019 6:09 am

Interfacing Kflop with Blender

Post by cyprian21 » Mon May 18, 2020 7:33 pm

Good day,

I am wondering if anyone has attempted to interface the kflop motion controller with Blender which is a free and open source 3D creation suite, https://www.blender.org/.

Below is an example of how someone managed to interface Blender and an Arduino to control a robotic arm in real-time by calculating its Inverse Kinematics angles from the model.

A python script enables real-time control of a robotic arm in Blender. It works by reading angles from the arm's armature and sending them through the serial port to an arduino controlling the physical arm.

This can be seen here:
http://www.alvaroferran.com/projects/blender-controller

Now, I do not necessarily want real-time control but it would be neat to export said Inverse Kinematics angles from the model and run them on the kflop so the motor performs the motion of the 3d model.

Instead of an Arduino, I would like to do something similar with the kflop.

I already control my cnc mill with a kflop and would like to buy more kflop boards to experiment.

Would anyone have any feedback or thoughts on how to approach something like this?

Kindly,
Cyprian

User avatar
TomKerekes
Posts: 2529
Joined: Mon Dec 04, 2017 1:49 am

Re: Interfacing Kflop with Blender

Post by TomKerekes » Mon May 18, 2020 9:30 pm

Hi Cyprian,

That sounds interesting. I'm not aware of anyone interfacing KFLOP to Blender.

I didn't see any Kinematics. It seems the Blender link angles were simply being sent directly to the motor axes.

I'm not familiar with Blender Scripts or Code, but assuming it can be made to make an external call to a dll it shouldn't be very difficult. Usually a KFLOP MoveExp call works well in a situation where a motor axis should be attempting to follow a randomly changing target position.
Regards,

Tom Kerekes
Dynomotion, Inc.

cyprian21
Posts: 13
Joined: Fri Nov 29, 2019 6:09 am

Re: Interfacing Kflop with Blender

Post by cyprian21 » Thu Dec 17, 2020 9:23 am

Thank you Tom,

To take a simpler approach, I wrote a script in Python that exported the rotation of an object as a list of degrees sampled at 30 times a second.

In this simple example below, the object (I called it 'Stepper01') just rotates on it's Z axis twice in 2 seconds according to an animation in Blender that has a prescribed acceleration and deceleration. So, I would like to now have a stepper motor recreate this motion using these exported values:

Stepper01 - frame 1 - X:0.000000 Y:0.000000 Z:0.593333
Stepper01 - frame 2 - X:0.000000 Y:0.000000 Z:2.346667
Stepper01 - frame 3 - X:0.000000 Y:0.000000 Z:5.220001
Stepper01 - frame 4 - X:0.000000 Y:0.000000 Z:9.173335
Stepper01 - frame 5 - X:0.000000 Y:0.000000 Z:14.166667
Stepper01 - frame 6 - X:0.000000 Y:0.000000 Z:20.160002
Stepper01 - frame 7 - X:0.000000 Y:0.000000 Z:27.113332
Stepper01 - frame 8 - X:0.000000 Y:0.000000 Z:34.986674
Stepper01 - frame 9 - X:0.000000 Y:0.000000 Z:43.740002
Stepper01 - frame 10 - X:0.000000 Y:0.000000 Z:53.333334
Stepper01 - frame 11 - X:0.000000 Y:0.000000 Z:63.726669
Stepper01 - frame 12 - X:0.000000 Y:0.000000 Z:74.880006
Stepper01 - frame 13 - X:0.000000 Y:0.000000 Z:86.753340
Stepper01 - frame 14 - X:0.000000 Y:0.000000 Z:99.306661
Stepper01 - frame 15 - X:0.000000 Y:0.000000 Z:112.500005
Stepper01 - frame 16 - X:0.000000 Y:0.000000 Z:126.293353
Stepper01 - frame 17 - X:0.000000 Y:0.000000 Z:140.646682
Stepper01 - frame 18 - X:0.000000 Y:0.000000 Z:155.520006
Stepper01 - frame 19 - X:0.000000 Y:0.000000 Z:170.873329
Stepper01 - frame 20 - X:0.000000 Y:0.000000 Z:186.666666
Stepper01 - frame 21 - X:0.000000 Y:0.000000 Z:202.860006
Stepper01 - frame 22 - X:0.000000 Y:0.000000 Z:219.413338
Stepper01 - frame 23 - X:0.000000 Y:0.000000 Z:236.286651
Stepper01 - frame 24 - X:0.000000 Y:0.000000 Z:253.440016
Stepper01 - frame 25 - X:0.000000 Y:0.000000 Z:270.833338
Stepper01 - frame 26 - X:0.000000 Y:0.000000 Z:288.426704
Stepper01 - frame 27 - X:0.000000 Y:0.000000 Z:306.179977
Stepper01 - frame 28 - X:0.000000 Y:0.000000 Z:324.053325
Stepper01 - frame 29 - X:0.000000 Y:0.000000 Z:342.006642
Stepper01 - frame 30 - X:0.000000 Y:0.000000 Z:360.000010
Stepper01 - frame 31 - X:0.000000 Y:0.000000 Z:377.993324
Stepper01 - frame 32 - X:0.000000 Y:0.000000 Z:395.946749
Stepper01 - frame 33 - X:0.000000 Y:0.000000 Z:413.820043
Stepper01 - frame 34 - X:0.000000 Y:0.000000 Z:431.573371
Stepper01 - frame 35 - X:0.000000 Y:0.000000 Z:449.166682
Stepper01 - frame 36 - X:0.000000 Y:0.000000 Z:466.560059
Stepper01 - frame 37 - X:0.000000 Y:0.000000 Z:483.713341
Stepper01 - frame 38 - X:0.000000 Y:0.000000 Z:500.586695
Stepper01 - frame 39 - X:0.000000 Y:0.000000 Z:517.139959
Stepper01 - frame 40 - X:0.000000 Y:0.000000 Z:533.333300
Stepper01 - frame 41 - X:0.000000 Y:0.000000 Z:549.126719
Stepper01 - frame 42 - X:0.000000 Y:0.000000 Z:564.480000
Stepper01 - frame 43 - X:0.000000 Y:0.000000 Z:579.353420
Stepper01 - frame 44 - X:0.000000 Y:0.000000 Z:593.706708
Stepper01 - frame 45 - X:0.000000 Y:0.000000 Z:607.499974
Stepper01 - frame 46 - X:0.000000 Y:0.000000 Z:620.693332
Stepper01 - frame 47 - X:0.000000 Y:0.000000 Z:633.246673
Stepper01 - frame 48 - X:0.000000 Y:0.000000 Z:645.120110
Stepper01 - frame 49 - X:0.000000 Y:0.000000 Z:656.273372
Stepper01 - frame 50 - X:0.000000 Y:0.000000 Z:666.666734
Stepper01 - frame 51 - X:0.000000 Y:0.000000 Z:676.260090
Stepper01 - frame 52 - X:0.000000 Y:0.000000 Z:685.013442
Stepper01 - frame 53 - X:0.000000 Y:0.000000 Z:692.886628
Stepper01 - frame 54 - X:0.000000 Y:0.000000 Z:699.839979
Stepper01 - frame 55 - X:0.000000 Y:0.000000 Z:705.833388
Stepper01 - frame 56 - X:0.000000 Y:0.000000 Z:710.826639
Stepper01 - frame 57 - X:0.000000 Y:0.000000 Z:714.780171
Stepper01 - frame 58 - X:0.000000 Y:0.000000 Z:717.653331
Stepper01 - frame 59 - X:0.000000 Y:0.000000 Z:719.406668
Stepper01 - frame 60 - X:0.000000 Y:0.000000 Z:720.000020

Perhaps there is also a way adding some kind of interpolation in between each of the frames so that the motion is nice and smooth?

All that is of course unless there is a better way achieve this exact motion without the use so many individual samples.

Again the idea here is to animate a robot in Blender, export that data and have the kflop motion controller playback what the virtual robot did.

Thank you kindly,
Cyprian
Attachments
stepper_rotation.txt
(3.49 KiB) Downloaded 44 times

User avatar
TomKerekes
Posts: 2529
Joined: Mon Dec 04, 2017 1:49 am

Re: Interfacing Kflop with Blender

Post by TomKerekes » Thu Dec 17, 2020 3:26 pm

Hi Cyprian,

It isn't clear what you are trying to accomplish. But that could be formatted as GCode and run with KMotionCNC. You could use G93 (Inverse time mode) to tell the Interpreter how much time each block should take, 1/30th of a second. The time is specified in inverse minutes so 30x60=1800. Change:

Stepper01 - frame 1 - X:0.000000 Y:0.000000 Z:0.593333
Stepper01 - frame 2 - X:0.000000 Y:0.000000 Z:2.346667
Stepper01 - frame 3 - X:0.000000 Y:0.000000 Z:5.220001

to

G93 G1 X0.000000 Y0.000000 Z0.593333 F1800
G93 G1 X0.000000 Y0.000000 Z2.346667 F1800
G93 G1 X0.000000 Y0.000000 Z5.220001 F1800
etc
Regards,

Tom Kerekes
Dynomotion, Inc.

cyprian21
Posts: 13
Joined: Fri Nov 29, 2019 6:09 am

Re: Interfacing Kflop with Blender

Post by cyprian21 » Fri Dec 18, 2020 3:06 am

Thanks Tom! Worked like a charm!

I got KmotionCNC using Gcode to mimic the rotation of the virtual motor axis in Blender.

I thought I would do it by writing c code and running it in KMotion Executive Application but this works as well.

I'll keep experimenting,

Thanks again!
Cyprian

Post Reply