Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LANGUAGE INCOMPATIBILITY] Missing default value for damping in DQ_ClassicQPController for Python #59

Closed
anachristinaac opened this issue Jul 30, 2024 · 2 comments
Assignees
Labels
language incompatibility Something is incompatible between languages

Comments

@anachristinaac
Copy link

anachristinaac commented Jul 30, 2024

Description of the missing/unexpected functionality

When using the DQ_ClassicQPController, the MATLAB version defines a default value (0.001) for the damping variable, but the Python version does not.

Python behavior

PYTHON SCRIPT

from dqrobotics import *
from dqrobotics.solvers import DQ_QuadprogSolver
from dqrobotics.robot_control import DQ_ClassicQPController
from dqrobotics.robots import KukaLw4Robot

robot = KukaLw4Robot.kinematics()
solver = DQ_QuadprogSolver()
controller = DQ_ClassicQPController(robot, solver)
print(controller.get_damping())

PYTHON OUTPUT

7.73974598944389e+228

Matlab behavior

MATLAB SCRIPT

robot = KukaLwr4Robot.kinematics();
solver = DQ_QuadprogSolver;
controller = DQ_ClassicQPController(robot, solver);
controller.get_damping()

MATLAB OUTPUT

1.0000e-03

Environment:

  • OS: Ubuntu 22.04.4 LTS
  • dqrobotics version MATLAB: commit e455c66
  • MATLAB version: R2023b
  • dqrobotics version Python: 23.4.0a22
  • Python version: 3.10.12
@anachristinaac anachristinaac added the language incompatibility Something is incompatible between languages label Jul 30, 2024
@juanjqo
Copy link
Member

juanjqo commented Jul 31, 2024

@anachristinaac thank you for letting us know! It looks like it is an issue in the C++ version.

@mmmarinho I proposed a PR in C++ to fix this language incompatibility. I tested both C++ and Python locally.

Minimal example:

from dqrobotics.solvers import DQ_QuadprogSolver
from dqrobotics.robot_control import DQ_ClassicQPController
from dqrobotics.robots import KukaLw4Robot


def main() -> None:
    robot = KukaLw4Robot.kinematics()
    solver = DQ_QuadprogSolver()
    controller = DQ_ClassicQPController(robot, solver)
    print(controller.get_damping())


if __name__ == "__main__":
    main()

Output:

0.001
#include <iostream>
#include <dqrobotics/robots/KukaLw4Robot.h>
#include <dqrobotics/robot_control/DQ_ClassicQPController.h>
#include <dqrobotics/solvers/DQ_PROXQPSolver.h>

using namespace DQ_robotics;


int main()
{
    auto robot = std::make_shared<DQ_SerialManipulatorDH>(KukaLw4Robot::kinematics());
    auto solver = std::make_shared<DQ_PROXQPSolver>();
    auto controller = DQ_ClassicQPController(robot, solver);
    auto damping = controller.get_damping();
    std::cout<<damping<<std::endl;
}

Output:

0.001

mmmarinho pushed a commit to dqrobotics/cpp that referenced this issue Sep 26, 2024
… the Matlab. (See #67 and dqrobotics/python#59)

* [DQ_KinematicController.h] Initialized some variables to match the Matlab implementation

* [DQ_ClassicQPController.cpp] Added a default damping to match the DQ_ClassicQPController.m class

* [DQ_KinematicController.h] Removed from the header the initialization of variables that are initialized in the constructor

* [DQ_KinematicController.cpp] Added the initialization of the damping attribute in the constructor. In addition, I fixed the initialization order of the attributes last control and last error signal.

* Revert "[DQ_KinematicController.h] Initialized some variables to match the Matlab implementation"

This reverts commit 378c3f4.
@mmmarinho
Copy link
Member

Fixed with dqrobotics/cpp#67.

If needed, please re-open the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language incompatibility Something is incompatible between languages
Projects
None yet
Development

No branches or pull requests

3 participants