ThoughtForge Client

This class manages communication between the local client and the ThoughtForge servers. To implement a ThoughtForge client, inherit from the base class.

ThoughtForge Client Session Base Class

host=None, port=None, protocol='https', api_key=None, model_data=None)

This class is a base class for implementing client applications on the ThoughtForge platform. It manages the protocol for talking to the server and is inteded to be inherited by users to implement simple interactive simulations.

See also
Please see examples at for usage examples of this class.


  • file_name (str) – The parameter file for specifying sensors, motors and model configuration
  • host (str) – Host address for the destination ThoughtForge server. Defaults to None. If left unset, will be populated from the environment variable ‘THOUGHTFORGE_HOST’
  • port (int) – Host port for the destination ThoughtForge server. Defaults to None. If left unset, will be populated from the environment variable ‘THOUGHTFORGE_PORT’
  • model_data (dict) – Optional parameter for supplying saved model data at initialization of the sim.


This function is called automatically when debug data is being collected. Implement this function in a user client session to perform custom runtime debugging.

Debug mode can be enabled in a client params file by setting “enable_debug”: true
Here are examples of things to look at:
print("Global stability rate:", round(debug_data_dict['global_stability_rate'], 6))
print("Global energy estimate", round(debug_data_dict['global_energy_estimate'], 6))
print("Per-block stability rates:", debug_data_dict['block_stability_rates'])
print("Per-block energy estimates:", debug_data_dict['block_energy_estimates'])
print("Per-block stable times:", debug_data_dict['block_stable_times'])

debug_data_dict (dict) – A dictionary of global and block-level debug statistics

returns the number of motors that have been added to the session modelR
The number of Motors.
Return type:

‍returns the number of sensors that have been added to the session modelReturns:
The number of sensors.
Return type:


This function allows clients to preprocess their json specifications before sending to the server


This function is called to notify the start of the session. This is an opportunity to perform initialization that is needed.


This function can optionally be implemented by users to handle end-of-session needs or to report on results


This function can optionally be implemented by users to initialize any simulation environment parameters, and set the initial sensor state from the simulation. If this function isn’t implemented, initial sensor values are assumed to be 0.

initial sensor state of the simulation
Return type:


This function requests stopping of the simulation. Client applications can call this to request shutdown of the simulation loop


Implement this function in client code to update environment state and return sensor data.

update() is called automatically during simulation and is intended to be the primary point of entry for users to define the interaction between the thoughtforge model and the specific simulation environment.


motor_action_dict (dict) – A dictionary of motor names to motor values generated by the model

A dictionary of sensor names to sensor values to send to the model
Return type: