JeanElsner / panda-py

Python bindings for real-time control of Franka Emika robots.
https://jeanelsner.github.io/panda-py/
Apache License 2.0
77 stars 14 forks source link

Error in API Call for Unlock/Lock on FR3 #18

Closed alberthli closed 6 months ago

alberthli commented 6 months ago

Hi Jean, thanks for the great package. Upon trying to unlock the FR3, I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/path/to/python3.10/site-packages/panda_py/__init__.py", line 113, in unlock
    self._request('post',
  File "/path/to/python3.10/site-packages/panda_py/__init__.py", line 312, in _request
    raise ConnectionError(response.text)
ConnectionError: <!DOCTYPE html>
<html>
<head>
<title>Not found</title>
</head>
<body>
<code>No handler accepted "/api/robot/open-brakes"</code>
</body></html>

I've downloaded the wheel associated with libfranka version 0.13.2 for python 3.10. My guess is that the API call might be different between the Panda and the FR3? By examining the API calls sent out from the web GUI, I can successfully unlock the robot with the following change to __init__.py:

  def lock(self, force: bool = True) -> None:
    """
    Locks the brakes. API call blocks until the brakes are locked.
    """
    self._request('post',
                  '/desk/api/joints/lock',
                  files={'force': force})

  def unlock(self, force: bool = True) -> None:
    """
    Unlocks the brakes. API call blocks until the brakes are unlocked.
    """
    self._request('post',
                  '/desk/api/joints/unlock',
                  files={'force': force},
                  headers={'X-Control-Token': self._token.token})

If there is indeed a difference between the FER and FR3 interfaces, then perhaps the Desk object can just take an additional flag that indicates which platform the user has. I've opened a PR with those changes for your review.

juelg commented 6 months ago

Thank you @alberthli , the fix works for our FR3.

JeanElsner commented 6 months ago

Thanks again for this, I will merge your solution and make a release soon.