Numpy/Python Array Value error

AnthonyT picture AnthonyT · Mar 19, 2017 · Viewed 30.2k times · Source

I am trying to create a function to calculate the end-effector position of robotic arm using numpy arrays, but am coming across an error when the code runs. I have a function that passes in angles as arguments.

def FinalPosition(angle1, angle2, angle3, angle4, angle5, angle6):

My IDE is highlighting the last two lines of the array:

    T1 = np.array([np.cos(angle1), -np.sin(angle1)*np.cos(b1), np.sin(angle1)*np.sin(b1), a1*np.cos(angle1)],
        [np.sin(angle1), np.cos(angle1)*np.cos(b1), -np.cos(angle1)*np.sin(b1), a1*np.sin(angle1)],
        [0, np.sin(b1), np.cos(b1), d1],
        [0, 0, 0, 1])

and the error i'm getting is:

     .............................................in FinalPosition
[0, np.sin(b1), np.cos(b1), d1], [0, 0, 0, 1])
ValueError: only 2 non-keyword arguments accepted

Not sure what the issue is, could someone explain?

edit: the IDE hightlight over the last two lines says this.

Expected type 'Optional[bool]', got 'List[Union[int | TypeVar('T'), Any]]' instead less... (Ctrl+F1 Alt+T) 

This inspection detects type errors in function call expressions. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Types of function parameters can be specified in docstrings or in Python 3 function annotations.

Answer

AnthonyT picture AnthonyT · Mar 20, 2017

Answered by @hpaulj and @ForceBru in the comments. Missing a set of [] brackets.

np.array([ your lists ])