Makeblock-official / mDrawBot

mDrawbot is a four-in-one drawing robotic kit, you can assembly into 4 different configuration drawing robots, learn more from Makeblock official website
http://www.makeblock.com
GNU General Public License v3.0
201 stars 149 forks source link

Command line automation #40

Open robertshearing opened 9 years ago

robertshearing commented 9 years ago

I'd like to create and automated process where I can get the mScara to draw some svg graphics on demand.

Is it possible to send an svg file location with some position/scale data to trigger the robot to begin drawing via command line interface? Alternatively can this be dome by sending the data over the serial directly? I have had a brief glance at the source code but I'm not familiar with python and I can't see there the serial comms are.

Any help would be really appreciated.

tur0kk commented 8 years ago

I don't think it is possible to start mDraw with parameters via command line. What you can do is to send gcode commands to the mScara directly via a serial connection.

Python code which sends commands in a file named out.gcode to device:

import serial
import time
# Open grbl serial port
s = serial.Serial('INSERT_YOUR_PORT_HERE',115200)
# Open g-code file
f = open('out.gcode','r');
# Wake up firmware
s.write("\r\n\r\n")
time.sleep(2)   # Wait for firmware to initialize 
s.flushInput()  # Flush startup text in serial input
# Stream g-code to firmware
for line in f:
    l = line.strip() # Strip all EOL characters for consistency
    print 'Sending: ' + l,
    s.write(l + '\n') # Send g-code block to firmware
    s.flushInput() 
    grbl_out = s.readline() # Wait for firmware response with carriage return
    print ' : ' + grbl_out.strip()
# Wait here until firmware is finished to close serial port and file.
raw_input("  Press <Enter> to exit and disable firmware.") 
# Close file and serial port
f.close()
s.close()   

Then the only thing you have to do is to translate your image to gcode accepted by mScara.

luispinedaaguirre commented 8 years ago

@robertshearing were you able to automate the process? if so, can you share the code you use or give me advice on how to do it. I am working on a project that would need automation. Thank you in advance.

luispinedaaguirre commented 8 years ago

@tur0kk Do you have a C or C++ code instead of Python that has the same function? Thank you in advance

tur0kk commented 8 years ago

No sorry, I only have the python code for this basic sending functionality.

But I wrote a plugin for an open source laser cutter software called VisiCut. It can read in vector files, generate gcode, and send it to a laser cutter. With this plugin it is possible to use VisiCut with the MakeBlock laser cutter. Find an explanation on my blog.