Giter Site home page Giter Site logo

justagist / panda_robot Goto Github PK

View Code? Open in Web Editor NEW
75.0 3.0 17.0 33.75 MB

A ROS python interface for using the franka robot (requires franka_ros_interface). Simplified control and management API.

Home Page: https://justagist.github.io/panda_robot

License: Apache License 2.0

CMake 1.44% Python 98.56%
panda-robot-api panda-robot franka-panda-api franka-panda-python franka-ros

panda_robot's Introduction

Panda Robot Python 2.7, 3.6+ ROS Version

PyPI Codacy Badge

A Python interface package built over the Franka ROS Interface package, combining its different classes to provide a unified interface for controlling and handling the Franka Emika Panda robot. Also works directly with Panda Simulator.

The package provides an extensive and unified API for controlling and managing the Franka Emika Robot (and gripper) using pre-defined low-level controllers (position, velocity, torque, joint impedance), MoveIt planners, and JointTrajectory action service.

NOTE: This version requires Franka ROS Interface v0.7.1 ('master'/'v0.7.1-dev' branch) to be installed. For usage with older versions, use Panda Robot branch v0.6.0 from Github.

Features

  • Provides simple-intuitive interface classes with methods to directly and easily control the robot using low-level controllers, MoveIt planners, or Trajectory action client.
  • Get real-time robot state, joint state, controller state, kinematics, dynamics, etc.
  • Provides Kinematics computation (using KDL library). Automatically adjusts computations for the end-effector frames set in Dash or by code.
  • Integrated with gripper control.
  • Manage frames transformation and controller switching using simple utility functions.
  • Works directly on simulated robot when using Panda Simulator providing direct sim-to-real and real-to-sim code transfer.

DOCUMENTATION: https://justagist.github.io/panda_robot/

vid Watch video here

vid Watch video here

Installation

NOTE: This branch should work with ROS Melodic and ROS Noetic. Tested on:

ROS Version Required Python Version
Melodic 2.7+
Noetic 3.6+

The following dependencies have to be met before installing PandaRobot:

  • Requires ROS Melodic or Noetic (preferably the desktop-full version to cover all dependencies such as PyKDL and MoveIt)

  • Franka ROS Interface package. This package should be installed from source (v0.7.1 or master branch) following all instructions in the Installation section. Installing this package correctly would also resolve all the other dependencies for PandaRobot.

Once the dependencies are installed, the package can be installed either from pypi, or by building from source. Note that the installation may be successful even if the above dependencies are not met, but the package cannot be used until the dependencies are installed.

Install with pip

PyPI

pip install panda-robot

NOTE: This will not check for the required ROS dependencies. They have to be installed as described in the previous section.

Build from source

If you want to install the package from source, you can either clone this repository and run python setup.py install, or build it as a catkin package in your ROS workspace. To build as catkin package:

  • Clone this repo to src folder of your catkin workspace.

  • In catkin workspace root, run:

 catkin build
 source devel/setup.bash

Note: This package is written to be compatible with both Python 2 and 3, so make sure you have the Python future module installed (pip install future).

Usage

Note: If using with a real physical Franka Emika Panda robot, the franka_ros_interface 'driver' should be running in the 'master' environment in one terminal (See Franka ROS Interface instructions for details). Then, any code which uses PandaRobot or Franka ROS Interface should be run in 'master' or 'remote' environment (as appropriate). When using with Panda Simulator, this package can be used directly without the need for any specific environment as long as this package, the simulator package, and Franka ROS Interface packages are in the same ROS workspace, and correctly sourced.

Example: Testing interface in terminal

>> python # or `python3` # start interactive python session; make sure the correct ros workspace is sourced.
>> import rospy
>> from panda_robot import PandaArm
>> rospy.init_node("panda_demo") # initialise ros node

>> r = PandaArm() # create PandaArm instance

>> r.move_to_neutral() # moves robot to neutral pose; uses moveit if available, else JointTrajectory action client

>> pos,ori = r.ee_pose() # get current end-effector pose (3d position and orientation quaternion of end-effector frame in base frame)

>> r.get_gripper().home_joints() # homes gripper joints
>> r.get_gripper().open() # open gripper

>> r.move_to_joint_position([-8.48556818e-02, -8.88127666e-02, -6.59622769e-01, -1.57569726e+00, -4.82374882e-04,  2.15975946e+00,  4.36766917e-01]) # move robot to the specified pose

>> r.move_to_cartesian_pose(pos,ori) # move the robot end-effector to pose specified by 'pos','ori'

See script (test/test_pos_controllers.py) to see how the robot can be controlled using low-level joint controllers.

See script (scripts/env.py), and run it interactively (python -i env.py) for testing other available functionalities.

