I m trying to build a Python function. I have created a tridimensional array. But if I try to insert a value into it, I received the following error:
<code>list indices must be integers or slices, not tuple
</code>
<code>list indices must be integers or slices, not tuple
</code>
list indices must be integers or slices, not tuple
This is the code:
<code>def eventHandler(request, args, config):
import math
file_temp_id = args.get('EventHeaderID')
logger.debug(f"Hello {username}, your fileTempID is {file_temp_id}")
file_bodies = FileBodies(tenant=tenant,eventHeaderId=file_temp_id)
maxRowId = file_bodies.getMaxRowID(fieldId=41)
file_bodies.InformationMessage(message=f"numero righe in pagina: {maxRowId}")
for i in range(1, maxRowId+1):
file_bodies.InformationMessage(message=f"analizzo riga: {i}")
# Creo il vettore posizione Forearm
v_FOREARM = [0, -0.236397, 0]
# Creo il vettore posizione UpperArm
v_UA = [0, -0.289316, 0]
# definisco pigreco
Pi = 3.14159265358979
# Creo la matrice di rotazione RyRzRx della shoulder
w, h = 3, 3
R_SH = [[0 for x in range(w)] for y in range(h)]
#
Flex_Sh = file_bodies.getValue_REAL(fieldId=65, rowId=i)
Rot_Sh = file_bodies.getValue_REAL(fieldId=64, rowId=i)
Abd_Sh = file_bodies.getValue_REAL(fieldId=63, rowId=i)
R_SH[1, 1] = math.cos(Flex_Sh / 180 * Pi) * math.cos((-Rot_Sh) / 180 * Pi) - math.sin(Flex_Sh / 180 * Pi) * math.sin(Abd_Sh / 180 * Pi) * math.sin((-Rot_Sh) / 180 * Pi)
return file_bodies.getChanges()
</code>
<code>def eventHandler(request, args, config):
import math
file_temp_id = args.get('EventHeaderID')
logger.debug(f"Hello {username}, your fileTempID is {file_temp_id}")
file_bodies = FileBodies(tenant=tenant,eventHeaderId=file_temp_id)
maxRowId = file_bodies.getMaxRowID(fieldId=41)
file_bodies.InformationMessage(message=f"numero righe in pagina: {maxRowId}")
for i in range(1, maxRowId+1):
file_bodies.InformationMessage(message=f"analizzo riga: {i}")
# Creo il vettore posizione Forearm
v_FOREARM = [0, -0.236397, 0]
# Creo il vettore posizione UpperArm
v_UA = [0, -0.289316, 0]
# definisco pigreco
Pi = 3.14159265358979
# Creo la matrice di rotazione RyRzRx della shoulder
w, h = 3, 3
R_SH = [[0 for x in range(w)] for y in range(h)]
#
Flex_Sh = file_bodies.getValue_REAL(fieldId=65, rowId=i)
Rot_Sh = file_bodies.getValue_REAL(fieldId=64, rowId=i)
Abd_Sh = file_bodies.getValue_REAL(fieldId=63, rowId=i)
R_SH[1, 1] = math.cos(Flex_Sh / 180 * Pi) * math.cos((-Rot_Sh) / 180 * Pi) - math.sin(Flex_Sh / 180 * Pi) * math.sin(Abd_Sh / 180 * Pi) * math.sin((-Rot_Sh) / 180 * Pi)
return file_bodies.getChanges()
</code>
def eventHandler(request, args, config):
import math
file_temp_id = args.get('EventHeaderID')
logger.debug(f"Hello {username}, your fileTempID is {file_temp_id}")
file_bodies = FileBodies(tenant=tenant,eventHeaderId=file_temp_id)
maxRowId = file_bodies.getMaxRowID(fieldId=41)
file_bodies.InformationMessage(message=f"numero righe in pagina: {maxRowId}")
for i in range(1, maxRowId+1):
file_bodies.InformationMessage(message=f"analizzo riga: {i}")
# Creo il vettore posizione Forearm
v_FOREARM = [0, -0.236397, 0]
# Creo il vettore posizione UpperArm
v_UA = [0, -0.289316, 0]
# definisco pigreco
Pi = 3.14159265358979
# Creo la matrice di rotazione RyRzRx della shoulder
w, h = 3, 3
R_SH = [[0 for x in range(w)] for y in range(h)]
#
Flex_Sh = file_bodies.getValue_REAL(fieldId=65, rowId=i)
Rot_Sh = file_bodies.getValue_REAL(fieldId=64, rowId=i)
Abd_Sh = file_bodies.getValue_REAL(fieldId=63, rowId=i)
R_SH[1, 1] = math.cos(Flex_Sh / 180 * Pi) * math.cos((-Rot_Sh) / 180 * Pi) - math.sin(Flex_Sh / 180 * Pi) * math.sin(Abd_Sh / 180 * Pi) * math.sin((-Rot_Sh) / 180 * Pi)
return file_bodies.getChanges()
The error is on this line of code:
<code>R_SH[1, 1] = math.cos(Flex_Sh / 180 * Pi) * math.cos((-Rot_Sh) / 180 * Pi) - math.sin(Flex_Sh / 180 * Pi) * math.sin(Abd_Sh / 180 * Pi) * math.sin((-Rot_Sh) / 180 * Pi)
</code>
<code>R_SH[1, 1] = math.cos(Flex_Sh / 180 * Pi) * math.cos((-Rot_Sh) / 180 * Pi) - math.sin(Flex_Sh / 180 * Pi) * math.sin(Abd_Sh / 180 * Pi) * math.sin((-Rot_Sh) / 180 * Pi)
</code>
R_SH[1, 1] = math.cos(Flex_Sh / 180 * Pi) * math.cos((-Rot_Sh) / 180 * Pi) - math.sin(Flex_Sh / 180 * Pi) * math.sin(Abd_Sh / 180 * Pi) * math.sin((-Rot_Sh) / 180 * Pi)
1