jeanelsner / panda-py Goto Github PK
View Code? Open in Web Editor NEWPython bindings for real-time control of Franka Emika robots.
Home Page: https://jeanelsner.github.io/panda-py/
License: Apache License 2.0
Python bindings for real-time control of Franka Emika robots.
Home Page: https://jeanelsner.github.io/panda-py/
License: Apache License 2.0
Hi Jean,
Not a bug, but I was testing the cartesian impedance controller and working on extending it to include orientation, and noticed that the expected convention for quaternions is with scalar last, which differs from the one in roboticstoolbox/spatialmath (which I am using quite extensively) and Eigen (in API not memory, confusing!). I wander if it is worth having a configuration flag that determines this? Otherwise I think it is worth pointing this out visibly in the documentation/examples as it can actually lead to some unexpected outcomes:)
I'm conducting some grasping experiments where the gripper may contact the desk a little. But I've noticed that in the grasping process, after the gripper closed, the program just stuck and finally aborted (core dumped).
my code is like:
self.panda.move_to_joint_position(pre_grasp_joints, speed_factor=self.move_speed)
time.sleep(0.03)
self.panda.move_to_joint_position(grasp_joints, speed_factor=self.move_speed)
self.gripper.move(width=0.0, speed=self.gripper_speed)
time.sleep(0.03)
self.panda.move_to_joint_position(after_grasp_joints, speed_factor=self.move_speed)
self.gripper.move(width=self.max_gripper_width, speed=self.gripper_speed)
time.sleep(0.03)
here is the output:
....(previous ignored)
INFO - 2023-11-08 22:57:14,710 - grasp_panda - Stopping active controller (Trajectory).
INFO - 2023-11-08 22:57:14,712 - grasp_panda - Initializing motion generation (moveToJointPosition).
INFO - 2023-11-08 22:57:14,724 - grasp_panda - Computed joint trajectory: 1 waypoint, duration 5.72 seconds.
INFO - 2023-11-08 22:57:14,724 - grasp_panda - Starting new controller (Trajectory).
INFO - 2023-11-08 22:57:20,850 - grasp_panda - Stopping active controller (Trajectory).
INFO - 2023-11-08 22:57:20,853 - grasp_panda - Initializing motion generation (moveToJointPosition).
INFO - 2023-11-08 22:57:20,860 - grasp_panda - Computed joint trajectory: 1 waypoint, duration 2.17 seconds.
INFO - 2023-11-08 22:57:20,861 - grasp_panda - Starting new controller (Trajectory).
File "grasp_panda.py", line 136, in _execute_pick_and_place
self.gripper.move(width=0.0, speed=self.gripper_speed)
RuntimeError: libfranka gripper: Command failed!
INFO - 2023-11-08 22:59:13,746 - core - signal_shutdown [atexit]
Aborted (core dumped)
Hi @JeanElsner,
thanks for the great work here. I came across an edge case in the Cartesian motion generation. Executing the following code ...
T_0 = panda_py.fk(constants.JOINT_POSITION_START)
T_1 = T_0.copy()
T_1[0, 3] += 0.35
T_1[2, 3] -= 0.2
# T_1[1, 3] -= 0.2
panda.move_to_joint_position(constants.JOINT_POSITION_START)
panda.move_to_pose(T_1,
speed_factor=0.05,
stiffness=2 * np.array([600, 600, 600, 600, 250, 150, 50]))
produces the following error:
INFO:panda:Connected to robot (192.168.88.140).
INFO:panda:Panda class destructor invoked (192.168.88.140).
INFO:panda:Initializing motion generation (moveToJointPosition).
INFO:motion:Computed joint trajectory: 1 waypoint, duration 2.10 seconds.
INFO:panda:Starting new controller (Trajectory).
INFO:panda:Stopping active controller (Trajectory).
INFO:panda:Initializing motion generation (moveToPose).
INFO:motion:Computed Cartesian trajectory: 1 waypoint, duration 4.24 seconds.
INFO:panda:Starting new controller (Trajectory).
ERROR:motion:IK failed at time 3.11, prior to waypoint 1. Goal may be outside of workspace.
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[77], line 10
6 # T_1[1, 3] -= 0.2
8 panda.move_to_joint_position(constants.JOINT_POSITION_START)
---> 10 panda.move_to_pose(T_1,
11 speed_factor=0.05,
12 stiffness=2 * np.array([600, 600, 600, 600, 250, 150, 50]))
RuntimeError: IK produced NaN.
When I shift the goal pose in y
(see line 5 in the code above), the motion works but the first joint turns around very quickly. Let me know, if you need more data or how we can debug this.
Best,
Jan
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.
Thanks for great work. I'm trying to using your lib to control panda robot. While using another controller(cartesian impedance control, joint position) method it works great but when i try mmc control method it makes this error. blow is error i got
mmc.py 172.16.0.2
Control loop interruped: libfranka: Move command aborted: motion aborted by reflex! ["communication_constraints_violation"]
control_command_success_rate: 0.7254 packets lost in a row in the last sample: 7
Traceback (most recent call last):
File "/home/ahrilab/Downloads/mmc.py", line 40, in <module>
while ctx.ok() and not arrived:
RuntimeError: libfranka: Move command aborted: motion aborted by reflex! ["communication_constraints_violation"]
control_command_success_rate: 0.7254 packets lost in a row in the last sample: 7
I found it could be network latency issue in your test code it give this result.
I tested ping too. I shows good result too.
#9300 Current success rate: 1.000
#9400 Current success rate: 1.000
Finished test, shutting down example
#######################################################
The control loop did not get executed 206 times in the
last 9999 milliseconds (lost 206) robot states
Control command success rate of 9444 samples:
Max: 1.000
Avg: 0.979
Min: 0.910
#######################################################
it seems no problem in network setting.
In my case code with roboticstoolbox makes error. I aslo tried ik solve with roboticstoolbox it makes same error too.
Hi @JeanElsner,
Could you add a function to the 'Desk' class that triggers the robot to shut down? It could also be a parameter for the 'logout(shutdown=True)' function.
Thanks in advance!
Jan
First of all thanks for the fast reply regarding the installation. I went ahead and installed virtualbox and Ubuntu and the installation and everything else worked but...
I made a new python file in PyCharm and copied the first couple of lines from your jupyter tutorial notebook.
The connection to the desk works as you can see from the INFO:.... output. the unlock also works the the Panda robot unlocks all axes and moves them a tiny but as it is supposed to happen and as if I would press the unlock button in the Desk, but then when I want to connect to the Robot and the Hand I ran into the following error:
INFO:desk:Login succesful.
INFO:desk:Legacy desk detected.
Traceback (most recent call last):
File "/home/vboxuser/PycharmProjects/Panda_Test/Connect2Desk_Unlock.py", line 20, in <module>
panda = panda_py.Panda(hostname)
RuntimeError: libfranka: UDP receive: Timeout
Process finished with exit code 1
I searched for this error but there are only 2 options i found.
Do you think the reason is that the robot is on a too old version (4.0.2) and that this is the reason that I cannot connect?
Pinging it works but your communication_test.py always ends at the
if len(sys.argv) < 2: raise RuntimeError(f'Usage: python {sys.argv[0]} 172.16.0.2')
I have also added a static IP and connected to the control unit instead of the Arms base, as it is recommended in the documentation of the Panda..
hello, thank you very much for your work!
I have tried it and it is so impressive! But I'm a little confused why in your ik
function, q_7
is redundant joint? If it is only 6-DoF indeed, some waypoints may generate nan results. It can solve ik successfully if we do not fix the value of q_7
.
Hi, I was testing the code for trajectory smoothing, and in my case I require the code to track densely sampled trajctories rather than a limited number of way-points (for example points along a circle). Currently the code in panda-py forces the max_deviation
in the Path
constructor to zero (which works fine), but this will result in jerky motions that treat each pair of samples as a segment. This can be avoided by increasing max_deviation
to a suitable value. However, doing so results in the Trajectory::getTrajectorySegmentIndex
function returning a wrong index for a given timestep. I believe this is due to a mismatch in the length of the smoothed trajectory and the input path.
I'm still testing this, but one way to avoid the issue is to store a segment index into each PathSegment
when constructing the Path
object, and then using the following code for Trajectory::getTrajectorySegmentIndex
:
size_t Trajectory::getTrajectorySegmentIndex(double time) {
size_t idx = 0;
auto t = getTrajectorySegment(time);
double s = t->path_pos_;
return path_.getPathSegment(s)->index;
}
Hi, I am relatively new to this topic and I am currently working on my master thesis with the Panda robot.
I want write a program in python for the robot so it build up a structure of some kind of bricks.
My problem is that i cannot install your package.
I am using a windows PC and put the pip install panda-python command in the Terminal of a new project in PyCharm.
When i did this i got the following error:
ErrorCode_Python_panda_install.txt
So i tried to clone this repo first and open the project folder and repeat the install but now the pip command does not work at all with the following error message:
pip : The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Did the same in Visual Studio, cloned the repo, opened a CMake and opened the CMakeList.txt, the installation started but with the same error as in the attached file -> cannot find Eigen3....
Could you please provide some help, I really wish to use Python to manipulate the robot and write some tasks for it.
Do I need to use a Linux OS or what am I doing wrong.
I thank you in advance for your help.
Best regards
Thomas
Hi, I have a separate process that needs to read RobotState continuously at specified frequency. In my main thread I'm also trying to execute robot move to pose commands. However, these two commands seem to conflict with each other and I get UDP timeout issues. What's the proper way to asynchronously read RobotState from a separate process?
Main Process:
while True:
# run some move_to_pose command
Process 1:
robot = libfranka.Robot(hostname).read(test.call)
Hi,
thanks for the library.
I did pip install panda-python
on Windows 11. The dependencies are not installed directly during pip install. It requires manually installing Eigen3, Poco and Franka.
Was this library tested on windows? I'm not sure if the installation problem is due to the win system, or if the dependencies need to be installed in advance.
Hi, first of all thanks for the work!
I want to record the robot pose while "teaching", is there a suggested way or examples on how to do this with panda-py?
I currenly am getting the the pose with panda.get_robot().read_once().O_T_EE
Hello, and thank you for a very nice library.
I was wondering if there's any way of moving the gripper at the same time as the robot arm moves? I've tried to do some simple threading, where one script controls the arm, and the other controls the gripper, but didn't really get it to work. The actions happened in sequence, as if it was written in one script.
Again, thank you!
Hi, it would be useful to add functionality to the desk interface so it can also set programming vs execution mode. Currently I am doing this externally (using a FR3) with this function:
def set_programming_mode(desk, flag):
if flag:
url = '/desk/api/operating-mode/programming'
else:
url = '/desk/api/operating-mode/execution'
desk._request('post',
url,
files={'force': True},
headers={'X-Control-Token': desk._token.token})
With the URLs borrowed from https://github.com/TimSchneider42/franky
Hi @JeanElsner ,
I recently discovered this repo and it is EPIC!!!!
It makes my life so much simpler!!!
THANKS A LOT FOR THAT!!!
No issue here.
Thanks for the great work! I've been using this as my main Franka driver and I noticed that the joints will sometimes wildly oscillate when trying to get into a particular motion. Has anyone else encountered this issue? The error I get is "Power Limit Violation"
Hi! I want to use panda-py to execute a sequence of gripper pose on fr3. But I find that sometimes the move_to_pose function does not work, especially when the gripper deviates from the starting position. Can you help me with that?
Here is the error:
Control loop interruped: libfranka: Move command aborted: motion aborted by reflex! ["controller_torque_discontinuity"]
control_command_success_rate: 1
Irregular state detected. Attempting automatic error recovery.
Segmentation fault (core dumped)
Thanks a lot for your fantastic work!
I want to modify and fine-tune some C++ code but cannot figure out how to build and install from the source.
Could you please write a simple guidance of how to build and install the panda_py from the source code?
update: I successfully build the _core.so
and libfranka.so
, and use make install
to install the .so
file, but how to make and install the python library? Currently I can not import panda_py
from my own project.
Many thanks.
this demo failed and raise:
Control loop interruped: libfranka: Move command aborted: motion aborted by reflex! ["power_limit_violation"]
control_command_success_rate: 1
Irregular state detected. Attempting automatic error recovery.
it seems the function "move_to_pose()" don't work well, franka interupted when i test this function alone.
Hi!
Is there any way of exceeding the 2m/s limit on cartesian velocity of the end effector using panda-py?
There is some issue with the ik solver in the move_to_pose function. Given a position that is not hard to reach, it will give me ik solver failed error. However, I use another ik solver to get the joint position, and then use the set joint position function, the robot can reach the desired position.
First of all really good work Jean!! Thanks a lot for this repo.
Secondly, have you looked at porting the Active Controllers that was introduced with libfranka v0.13.0? It enables user to control without the need for the callback function.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.