Hi everyone,
i have revived a project that i begun some years ago. I have a 3d printed Moveo with 6 axis. i am using 6 tic T500 to control 6 stepper motors of various sizes.
i am using python to read and write positions and status between redis and ticcmd.
i use subprocess in python:
The first instance sends the reset timeout command every 0.5 seconds.
The second instance reads ticcmd -s to get current position and velocity every 0.2 seconds.
The third instance writes position values to the tic, everytime the value for an axis changes in its corresponding redis topic.
at first i tried to make only one python program that controls all 6 tic controllers but that introduced alot of latency. Then i reduced the program to handle only one tic controller, and instead started 6 separate python programs. That has less latency but alot more CPU load.
Where should i best optimize ?
is the latency coming from python (i expect) or from ticcmd?
is ticcmd started only once and communicating with the tic controllers each one at a time ? or are there more instances running at the same time (i was not able to observe that in htop)?
what is the best way to read the tic status very often ? (the current position display in the ticgui is very fast, how does it work?)
the goal of all of this is that i would like to use the moveo with Ros Moveit - i have already some work done like urdf file and configuraton, but i need to make a driver for Ros2 control or at least a wrapper of some kind. i found some older projects on github that used an arduino mega and ramps, and tried that and it worked a little but not very satisfying. i think this could be a cool use case for the tic controllers.
kind regards
fenrelot
Hello, fenrelot.
When you say “latency”, what exactly are you referring to? How did you measure it and what numbers did you consider to be “alot”?
You might consider using a single invocation of ticcmd to both get the status (-s
) and also set the position (--position
) or clear the timeout (--reset-command-timeout
) at the same time. This would reduce the overhead. Note that setting the target position clears the timeout as a side effect, so there is no reason to set the position and reset the timeout at the same time. You can also disable the command timeout feature entirely, reducing the amount of I/O needed in your system.
I’m not sure if using one Python process or multiple ones makes the most sense: it probably depends on what else is going on in the program. If you do use a single process, you should time how long it takes to run those six ticcmd invocations in series (one after the other). If it’s too slow for what you need, then you can consider using threads to run them in parallel.
The ticcmd program does not run in the background; it uses your operating system’s APIs to find the Tic, open a handle to it, perform the I/O you requested, close the handle, and then terminate. The Tic Control Center (ticgui) is very different: it finds the Tic and opens a handle to it in the same way, but then it leaves the handle open so it can efficiently communicate with the Tic while it is connected.
–David
Thank you for explaining the different inner workings of ticcmd and ticgui !
my conclusions for now are:
i can optimize my python code in the following way regarding the use of ticcmd: use it more wisely by consolidating instructions.
is it possible to achieve the speed of the tic gui (for example to read the velocity value with 20hz?) by creating something from the “12.11. Example code using the C API” of the documentation ?
i also found the source of the ticgui software on github but that is a little above my programming skills.
i think i will use the ticcmd for now and see how far it gets me
thanks again !
greetings
fenrelot
Yes, the Tic Control Center software uses the Tic’s C API for all its communication with the Tic.
–David