Open
Description
Bug description
- The DQ_ClassicQPController compute_setpoint_control_signal() is throwing a runtime error when it is used with the DQ_DifferentialDriveRobot.
To Reproduce
Code
import numpy as np
from dqrobotics import *
from dqrobotics.robot_modeling import DQ_DifferentialDriveRobot
from dqrobotics.solvers import DQ_QuadprogSolver
from dqrobotics.robot_control import DQ_ClassicQPController, ControlObjective
def main():
mobile_base = DQ_DifferentialDriveRobot(1, 1)
qp_solver = DQ_QuadprogSolver()
mobile_base_controller = DQ_ClassicQPController(mobile_base, qp_solver)
mobile_base_controller.set_control_objective(ControlObjective.Pose)
control_gain = 10.0
mobile_base_controller.set_gain(control_gain)
control_damping = 0.001
mobile_base_controller.set_damping(control_damping)
q = np.array([0.12, 0.0, 0.0])
J = mobile_base.pose_jacobian(q)
x_reference = 1.0
y_reference = 1.0
phi_reference = 0.0
q_reference = np.array([x_reference, y_reference, phi_reference])
print("q_reference")
print(q_reference)
task_reference = mobile_base.fkm(q_reference)
u_qdot = mobile_base_controller.compute_setpoint_control_signal(q, vec8(task_reference))
if __name__ == '__main__':
main()
Output
q_reference
[1. 1. 0.]
Traceback (most recent call last):
File "issues.py", line 36, in <module>
main()
File "issues.py", line 31, in main
u_qdot = mobile_base_controller.compute_setpoint_control_signal(q, vec8(task_reference))
RuntimeError: DQ_DifferentialDriveRobot::pose_jacobian(q,to_link) only accepts to_link in {0,1}.
Expected behavior
- The compute_setpoint_control_signal() should return an array containing the control signal.
Environment:
- OS: Ubuntu 18.04
- dqrobotics version 20.4.0.26
- Python version 3.6.9
Additional context
- This issue is really similar to the last fix of issue [BUG] The pose_jacobian() of DQ_DifferentialDriveRobot is trying to access link index 3 #22 .
- The issue probably happens on line 42 of DQ_QuadraticProgrammingController.cpp when calculating the Jacobian to use in the controller. I have not tested the tracking controller, but it will probably happen on line 82 also.