Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Numpy/Python Array Value error

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.

like image 601
AnthonyT Avatar asked Mar 19 '17 20:03

AnthonyT


People also ask

How do you fix error setting an array element with a sequence?

Here we have seen that this error is cause because we are assigning array as a element to array which accept string data-type. we can fix this error by matching the data-type of value and array and then assign it as element of array.

What is the truth value of an array?

ValueError: The truth value of an array with more than one element is ambiguous. If the number of elements is one, the value of the element is evaluated as a bool value. For example, if the element is an integer int , it is False if it is 0 and True otherwise.

How do you use a ANY () or a all ()?

Use all() when you need to check a long series of and conditions. Use any() when you need to check a long series of or conditions.


1 Answers

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

np.array([ your lists ])
like image 134
AnthonyT Avatar answered Sep 30 '22 17:09

AnthonyT