See other files in the tests and demos directories for more usage examples.

Learn about all available functionalities in the Documentation.

License

License

Copyright (c) 2019-2021, Saif Sidhik

If you use this software for research, please considering citing using DOI.

panda_robot's People

Contributors

ch3ri0ur avatar justagist avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

panda_robot's Issues

AttributeError: 'PandaArm' object has no attribute '_joint_names'

All package is the newest version.

When I run
r = PandaArm()
It shows this error.

RobotParam: get_robot_name cannot detect robot name under param /robot_config/arm_id
RobotParam: get_joint_names cannot detect joint_names for arm
RobotParam: get_joint_limits cannot detect robot joint velocity limits under param /robot_config/joint_config/joint_velocity_limit
RobotParam: get_joint_limits cannot detect robot joint position lower limits under param /robot_config/joint_config/joint_position_limit/lower
RobotParam: get_joint_limits cannot detect robot joint position upper limits under param /robot_config/joint_config/joint_position_limit/upper
RobotParam: get_joint_limits cannot detect robot joint torque limits under param /robot_config/joint_config/joint_effort_limit
RobotParam: get_joint_limits cannot detect robot joint acceleration limits under param /robot_config/joint_config/joint_acceleration_limit
PandaArm: Cannot detect joint names for arm on this robot. Exiting Arm.init().
Traceback (most recent call last):
File "", line 1, in
File "/home/rex/.local/lib/python3.8/site-packages/panda_robot/panda_robot.py", line 84, in init
for i in range(len(self.joint_names()))]
File "/home/rex/catkin_ws/src/franka_ros_interface/franka_interface/src/franka_interface/arm.py", line 274, in joint_names
return self._joint_names
AttributeError: 'PandaArm' object has no attribute '_joint_names'

AttributeError: 'PandaArm' object has no attribute 'set_EE_frame_to_link'

I am using
Panda_robot v0.6.0;
Panda_simulator melodic;
franka_ros_interface v0.6.0
libfranka 0.7.0
franka_ros 0.6.0

when I do

python # start interactive python session; make sure the correct ros workspace is sourced.
import rospy
from panda_robot import PandaArm
rospy.init_node("panda_demo") # initialise ros node

r = PandaArm() # create PandaArm instance

It shows the error:

r = PandaArm()
[INFO] [1618014242.316671, 112.310000]: Robot control running in Simulation Mode!
[INFO] [1618014242.464641, 112.417000]: Waiting for collision behaviour services...
[INFO] [1618014243.702680, 113.336000]: PandaArm: Collision Service Not found. It will not be possible to change collision behaviour of robot!
[INFO] [1618014243.740938, 113.366000]: FrankaControllerManagerInterface: cannot detect controller name under param /controllers_config/trajectory_controller
[INFO] [1618014243.756567, 113.376000]: FrankaControllerManagerInterface: cannot detect controller name under param /controllers_config/impedance_controller
[INFO] [1618014243.882530, 113.479000]: PandaArm: MoveGroup was not found! This is okay if moveit service is not required!
[INFO] [1618014243.985199, 113.552000]: GripperInterface: Waiting for gripper action servers...
[INFO] [1618014243.998065, 113.557000]: GripperInterface: Gripper action servers found!
Unknown tag "hardwareInterface" in /robot[@name='panda']/transmission[@name='panda_tran_1']/actuator[@name='panda_motor_1']
Unknown tag "hardwareInterface" in /robot[@name='panda']/transmission[@name='panda_tran_2']/actuator[@name='panda_motor_2']
Unknown tag "hardwareInterface" in /robot[@name='panda']/transmission[@name='panda_tran_3']/actuator[@name='panda_motor_3']
Unknown tag "hardwareInterface" in /robot[@name='panda']/transmission[@name='panda_tran_4']/actuator[@name='panda_motor_4']
Unknown tag "hardwareInterface" in /robot[@name='panda']/transmission[@name='panda_tran_5']/actuator[@name='panda_motor_5']
Unknown tag "hardwareInterface" in /robot[@name='panda']/transmission[@name='panda_tran_6']/actuator[@name='panda_motor_6']
Unknown tag "hardwareInterface" in /robot[@name='panda']/transmission[@name='panda_tran_7']/actuator[@name='panda_motor_7']
Unknown tag "hardwareInterface" in /robot[@name='panda']/transmission[@name='panda_leftfinger']/actuator[@name='panda_finger_joint1']
Unknown tag "hardwareInterface" in /robot[@name='panda']/transmission[@name='panda_rightfinger']/actuator[@name='panda_finger_joint2']
Traceback (most recent call last):
File "", line 1, in
File "/home/sission/proj_ws/src/panda_robot/src/panda_robot/panda_robot.py", line 107, in init
self.set_EE_frame_to_link('panda_hand' if self.has_gripper else 'panda_link8')
AttributeError: 'PandaArm' object has no attribute 'set_EE_frame_to_link'

