diff --git a/README.md b/README.md index b6dab6d..fcfcc38 100644 --- a/README.md +++ b/README.md @@ -1,90 +1,56 @@ -# DIANA-TemplateCPP +# Panda-IK

- +

-### v2.0.0 -*Insert here a brief description of the project.*
-DIANA-TemplateCPP is the official C++/Cmake template for DIANA Software repositories. It is intended as a *starting point* for the development of new repositories. It uses advanced CMake functionalities to make the project compliant with the [DIANA Software standard](https://github.com/team-diana/CS-Docs/tree/master/DIANA%20Software/Conventions), to handlefiles, installation and tests. This template is meant to be used in CLion IDE. +Based upon [this work](https://github.com/ffall007/franka_analytical_ik), this shared library provides an easy-to-use interface for the analytical inverse kinematics solver for the Franka Emika Panda robot. The available functionalities are callable from both C++ and Python. A Python example is provided [here](python/example.py). -### Workflows -| | **Build and install** | **Makefile standard commands** | -|----------|----------|-------------------------| -| **Master** | ![MASTER: ccpp.yml](https://github.com/team-diana/DIANA-TemplateCPP/actions/workflows/ccpp.yml/badge.svg?badge.svg?branch=master) |![MASTER: make-standard-commands.yml](https://github.com/team-diana/DIANA-TemplateCPP/actions/workflows/make-standard-commands.yml/badge.svg?branch=master) | -| **Develop** |![DEVELOP: ccpp.yml](https://github.com/team-diana/DIANA-TemplateCPP/actions/workflows/ccpp.yml/badge.svg?branch=develop) | ![MASTER: make-standard-commands.yml](https://github.com/team-diana/DIANA-TemplateCPP/actions/workflows/make-standard-commands.yml/badge.svg?branch=develop) | +## Installation -## Description -Insert here some detailed description about your software. Here are some suggestions: -- **Library**: *How to include in Cmake? What are the main functions of the library? How do they work? Simple code examples* -- **Program**: *How does it work? How to use it ? Program arguments ? What are the Mqtt topics it uses? Are there any ShmemKeys? Does it have particular dependencies?* -- **Service**: How does it work? Is it possible to use it as standalone? Does it have dependencies? Are there arguments to pass in the standalone version? - -*In general, think as you were the user, and not a developer: what are the info you will need to start using your modules as fast as possible?* -*Also, remember to provide links to documentation (Cs docs) and external information, if needed.* -## Make Targets -### Install Dependencies - -#### Configure - -```bash +``` +git clone git@github.com:Anatr1/panda-IK.git +cd panda-IK make configure +make build +make install ``` -### Build project -#### Generate Makefiles/Cmake Project -```bash -make generate -``` -#### Clean (deletes build folder) +## Usage -```bash -make clean -``` +### C++ -#### Build project - debug configuration +To obtain an array of doubles corresponding to the joint angles of the robot for a given end-effector pose, use the following function: -```bash -make build -``` +```cpp +#include -#### Build project - Release configuration +// ... -```bash -make release -``` -### Install, uninstall, test and others -#### Install built project +std::array result = compute_inverse_kinematics(array xyzrpy, array q_actual); -```bash -make install -``` -#### Uninstall built project -Cleans all the files installed by the project. -```bash -make uninstall ``` +```xyzrpy``` is an array of doubles containing the desired end-effector pose in the format [x, y, z, roll, pitch, yaw]. ```q_actual``` is an array of doubles containing the current joint angles of the robot. ```result``` will contain the solution, if any, for the given input. If no solution is found, the function will return the current joint angles of the robot. -#### Run Tests +### Python -```bash -make test -``` +To obtain an array of doubles corresponding to the joint angles of the robot for a given end-effector pose, use the following function: -#### Generate Doxygen documentation +```python +import ctypes -```bash -make docs -``` +# Load the shared library +pandaik_lib = ctypes.CDLL('/usr/local/diana/lib/libPanda-IK.so') -### Other makefile targets -Set here, if needed, "custom" make targets for the project. -### Run ExampleProgram +# Define the argument types and return type +pandaik_lib.compute_inverse_kinematics_void.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double)] +pandaik_lib.compute_inverse_kinematics_void.restype = None -```bash -make run_ExampleProgram -``` -### Run ExampleService (as a standalone) +xyzrpy = (ctypes.c_double * 6)(X, Y, Z, ROLL, PITCH, YAW) +q_actual = (ctypes.c_double * 7)(Q1, Q2, Q3, Q4, Q5, Q6, Q7) +output = (ctypes.c_double * 7)() -```bash -make run_ExampleService +# Call a function from the library +pandaik_lib.compute_inverse_kinematics_void(xyzrpy, q_actual, output) ``` + +```X, Y, Z, ROLL, PITCH, YAW``` are the desired end-effector pose. ```Q1, Q2, Q3, Q4, Q5, Q6, Q7``` are the current joint angles of the robot. ```output``` will contain the solution, if any, for the given input. If no solution is found, the function will return the current joint angles of the robot. diff --git a/assets/panda_ik.gif b/assets/panda_ik.gif new file mode 100644 index 0000000..e3a2b0a Binary files /dev/null and b/assets/panda_ik.gif differ diff --git a/python/example.py b/python/example.py index f4250b6..111ea66 100644 --- a/python/example.py +++ b/python/example.py @@ -12,6 +12,6 @@ output = (ctypes.c_double * 7)() # Call a function from the library -result = pandaik_lib.compute_inverse_kinematics_void(xyzrpy, q_actual, output) +pandaik_lib.compute_inverse_kinematics_void(xyzrpy, q_actual, output) print("Result from C++:", list(output)) # Assuming the function returns an array of 7 doubles # Should print: Result from C++: [0.8867046650124633, -1.3398493172549706, -0.7760786149655098, -2.652291962842672, 2.2357825028981364, 2.737863867200816, 0.0]