Notable changes of tdmclient. Release versions refer to [https://pypi.org/project/tdmclient/].
- In transpiler, event name fixed in code generated for
emit
- Tool
infoto display the variables, events and native functions of a robot. - Existence of a variable in a node can be tested with
inornot in. - In tool
list, the product id (content of the node variable_productId) is displayed if it's available, with its meaning if it's known. - In transpiler, as an alternative to the
oneventdecorator, functions can be declared as event handlers by callingoneventas a function. For example the three code fragments below are equivalent:@onevent def timer0(): ...def timer0(): ... onevent(timer0)def task(): ... onevent(task, "timer0")
- Variable size returned in node description.
- In transpiler:
- Empty lists are now reported as unsupported instead of an obscure exception.
- Variable
prox_ground_ambientwas mapped to Thymio variableprox.ground.ambientwhich is misspelled in the robot firmware asprox.ground.ambiant; transpiled code was rejected by the Aseba compiler. Now bothprox_ground_ambientandprox_ground_ambiantare mapped toprox.ground.ambiantto suit both new Python documentation with a correct spelling and programmers using Aseba documentation. - Deque functions are prefixed with
nf_to be consistent with other native functions and with the documentation. - Typo in the name of variables
event.*. - In user-defined event names in
@onevent defandemit, underscore characters are replaced with dots. These events are now consistant with the automatic definitions ofrun.
- Option to browse zeroconf information on all interfaces instead of default one. Optional argument
all_interfacesin constructors ofTDMZeroconfBrowser,ClientandClientAsync; and option--zcallin toolsgui,list,repl,run,tdmdiscoveryandwatch. - In tool
watch, new options to filter the information to observe:--events,--scratchpads,--shared-event-descr,--shared-variables,--variables,--vm-state. - New tool
sendevent.
- Default TDM is local on port 8596 (fixed port of TDM as launched by Thymio Suite). Zeroconf is used only if requested with
zeroconf=Truein the constructors ofClientandClientAsyncand in methodtdmclient.notebook.start, or--zeroconfin the tools.
- Module
websocketsnot needed anymore except to enable option--wsin toolserver. - In tool
gui, connection closed on exit. - Group id instead of node id in TDM message
SendEvents.
- In transpiler, syntax errors are displayed with context
- Module
tkinternot needed anymore except for toolgui - In transpiler, attribute syntax for scalar Thymio variables, such as
import thymio; x = thymio.button_center
- Exported
NodeLockError
- Dependency on package
websocket-clientremoved (websocket-clientshould be installed separately ifClientorClientAsyncare instantiated withtdm_ws=True)
- Optional connection to the TDM using a WebSocket instead of plain TCP
- In tools
gui,list,repl,run, andwatch:- option
--tdmport defaultstands for the default TDM TCP port 8596 - option
--tdmwsto connect to the TDM with a WebSocket
- option
- In server:
- improved support to use in other programs
- To make the tools easier to reuse from code, their entry point has been moved to the root of the module, and the tool name must be provided as the first argument. For example instead of
you must now type
python3 -m tdmclient.tools.run program.pyTo call thepython3 -m tdmclient run program.pymainfunction of a tool, import it withimport tdmclient.toolsinstead of e.g.import tdmclient.tools.run; and calltdmclient.tools.run.main([args...])as before. Or use an alternativeimportorfrom ... importvariant if you prefer.
- When closing the TCP connection, callback functions are all executed in turn when the connection is actually closed
- In transpiler:
- In
tdmclient.tools.transpileand notebooks, option--warning-missing-globalto display warnings for local variables which hide global variables (a declaration as global could be missing) - Exception
NameErrorreplaced byTranspilerErrorwith node context to display the line number in the error message - Property
linenoin exception classTranspilerError - Transpiler exception for unsupported augmented assignments
/=,**=and@= - Errors on undefined variables or invalid use of list variables or indexing in augmented assignments
- In
- In function
ClientAsync.wait_for_node, optional argumenttimeout - In server:
- options
--port,--debug,--zeroconf - support for WebSocket
- code easier to use in other programs
- options
- In transpiler:
- Name of local list variables passed to native functions wasn't converted
- User functions called in arguments of
emit,exitandprintcaused an exception
- In server:
- Clean shutdown of connection thread
- Socket address reused
- Separate group id
- Transpiler exception for unsupported operators such as
/,**and@
- Options of tool
tdmclient.tools.gui - In transpiler:
- Check that constants such as
REDare not assigned to (clean error from transpiler instead of incorrect transpiled code) - When auxiliary statements are required to compute the condition of
elif, the generated code iselse aux if ... end endinstead ofaux elseif ... end
- Check that constants such as
- Optional boolean argument
zeroconfinClientconstructor and Jupyter functionsstart(),list(), andwatch() - Class
NodeLockErrorwith the current node status raised when a node cannot be locked - Optional key argument
passwordin the constructor ofClientAsyncto connect to remote TDM - In repl:
- Key argument
robot_indexin functions and option--robotindexin Jupyter magic commands to specify the robot by index - Optional robot specification in
send_event - Optional argument
all_nodesin functionprocess_events
- Key argument
- In notebooks:
- Optional
debugargument instart() - Optional
passwordargument instart(),list(),watch() - Optional
timeoutargument inlist()andget_nodes() - Multiple targets in magic commands
%%run_pythonand%%run_asebawith comma-separated list of robots
- Optional
- Option
--passwordin toolstdmclient.tools.guy,tdmclient.tools.list,tdmclient.tools.repl,tdmclient.tools.run,tdmclient.tools.watch
- In repl and Jupyter, callback
on_event_datahas a newnodeargument to better support interaction with multiple robots
- Method
Client.create_node()referred to a symbol which wasn't imported - Watch flag changes sent by methods
ClientAsyncNode.watchandClientAsyncNode.unwatch - In repl, support for starred expressions
- Support for fragmented packets
- In notebooks, function
get_nodes()must be called afterstart()and with its tdm connection to avoid returning orphan nodes
- In
tdmclient.tools.watch, options to select the tdm and the robot - In repl:
- in functions
run()andstop(), keyword argumentsrobot_idorrobot_nameto specify another robot, which is locked during the call - the complete Python or Aseba source code of a program can be passed to function
run()as an alternative to collecting @onevent functions and global variables
- in functions
- In notebooks:
- private symbols not defined anymore in
tdmclient.notebook - docstrings for magic commands, displayed with e.g.
%%run_python? - In magic commands
%%run_pythonand%%run_aseba, options--robot-id IDor--robot-name NAMEto specify another robot, which is locked during the execution - functions
list()andget_nodes()can be called beforestart() - function
tdmclient.notebook.watch(), to be called asawait tdmclient.notebook.watch()to display the robot variables with live update
- private symbols not defined anymore in
- In transpiler, support for lists given as
len(...)*[...]or[...]*len(...) - When decoding flatbuffer strings, illegal utf-8 sequences decoded as
U+FFFD(replacement character) instead of raising an exception
- In notebooks, functions
list()andget_nodes()use by default the TDM connection established bystart()instead of a local TDM advertized by zeroconf
- Local variables defined by the assignment of a global variable neither declared with
globalnor predefined as Thymio variables raised an exception
- Runtime VM errors reported in repl and
tdmclient.tools.run
- In transpiler, temporary variables in
forloops overwrote the loop limit and step - Format of the tdm message for VM state changed
- In transpiler, support for lists given as
num*[...]or[...]*num
- In transpiler, access to undeclared global variables when they aren't hidden by a local variable
- In repl and notebooks, synchronized user variables not forgotten when a program is run on the robot
- In
tdmclient.tools.repl, launch code moved to a functionmain(argv=None)so that it can be called from the Python shell - In repl and notebooks, shortened message when interrupting program
- In transpiler, module "clock" fixed
- In repl, better support for Python 3.6 and 3.10
- In transpiler:
- module
clockwith functionsseconds(),ticks_50Hz()andreset()
- module
- In repl:
- functions
get_client()andget_node() - functions
get_varandset_var - global variables defined in the robot program added to the list of variables to be synchronized
- functions
- In notebooks:
- functions
get_nodes()andlist()to get the list of nodes available in the TDM - decorator
@sync_varto synchronize the robot variables accessed in the function - in
%%run_python, option--clear-event-datato callclear_event_data()before starting the program
- functions
- In the
run()function of repl and notebooks and intdmclient.tools.run, the decision to wait or not when no explicit option is specified is now based only on custom events (events not predefined in the vm) - Better compatibility with Python 3.6:
- in transpiler, support of string constants as documentation strings or arguments of
print()andemit() - in repl, no warning for numbers and booleans
- in transpiler, support of string constants as documentation strings or arguments of
- Decoding of the size of array variables obtained from TDM
- In repl, underscores not converted to dots in name of global variables which don't correspond to a known Thymio variable
- Documentation improvements
- In transpiler, support for receiving custom events with arguments
- In repl, function
send_event - In notebooks, functions
stop,get_client,get_node
- In transpiler:
%in print string constants- in method
simple_transpile, symbols from modulethymioimported by default
- In transpiler, definitions for more native functions
- New notebook to illustrate the use of native functions
- Nul bytes in zeroconf property "ws-port" discarded
- In transpiler:
- support for
exit - dict of events emitted by
emit, with automatic declaration by tooltdmclient.tools.runand functionrunin repl and notebooks
- support for
- In documentation:
- note on the replacement of
run_async_programwithawaitin Jupyter notebooks
- note on the replacement of
- By default, locking the default node raises an error if it's busy instead of waiting
- Event output in tool
tdmclient.tools.runwritten with CSV format
- In transpiler:
andandor- augmented assignments with indexed variable target
rangewith negative step- list arguments in native function calls
- check for recursive function calls
- code generated for functions
math_clampandmath_muldiv
- In repl, event listeners reset when needed
- In transpiler:
- support for
print - support for module
thymiowhich can replace predefined Thymio variables and native functions
- support for
- In tdmclient.tools.run, support for events
- In transpiler:
- native functions without return value
- Support for Jupyter notebooks
- In repl:
- access to Aseba code
- function to forget definitions for the Thymio
- help and documentation
- In tools
gui,replandrun, new options--robotidand--robotid
- In transpiler:
- decoding of indices
- compatibility with older versions
- In repl:
- user-defined functions
- initialization of global variables in robot code
- Tool
tdmclient.tools.variablesrenamedtdmclient.tools.gui
- In transpiler:
- arguments, return value and local variables in function definitions;
- dot replaced with underscore in Thymio variable and native function names;
- Thymio variables must be declared as global in all function definitions;
- conditional expressions;
- chained comparisons;
- function
len; - better error messages
- New methods Client.shutdown_tdm, ClientAsync.rename, ClientAsync.send_events
- New callbacks Client.on_events_received, Client.on_event_received
- Argument of callback Client.on_variables_changed simplified
- Dummy server
- Missing tools in binary distribution
- Python-to-Aseba transpiler.
- Node objects with significant refactoring.
Node-related methods of classes
Thymio,ClientorClientAsyncwhich usednode_id_strto identify the node have been replaced by methods of new classesNode,ClientNodeandClientAsyncNode, respectively. Their use is simpler. - Options to specify the TDM address and port and avoid zeroconf
- First release on PyPI.