5

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.

3
  • 5
    Just embrace these lists with a pair of brackets: np.array([ your lists ]). Commented Mar 19, 2017 at 20:44
  • 1
    np.array takes ONE list, a dtype, and some key word arguments. Looks like your input is several lists. Commented Mar 19, 2017 at 20:46
  • @ForceBru haha can't believe I missed that! thank you :P Commented Mar 19, 2017 at 20:49

1 Answer 1

15

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

np.array([ your lists ])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.