Problem at during switching controllers

Hi, thanks for your great work!

Recently I'm struggling with a problem related to switching controller.

As you can see, in below codes,

  1. we use position controller to move the robot to initial position.
  2. send torque commands for certain time steps.
  3. if robot is disabled during torque commands execution, enable the robot and move it to initial position again.
    code3

However, an error occurs when the robot enabled again. After robot is enabled, it tries to swtich a controller from 'franka_ros_interface/effort_joint_torque_controller' to 'position_joint_trajectory controller'. A torque controller is successfully stopped, but position_joint_trajectory_controller exists in the active controller list. This causes an assertion error because only one controller should be in active controller list.
ERROR1

In the terminal that we launched interface.launch we observed that it tries to switch controller from 'effort_joint_torque_controller' to ''. We couldn't find why this happens.
ERROR2

Thanks in advance.

ImportError: PyKDL

Hi! I'm trying to use the panda_robot package, however when it comes to import PyKDL I have the following problem:

from panda_robot import PandaArm
File "/home/cmeo/Desktop/catkin_panda_robot_py/devel/lib/python2.7/dist-packages/panda_robot/init.py", line 34, in
exec(__fh.read())
File "", line 18, in
File "/home/cmeo/Desktop/catkin_panda_robot_py/src/panda_robot/src/panda_robot/panda_kinematics.py", line 28, in
import PyKDL
ImportError: /home/cmeo/Desktop/catkin_panda_robot_py/devel/lib/python2.7/dist-packages/PyKDL.so: undefined symbol: _Py_ZeroStruct

What should I do?

This is the building output:

Profile: default
Extending: [env] /opt/ros/melodic
Workspace: /home/cmeo/Desktop/catkin_panda_robot_py

Build Space: [exists] /home/cmeo/Desktop/catkin_panda_robot_py/build
Devel Space: [exists] /home/cmeo/Desktop/catkin_panda_robot_py/devel
Install Space: [unused] /home/cmeo/Desktop/catkin_panda_robot_py/install
Log Space: [missing] /home/cmeo/Desktop/catkin_panda_robot_py/logs
Source Space: [exists] /home/cmeo/Desktop/catkin_panda_robot_py/src
DESTDIR: [unused] None

Devel Space Layout: linked
Install Space Layout: None

Additional CMake Args: None
Additional Make Args: None
Additional catkin Make Args: None
Internal Make Job Server: True
Cache Job Environments: False

Whitelisted Packages: None
Blacklisted Packages: None

Workspace configuration appears valid.

[build] Found '17' packages in 0.0 seconds.
[build] Updating package table.
Warning: generated devel space setup files have been deleted.
Starting >>> catkin_tools_prebuild
Finished <<< catkin_tools_prebuild [ 1.5 seconds ]
Starting >>> franka_core_msgs
Starting >>> franka_moveit
Starting >>> franka_panda_description
Starting >>> orocos_kdl
Starting >>> panda_hardware_interface
Starting >>> panda_sim_moveit
Finished <<< panda_sim_moveit [ 1.5 seconds ]
Finished <<< panda_hardware_interface [ 1.6 seconds ]
Finished <<< franka_panda_description [ 1.5 seconds ]
Finished <<< franka_moveit [ 1.8 seconds ]
Finished <<< franka_core_msgs [ 2.6 seconds ]
Starting >>> franka_interface
Starting >>> franka_ros_controllers
Starting >>> panda_sim_controllers
Finished <<< orocos_kdl [ 9.7 seconds ]
Starting >>> python_orocos_kdl


Warnings << python_orocos_kdl:cmake /home/cmeo/Desktop/catkin_panda_robot_py/logs/python_orocos_kdl/build.cmake.000.log
CMake Warning (dev) at /usr/src/googletest/CMakeLists.txt:3 (project):
Policy CMP0048 is not set: project() command manages VERSION variables.
Run "cmake --help-policy CMP0048" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.

The following variable(s) would be set to empty:

PROJECT_VERSION
PROJECT_VERSION_MAJOR
PROJECT_VERSION_MINOR
PROJECT_VERSION_PATCH

This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at /usr/src/googletest/googlemock/CMakeLists.txt:40 (project):
Policy CMP0048 is not set: project() command manages VERSION variables.
Run "cmake --help-policy CMP0048" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.

The following variable(s) would be set to empty:

PROJECT_VERSION
PROJECT_VERSION_MAJOR
PROJECT_VERSION_MINOR
PROJECT_VERSION_PATCH

This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at /usr/src/googletest/googletest/CMakeLists.txt:47 (project):
Policy CMP0048 is not set: project() command manages VERSION variables.
Run "cmake --help-policy CMP0048" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.

The following variable(s) would be set to empty:

PROJECT_VERSION
PROJECT_VERSION_MAJOR
PROJECT_VERSION_MINOR
PROJECT_VERSION_PATCH

This warning is for project developers. Use -Wno-dev to suppress it.

cd /home/cmeo/Desktop/catkin_panda_robot_py/build/python_orocos_kdl; catkin build --get-env python_orocos_kdl | catkin env -si /usr/bin/cmake /home/cmeo/Desktop/catkin_panda_robot_py/src/orocos_kinematics_dynamics/python_orocos_kdl --no-warn-unused-cli -DCATKIN_DEVEL_PREFIX=/home/cmeo/Desktop/catkin_panda_robot_py/devel/.private/python_orocos_kdl -DCMAKE_INSTALL_PREFIX=/home/cmeo/Desktop/catkin_panda_robot_py/install; cd -
..................................................................................................................................................................
Finished <<< franka_ros_controllers [ 9.3 seconds ]
Finished <<< panda_sim_controllers [ 9.4 seconds ]
Finished <<< franka_interface [ 11.9 seconds ]
Starting >>> franka_tools
Starting >>> panda_robot
Starting >>> panda_sim_custom_action_server
Finished <<< franka_tools [ 1.9 seconds ]
Finished <<< panda_robot [ 1.9 seconds ]
Finished <<< panda_sim_custom_action_server [ 2.2 seconds ]
Starting >>> panda_gazebo
Finished <<< panda_gazebo [ 9.3 seconds ]
Starting >>> panda_simulator_examples
Finished <<< python_orocos_kdl [ 17.3 seconds ]
Finished <<< panda_simulator_examples [ 2.0 seconds ]
[build] Summary: All 16 packages succeeded!
[build] Ignored: 2 packages were skipped or are blacklisted.
[build] Warnings: 1 packages succeeded with warnings.
[build] Abandoned: None.
[build] Failed: None.
[build] Runtime: 29.6 seconds total.

Issues with ik solver when creating a trajectory with a path of EE poses

Hi,

I have a strange issue using the ik solver included in this package. I have a path with end-effector poses generated by a PROMP (paper: http://eprints.lincoln.ac.uk/id/eprint/25785/1/5177-probabilistic-movement-primitives.pdf). However, upon attempting to use the solver to convert each pose to joint angles, the solver doesn't always succeed, despite the path of poses being feasible (it is a replay of a trajectory provided as a demonstration with teleoperation). This means I am unable to plan a full trajectory with my poses, but instead have gaps (some poses are skipped as no solution is found). For instance, in a path with 100 poses, at least half of them failed to produce a valid joint configuration, when using seeding for all except the first pose. The situation is the same when using the neutral position as the seed for the first pose. With this approach, the produced trajectory usually does not resemble the demonstration at all, despite the poses of the demonstration and generated aligning perfectly.

However, I have found a workaround for this, which involves taking each individual pose, requesting an ik solution and executing it immediately using the panda_arm interface using exec_position_cmd. When doing this, there are 0 failures (1 at most). Unfortunately, such an approach means the trajectory cannot be planned nor smoothed before execution.

Any insight into why this is occurring would be super helpful. I can also provide the code I'm using when requesting the ik solutions and also provide json demonstration files if they can be of use.

Thanks!

EDIT: I also noticed this when using a DMP so this issue seems to persist regardless of how the EE poses are generated.

Controlling two robots

Hey @justagist,

First of all, thank you for your effort in providing a ROS / Python interface for the panda robot!

I would like to control two pandas at the same time. What do you think is the easiest way to accomplish the task? Could I e.g. just create a second franka.sh with a different config and run the franka_interface? But how could I connect to a specific robot arm with PandaArm() if two franka_interface are running? Or would I even need to make some adjustments in libfranka or franka-ros?

I would be very thankful for any hints and comments!

AttributeError: 'PandaArm' object has no attribute 'move_to_cartesian_pose'

Franka_ros_interface v0.6.0
Panda_robot v0.6.0

Hi! I know that the function move_to_cartesian_pose() is not in your example.
However, the panda_robot package v0.6.0 did initialized:
franka_interface.ArmInterface.__init__(self)
and franka_ros_interface v0.6.0 did have the function:
def move_to_cartesian_pose(self, pos, ori=None, use_moveit=True)

For what reason I can not call this function?

Quaternion Library

Hello Saif

When I try to import panda_robot it throws me quaternion library error. Even I installed it via pip for python 2.7 it still raise the same error. I tried numpy-quaternion also, still getting the same error. Any suggestion would be highly appreciated.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.