API reference for Py-EDScorbotTool
Graphical interface powered by Tkinter
- class pyEDScorbotTool.pyAER.pyEDScorbotTool(visible=True)[source]
py-EDScorbotTool software, replacement of jAER filter for EDScorbot
This class is used for establishing a communication with ED-Scorbot Robot in order to be able to control it via neuromorphic control, also called SPID
- Variables
self.d – Dictionary in which there are stored the variables that allow for SPID configuration. Every input of the graphical interface corresponds to a variable that is stored in this dictionary. It contains three other dictionaries: Motor Config, Joints and Scan Parameters, which in turn hold the corresponding variables. The keys for the dictionaries are “Motor Config”, “Joints” and “Scan Parameters”, respectively.
self.visible – Boolean variable that indicates whether the graphical interface should be rendered or not
self.root – Root of the graphical interface’s window
self.checked_usb – Variable that holds the state of the checkbox that indicates whether USB is enabled or not.
- ConfigureInit()[source]
Set current position as initial
This function sets the current position of each joint as the initial position. This means that, after this function is called, the current position will match the position with a reference of 0
- ConfigureSPID()[source]
Program SPID parameters and command a movement to all the joints
It calls sendCommandJoint1-6 and sends the parameters needed to configure the SPID controller as well as the reference specified
- ConfigureSPID_allJoints()[source]
Same as ConfigureSPID but it doesn’t print the information in the console
- Read_J1_pos()[source]
Read position of the first joint
This function makes combined use of sendCommand16 and readSensor functions to retrieve J1 position
- Returns
Position of J1 or -1 if something went wrong
- Return type
int
- Read_J2_pos()[source]
Read position of the second joint
This function makes combined use of sendCommand16 and readSensor functions to retrieve J2 position
- Returns
Position of J2 or -1 if something went wrong
- Return type
int
- Read_J3_pos()[source]
Read position of the third joint
This function makes combined use of sendCommand16 and readSensor functions to retrieve J3 position
- Returns
Position of J3 or -1 if something went wrong
- Return type
int
- Read_J4_pos()[source]
Read position of the fourth joint
This function makes combined use of sendCommand16 and readSensor functions to retrieve J4 position
- Returns
Position of J4 or -1 if something went wrong
- Return type
int
- Read_J5_pos()[source]
Read position of the fifth joint
This function makes combined use of sendCommand16 and readSensor functions to retrieve J5 position
- Returns
Position of J5 or -1 if something went wrong
- Return type
int
- Read_J6_pos()[source]
Read position of the sixth joint
This function makes combined use of sendCommand16 and readSensor functions to retrieve J6 position
- Returns
Position of J6 or -1 if something went wrong
- Return type
int
- SendCommandJoint1(ref)[source]
Send reference to 1st joint
This function allows to send a reference to the 1st joint in order to move it, reference to angle are mapped in angle_to_ref function
- SendCommandJoint1_lite()[source]
Send only reference to 1st joint
This function allows to send a reference to the 1st joint in order to move it, reference to angle are mapped in angle_to_ref function
- SendCommandJoint2(ref)[source]
Send reference to 2nd joint
This function allows to send a reference to the 2nd joint in order to move it, reference to angle are mapped in angle_to_ref function
- SendCommandJoint2_lite()[source]
Send only reference to 2nd joint
This function allows to send a reference to the 2nd joint in order to move it, reference to angle are mapped in angle_to_ref function
- SendCommandJoint3(ref)[source]
Send reference to 3rd joint
This function allows to send a reference to the 3rd joint in order to move it, reference to angle are mapped in angle_to_ref function
- SendCommandJoint3_lite()[source]
Send only reference to 3rd joint
This function allows to send a reference to the 3rd joint in order to move it, reference to angle are mapped in angle_to_ref function
- SendCommandJoint4(ref)[source]
Send reference to 4th joint
This function allows to send a reference to the 4th joint in order to move it, reference to angle are mapped in angle_to_ref function
- SendCommandJoint4_lite()[source]
Send only reference to 4th joint
This function allows to send a reference to the 4th joint in order to move it, reference to angle are mapped in angle_to_ref function
- SendCommandJoint5(ref)[source]
Send reference to 5th joint
This function allows to send a reference to the 5th joint in order to move it, reference to angle are mapped in angle_to_ref function
- SendCommandJoint5_lite()[source]
Send only reference to 5th joint
This function allows to send a reference to the 5th joint in order to move it, reference to angle are mapped in angle_to_ref function
- SendCommandJoint6(ref)[source]
Send reference to 6th joint
This function allows to send a reference to the 6th joint in order to move it, reference to angle are mapped in angle_to_ref function
- SendCommandJoint6_lite()[source]
Send only reference to 6th joint
This function allows to send a reference to the 6th joint in order to move it, reference to angle are mapped in angle_to_ref function
- SendFPGAReset()[source]
Command the FPGA to force an internal reset
This function tells the FPGA to reset, in order to restore its initial configuration in case something is not working properly
- SendFPGAReset_joint(joint)[source]
Command the FPGA to force an internal reset
This function tells the FPGA to reset, in order to restore its initial configuration in case something is not working properly
- alert(text)[source]
This function creates a messagebox with the text parameter as data
Useful to alert the user that something has gone wrong; to indicate successful procedures, please just print to console using print()
- Parameters
text (str) – Text to be displayed in the box
- static angle_to_ref(motor, angle)[source]
Convert angle of motor to reference
This function takes a motor and an angle and returns the corresponding reference to said angle for that specific motor.
- Parameters
motor (int) – Number of the motor (1-4)
angle (int) – angle to be converted
strict (boolean) – Whether to restrict reference values to ther maximum bounds or not (default is True)
- Returns
Reference that corresponds to the angle given for the given motor or the joint’s limit if the calculated reference is above (or below) it
- Return type
float
- checkRemote()[source]
Check wether remote usage has been enabled or not
This function reads the checked_remote self variable to determine whether remote connection has been enabled or not
If it has, then tries to connect to MQTT broker and sets self.mqtt to the mqtt client
If it hasn’t, it disconnects from the broker
- checkUSB()[source]
Check wether USB usage has been enabled or not
This function reads the checked_usb self variable to determine whether USB connection has been enabled or not
If it has, then tries to connect to AERNode board and sets self.dev to the device handlerconnect
If it hasn’t, it disconnects from the device
- static count_to_angle(motor, count)[source]
Convert counter of motor to estimated angle
This function takes a motor and its collected position and returns the corresponding estimated angle to said position for that specific motor.
- Parameters
motor (int) – Number of the motor (1-4)
count (int) – Position counter to be converted
- Returns
Estimated angle that corresponds to the position given for the given motor
- Return type
float
- static count_to_ref(motor, count)[source]
Convert counter of motor to reference
This function takes a motor and its collected position and returns the corresponding reference to said position for that specific motor.
- Parameters
motor (int) – Number of the motor (1-4)
count (int) – Position counter to be converted
- Returns
Reference that corresponds to the position given for the given motor
- Return type
float
- dumpConfig()[source]
Dump current configuration
This function dumps current config (the one being displayed in the GUI) to a JSON file named “config.json”
Generated config file is also printed in console
- init_config()[source]
Load initial config
This function tries to load the initial configuration for the program containing all the necessary values that make the SPID control work properly. There must be an “initial_config.json” file for this to work properly and, in case you are missing it, you can download the file directly from the latest master branch of the repository
- loadConfig(visible=True)[source]
Load configuration in an extern .json file
This function allows users to load a json file containing a valid configuration file, just as the ones generated with the dumpConfig function
Also works without gui, just pass the correspondent argument to the –config option
- readSensor(sensor)[source]
Read a joint’s position sensor
This function allows for a joint sensor to be read, so that you are able to know a joint’s position in any given moment
- Parameters
sensor (int) – The number of the sensor to be read, ranging from 1 to 6
- Returns
Sensor position if everything went well or -1 if something went wrong
- Return type
int
- static ref_to_angle(motor, ref, strict=True)[source]
Convert reference of motor to angle
This function takes a motor and a reference and returns the corresponding angle to said reference for that specific motor
- Parameters
motor (int) – Number of the motor (1-4)
ref (int) – reference to be converted
strict (boolean) – Whether to restrict angle values to ther maximum bounds or not (default is True)
- Returns
Angle that corresponds to the reference given for the given motor or the joint’s limit if the calculated reference is above (or below) it
- Return type
float
- static ref_to_count(motor, ref)[source]
Convert reference of motor to counter (estimated) absolute position
This function takes a motor and an arbitrary reference and returns the corresponding estimated position for said reference for that specific motor.
- Parameters
motor (int) – Number of the motor (1-4)
ref (int) – Reference to be converted
- Returns
Absolute estimated position that corresponds to the reference given for the given motor
- Return type
float
- render_buttons(row, col)[source]
Create the buttons that will be bounded to all different usable actions
- Parameters
row (int) – Row of the grid in which the buttons will be displayed
col (int) – Column of the grid in which the buttons will be displayed
- render_dynapse2(row, col)[source]
Create the Threshold and Reset counters paramters
Each variable created is stored in the “Dynapse2” dictionary and can be accessed directly using the name that appears on the graphical interface
- Parameters
row (int) – Row of the grid in which the inputs will be displayed
col (int) – Column of the grid in which the inputs will be displayed
- Returns
Labelframe in which the inputs are rendered
- render_gui()[source]
Top level GUI routine
This function serves as a top routine for rendering all GUI widgets. It calls each function that renders a component, and assigns them a place in the top window.
Layout changes may be made here: just change the column and row of the component to render in its call to adjust it to your own needs
- render_joints(row, col)[source]
Create joints text entries
These entries are read-only, as they will contain the joints measures read from the encoders
Each variable created is stored in the “Joints” dictionary and can be accessed directly using the name that appears on the graphical interface
- Parameters
row (int) – Row of the grid in which the inputs will be displayed
col (int) – Column of the grid in which the inputs will be displayed
- Returns
LabelFrame in which the entries are rendered
- render_motor(motor_number, row, col)[source]
Create the inputs for 1 motor
Each variable created is stored in the “Motor Config” dictionary and can be accessed directly using the name that appears on the graphical interface
- Parameters
motor_number (int) – Number of the motor to be rendered
row (int) – Row of the grid in which the inputs will be displayed
col (int) – Column of the grid in which the inputs will be displayed
- Returns
Labelframe in which the inputs are rendered
- render_progressbar(row, col)[source]
Create the progress bar to indicate trajectory execution %
- Parameters
row (int) – Row of the grid in which the buttons will be displayed
col (int) – Column of the grid in which the buttons will be displayed
- render_scan_parameters(row, col)[source]
Create the Scan Parameters inputs
Each variable created is stored in the “Scan Parameters” dictionary and can be accessed directly using the name that appears on the graphical interface
- Parameters
row (int) – Row of the grid in which the inputs will be displayed
col (int) – Column of the grid in which the inputs will be displayed
- Returns
Labelframe in which the inputs are rendered
- render_usbEnable(row, col)[source]
Create the checkbox that enables opening USB devices
The value of the box is stored in the checked_usb variable available in the class (self.checked_usb)
- Parameters
row (int) – Row of the grid in which the checkbox will be displayed
col (int) – Column of the grid in which the checkbox will be displayed
- resetUSB()[source]
Reset USB connection
This function resets USB connection by closing and then reopening the device
- scanMotor1()[source]
Scan Motor 1
This function commands the robot to perform the scan procedure defined by the 4 Scan Parameters (available in the dictionary as “Scan Parameters”)
These functions (scanMotor1-6) can be used to obtain data that can be later be displayed in different graphs
- scanMotor2()[source]
Scan Motor 2
This function commands the robot to perform the scan procedure defined by the 4 Scan Parameters (available in the dictionary as “Scan Parameters”)
These functions (scanMotor1-6) can be used to obtain data that can be later be displayed in different graphs
- scanMotor3()[source]
Scan Motor 3
This function commands the robot to perform the scan procedure defined by the 4 Scan Parameters (available in the dictionary as “Scan Parameters”)
These functions (scanMotor1-6) can be used to obtain data that can be later be displayed in different graphs
- scanMotor4()[source]
Scan Motor 4
This function commands the robot to perform the scan procedure defined by the 4 Scan Parameters (available in the dictionary as “Scan Parameters”)
These functions (scanMotor1-6) can be used to obtain data that can be later be displayed in different graphs
- scanMotor5()[source]
Scan Motor 5
This function commands the robot to perform the scan procedure defined by the 4 Scan Parameters (available in the dictionary as “Scan Parameters”)
These functions (scanMotor1-6) can be used to obtain data that can be later be displayed in different graphs
- scanMotor6()[source]
Scan Motor 2
This function commands the robot to perform the scan procedure defined by the 4 Scan Parameters (available in the dictionary as “Scan Parameters”)
These functions (scanMotor1-6) can be used to obtain data that can be later be displayed in different graphs
- search_Home_J1()[source]
Search Home position for joint 1
This function uses search_Joint_home function to search the home position of joint 1
- search_Home_J2()[source]
Search Home position for joint 2
This function uses search_Joint_home function to search the home position of joint 2
- search_Home_J3()[source]
Search Home position for joint 3
This function uses search_Joint_home function to search the home position of joint 3
- search_Home_J4()[source]
Search Home position for joint 4
This function uses search_Joint_home function to search the home position of joint 4
- search_Home_J5()[source]
Search Home position for joint 5
This function uses search_Joint_home function to search the home position of joint 5
- search_Home_J6()[source]
Search Home position for joint 6
This function uses search_Joint_home function to search the home position of joint 6
- search_Home_all()[source]
Search Home position for all joints
This function uses search_Joint_home function to search the home position of all joints
Be careful: this function won’t stop execution until it has completely finished rendering the graphical interface stuck in the process, so bear that in mind when using it
- search_Joint_home(JOINTNUM, pol)[source]
Implement the method of searching a joint’s home.
First it moves the joint until it hits one of its limits, then progressively moves the joint in the opposite direction until the controller receives the home signal from the joint
- Parameters
JOINTNUM (int) – Number of the joint we want to find home position for
pol (int) – 1 or -1, depending on the joint
- sendCommand16(cmd, data1, data2, spiEnable)[source]
Send 2 bytes of data and an address via USB to robot’s infrastructure
This function allows to send 2 bytes of data to a specific address to the AERNode board via USB
- Parameters
cmd (int) – Address to which data will be sent
data1 (byte) – Byte 1 of data
data2 (byte) – Byte 2 of data
spiEnable (bool) – Legacy option not to break anything, always True in this program
- send_Home_J1()[source]
Send Joint 1 to current home position
This function uses sendCommand16 to send the first joint to its current home position, which is specified by passing ‘0’ as reference
- send_Home_J2()[source]
Send Joint 2 to current home position
This function uses sendCommand16 to send the second joint to its current home position, which is specified by passing ‘0’ as reference
- send_Home_J3()[source]
Send Joint 3 to current home position
This function uses sendCommand16 to send the third joint to its current home position, which is specified by passing ‘0’ as reference
- send_Home_J4()[source]
Send Joint 4 to current home position
This function uses sendCommand16 to send the fourth joint to its current home position, which is specified by passing ‘0’ as reference
- send_Home_J5()[source]
Send Joint 5 to current home position
This function uses sendCommand16 to send the fifth joint to its current home position, which is specified by passing ‘0’ as reference
- send_Home_J6()[source]
Send Joint 6 to current home position
This function uses sendCommand16 to send the sixth joint to its current home position, which is specified by passing ‘0’ as reference
- send_Home_all()[source]
Send Joint 1-6 to current home position
This function uses sendCommand16 to send all joints to its current home position, using send_Home_JX functions, with X being the joint’s number