SVG Painter

Hi there,

Following is my new project, which is able to draw simple SVG files. The project is based on FABRIK inverse kinematics method.

The main program part is made in Delphi XE2 and communicates with robot via USB port. It consist of simple vector library, FABRIK inverse kinematics utils, and, as well, rasterization utils, which provide the possibility to trace lines and Bezier curves step by step. Delphi part also includes COM port communication class for sending commands to the robot.

Robot part is implemented using Robot Mesh Python. To keep it simple Python program contains only setup algorithm (which searches for motor zero positions) and move-to, line-to commands along with the main loop, which read commands from the COM port.


Robot Mesh Project:

Your project is just amazing. Thank you very much for posting the source codes, very interested in the ability to link windows and the brain. Could you post more information on how to do this from Delphi code a little I realized that works directly with the com port. There are some bytes of command codes for motors and other devices, or it is possible to run immediately part of the code in the brain. Could you post more information or links to it, how to link windows work and multiple brains. (translated via

(How to find the documentation for byte code. for Brian vexiq. Where?) or simple example how using com it is Possible to move motors or to work with sensors Guro ?

Ok. More about communication between Vex IQ and Windows:

Communication is done via USB cable, which connected as usually. Vex IQ driver, which is installed anyway if you use RobotC or Robot Mesh Studio, creates a virtual COM port. Its actually, quite simle to use it from Delphi, because COM port can be opened just like any file in WinAPI. I’ll not describe all details here, you can just re-use CommPort.pas unit from the project. I’ve found it actually, in Internet, and modified slightly. As well, I’ve found and added code, which detects VEX IQ port number; sources show how to connect to VEX IQ port:

procedure TRobot.Connect;
  nfo: TPortInfo;
  if not FPort.SearchPort('VEX', nfo) then
    raise ERobotError.Create('No connected VEX IQ found');

The main problem is that Com port cannot be opened by several application at the same time, so, its required to disconnect from Robot Mesh Studio first to make the port available. So, I use “Build program and download only” mode inside Robot Mesh Studio. It will automatically diconnects from COM port after two-three repeated click to this button. And, as well, your application should also disconnect from COM port, before Robot Mesh Studio will be able to connect to it. So, its not very comfortable :confused:

Next, there no “byte-code” or something similar published. Robot Mesh Python just provides Serial class, which can be used read/write bytes at the robot side. So, you can send/receive any bytes between Vex IQ and PC, and its your program task of how to interpret them.

Here its important to note that USB connection we use is generally designed for program downloading and debugging, speaking another words - to interoperating with IDE. This implies two things:

  1. Not all bytes, send from computer side, can be read with Serial class at robot side. Most data will not be considered as user-defined message. So, (thanks Anthony from Robot Mesh) data, which should be received via Serial class at robot side, should be prefixed with some predefined bytes:

To send data from the PC to the VEXIQ Brain to be read using, you need to prefix the data buffer with the following bytes:
0xc9, 0x36, 0xb8, 0x47, 0x7a, , data,….

e.g. the following would send two bytes: 0xaa, 0xbb:
0xc9, 0x36, 0xb8, 0x47, 0x7a, 2, 0xaa, 0xbb

This is done in TRobot.SendCmd in my sources.

  1. VEX IQ can send some debuggind data from the brain to PC at unpredictable times moments. And there no ways to distinguish this data from the data, which is explicitly sent to PC from your program using Serial class. So, robot program side should use some longer prefixes while sending data, and PC receiving side should search for such prefixes in in-coming data stream. There no other way.

My program is used htree commands:

01 - Execute setup procedure.
02 - Move to (without drawing, e.g. with raised pen)
03 - Draw to

Two last commands require two angles (for two motors) to be transfered as arguments. I encode every angly as two bytes and so, these commands are five bytes long. At the robot side I use the following code:

if sp.bytes_to_read() > 0:
  cmd = sp.read_byte()

for read commands, and:

arg = sp.read_bytes(4)

for read argument angles.

In opposite direction I send only one “ready” notification from robot to PC, which mean that the current command has been executed, and the brain is ready to read next command:

READY_STR  = '\x0AVP_\x01\x0A'
sp.write(READY_STR, False)

There no reason, why I choose READY_STR as shows above, you can choose any other string instead. However, as I noted, VEX IQ use “\x0A” char as a debuggins messages terminator char. So, probably, its a good idea to use it also, since it will minimize the chance, that a debugging message will contain READY_STR char sequence.

At PC side this notification is readed in TRobot.WaitForCmd method.

Wow, that is wicked cool! I’m going to show my students. Thanks for sharing!

Outstanding! Thanks for posting :slight_smile: