I'm using Sympy on JupiterNotebook, but I'm having trouble getting an error.

Asked 2 years ago, Updated 2 years ago, 331 views

I would appreciate it if you could tell me how to solve it.
"TypeError: 'map' object is not subscriptable"

The programs you would like to run are as follows:

There is no error up to the #parameter (real number) item, but this error appears in #calculation of each coordinate.

import numpy as np
from mpl_toolkits.mplot3d import Axes 3D
import matplotlib.pyplot asplt
from sympy import*
fromsympy.abc import*

init_printing()

# definition of unit vectors and angles
angles=symbols("phi_0phi_1phi_2")# angle indicating the direction from the origin to the shoulder
theas=symbols("theta_0theta_1theta_2")#Motor angle (±90 deg)
unit_vectors = [Matrix([cos(angles[i], sin(angles[i], 0]) for i in range(3)]
ez = Matrix ([0,0,1])

# Parameters (real number)
params = [(A, 130.0), (B, 200.0), (C, 400.0), (D, 130.0)]
params.append((angles[0], 2.0*np.pi/3.0*0))
params.append ((angles[1], 2.0*np.pi/3.0*1))
params.append ((angles[2], 2.0*np.pi/3.0*2))
params.append((x,0))
params.append(y,0))
params.append((z,400))

# calculation of each coordinate
A_vectors=map (lambdax: A*x, unit_vectors)
B_vectors= [A_vectors[i]+B*(unit_vectors[i]*cos(thetas[i])-ez*sin(thetas[i]) for i in range(3)]
D_vector= Matrix ([x, y, z])
C_vectors= [D_vector+D*unit_vectors[i] for i in range(3)]

Enter a description of the image here

python

2022-09-30 22:04

1 Answers

map has

Returns the iterator to apply function to all elements of the iterable while returning the results.

and so on.
A_vectors[i] is an error for the iterator.

Similar to B_vectors, C_vectors, it would be good to do the following

A_vectors=[A*x for x in unit_vectors]


2022-09-30 22:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.