├── hiqp_core
├── README.md
├── CHANGELOG.rst
├── rosdoc.yaml
├── package.xml
├── FindCASADI.cmake
├── include
│ └── hiqp
│ │ ├── solvers
│ │ ├── casadi_solver.h
│ │ ├── gurobi_solver__original.h
│ │ └── gurobi_solver.h
│ │ ├── hiqp_time_point.h
│ │ ├── tasks
│ │ ├── tdef_full_pose.h
│ │ ├── tdef_jnt_config.h
│ │ ├── tdyn_cubic.h
│ │ ├── tdyn_linear.h
│ │ ├── tdef_jnt_limits.h
│ │ ├── tdyn_jnt_limits.h
│ │ ├── tdyn_hyper_sin.h
│ │ ├── tdyn_minimal_jerk.h
│ │ ├── tdef_geometric_alignment.h
│ │ └── tdef_geometric_projection.h
│ │ ├── geometric_primitives
│ │ ├── geometric_primitive_visitor.h
│ │ ├── geometric_primitive_couter.h
│ │ ├── geometric_primitive.h
│ │ ├── geometric_point.h
│ │ ├── geometric_sphere.h
│ │ ├── geometric_plane.h
│ │ ├── geometric_primitive_map.h
│ │ ├── geometric_line.h
│ │ ├── geometric_primitive_visualizer.h
│ │ ├── geometric_cylinder.h
│ │ └── geometric_frame.h
│ │ ├── robot_state.h
│ │ ├── visualizer.h
│ │ ├── task_dynamics.h
│ │ ├── task_definition.h
│ │ ├── utilities.h
│ │ ├── task.h
│ │ ├── task_manager.h
│ │ └── hiqp_solver.h
├── src
│ ├── tasks
│ │ ├── tdyn_linear.cpp
│ │ ├── tdyn_jnt_limits.cpp
│ │ ├── tdyn_hyper_sin.cpp
│ │ ├── tdyn_cubic.cpp
│ │ ├── tdef_jnt_config.cpp
│ │ ├── tdyn_minimal_jerk.cpp
│ │ ├── tdef_full_pose.cpp
│ │ ├── tdef_jnt_limits.cpp
│ │ └── tdef_geometric_alignment.cpp
│ ├── hiqp_time_point.cpp
│ └── solvers
│ │ └── casadi_solver.cpp
└── CMakeLists.txt
├── hiqp_ros
├── README.md
├── CHANGELOG.rst
├── rosdoc.yaml
├── plugins.xml
├── package.xml
├── include
│ └── hiqp_ros
│ │ ├── utilities.h
│ │ ├── ros_topic_subscriber.h
│ │ ├── hiqp_joint_effort_controller.h
│ │ ├── hiqp_joint_velocity_controller.h
│ │ ├── ros_visualizer.h
│ │ └── hiqp_service_handler.h
├── CMakeLists.txt
└── src
│ └── utilities.cpp
├── hiqp_msgs
├── README.md
├── CHANGELOG.rst
├── msg
│ ├── StringArray.msg
│ ├── Vector3d.msg
│ ├── TaskMeasures.msg
│ └── TaskMeasure.msg
├── package.xml
├── srv
│ ├── ListAllTasks.srv
│ ├── ListAllPrimitives.srv
│ ├── RemoveAllTasks.srv
│ ├── RemoveAllPrimitives.srv
│ ├── RemoveTask.srv
│ ├── RemovePrimitive.srv
│ ├── ActivateTask.srv
│ ├── ActivatePriorityLevel.srv
│ ├── DeactivateTask.srv
│ ├── DeactivatePriorityLevel.srv
│ ├── MonitorTask.srv
│ ├── RemovePriorityLevel.srv
│ ├── DemonitorTask.srv
│ ├── MonitorPriorityLevel.srv
│ ├── DemonitorPriorityLevel.srv
│ ├── SetPrimitive.srv
│ └── SetTask.srv
└── CMakeLists.txt
├── hiqp
├── CHANGELOG.rst
├── CMakeLists.txt
└── package.xml
├── .gitignore
└── README.md
/hiqp_core/README.md:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework
2 | Copyright (C) 2016 Marcus A Johansson
--------------------------------------------------------------------------------
/hiqp_ros/README.md:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework
2 | Copyright (C) 2016 Marcus A Johansson
3 |
--------------------------------------------------------------------------------
/hiqp_msgs/README.md:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework
2 | Copyright (C) 2016 Marcus A Johansson
3 |
--------------------------------------------------------------------------------
/hiqp/CHANGELOG.rst:
--------------------------------------------------------------------------------
1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | Changelog for package hiqp
3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
4 |
5 |
--------------------------------------------------------------------------------
/hiqp_ros/CHANGELOG.rst:
--------------------------------------------------------------------------------
1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | Changelog for package hiqp_ros
3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 |
5 |
--------------------------------------------------------------------------------
/hiqp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.3)
2 | project(hiqp)
3 | find_package(catkin REQUIRED)
4 | catkin_metapackage()
5 |
--------------------------------------------------------------------------------
/hiqp_core/CHANGELOG.rst:
--------------------------------------------------------------------------------
1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | Changelog for package hiqp_core
3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 |
5 |
--------------------------------------------------------------------------------
/hiqp_msgs/CHANGELOG.rst:
--------------------------------------------------------------------------------
1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | Changelog for package hiqp_msgs
3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 |
5 |
--------------------------------------------------------------------------------
/hiqp_ros/rosdoc.yaml:
--------------------------------------------------------------------------------
1 | - builder: doxygen
2 | name: C++ API
3 | output_dir: c++
4 | file_patterns: '*.c *.cpp *.h *.cc *.hh *.dox'
5 |
--------------------------------------------------------------------------------
/hiqp_core/rosdoc.yaml:
--------------------------------------------------------------------------------
1 | - builder: doxygen
2 | name: C++ API
3 | output_dir: c++
4 | file_patterns: '*.c *.cpp *.h *.cc *.hh *.dox'
5 |
--------------------------------------------------------------------------------
/hiqp_ros/plugins.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 | The HiQPJointVelocityController generates velocity commands for a set of joints. It expects a VelocityJointInterface type of hardware interface.
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/hiqp/package.xml:
--------------------------------------------------------------------------------
1 |
2 | hiqp
3 | 0.0.1
4 |
5 |
6 | The HiQP Control Framework (including ROS support).
7 |
8 |
9 | Marcus A Johansson
10 | Marcus A Johansson
11 |
12 | GPLv3
13 |
14 | https://github.com/neckutrek/hiqp
15 |
16 | catkin
17 |
18 | hiqp_core
19 | hiqp_msgs
20 | hiqp_ros
21 | hiqp_examples
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/hiqp_msgs/msg/StringArray.msg:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | string[] params
--------------------------------------------------------------------------------
/hiqp_msgs/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | hiqp_msgs
4 | 0.0.1
5 | Messages and services for the HiQP Control Framework
6 |
7 | Marcus A Johansson
8 | Marcus A Johansson
9 |
10 | GPLv3
11 |
12 | catkin
13 | message_generation
14 | geometry_msgs
15 | std_msgs
16 | visualization_msgs
17 |
18 | visualization_msgs
19 | std_msgs
20 | geometry_msgs
21 | message_runtime
22 |
23 |
--------------------------------------------------------------------------------
/hiqp_msgs/srv/ListAllTasks.srv:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | ---
18 | bool success # is always true
--------------------------------------------------------------------------------
/hiqp_msgs/srv/ListAllPrimitives.srv:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | ---
18 | bool success # is always true
--------------------------------------------------------------------------------
/hiqp_msgs/msg/Vector3d.msg:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | float64 val1
18 | float64 val2
19 | float64 val3
--------------------------------------------------------------------------------
/hiqp_msgs/srv/RemoveAllTasks.srv:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | ---
18 | bool success # true upon successful removal of all tasks
--------------------------------------------------------------------------------
/hiqp_msgs/srv/RemoveAllPrimitives.srv:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | ---
18 | bool success # true upon successful removal of all primitives
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.sublime-*
2 | .Rhistory
3 |
4 | # Backup and data files
5 | eg/eg.*
6 | *~
7 | *.autosave
8 | *.bak
9 | *.off
10 | *.x
11 | x.*
12 |
13 | */doxygen
14 |
15 | */doc
16 |
17 | # patch results
18 | *.rej
19 |
20 | # Build products
21 | tmp/*
22 | build/Makefile*
23 | build/CMakeFiles
24 | build/CMakeCache.txt
25 | build/*/Makefile*
26 | build/*/object_script*
27 | build/*/Release/*
28 | build/*/Debug/*
29 | build/*/MinSizeRel/*
30 | build/*/RelWithDebInfo/*
31 | build
32 |
33 | *#
34 | *.#
35 | *.zip
36 | *.a
37 | *.dll
38 | *.lib
39 | *.exe
40 | *.bag
41 | *.o
42 | *.md5sum
43 |
44 | # Qt files
45 | *.pro.user
46 |
47 | # DevStudio files
48 | *.bsc
49 | *.ncb
50 | *.pdb
51 | *.suo
52 | *.user
53 | *.ilk
54 |
55 | # CVS files
56 | CVS/*
57 | */CVS/*
58 | */*/CVS/*
59 | */*/*/CVS/*
60 | *.cvsignore
61 |
62 | # Other files
63 | working/
64 | Status API Training Shop Blog About
65 | © 2014 GitHub, Inc. Terms Privacy Security Contact
66 |
--------------------------------------------------------------------------------
/hiqp_msgs/srv/RemoveTask.srv:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | string name # unique task identifier
18 | ---
19 | bool success # true upon successful removal
--------------------------------------------------------------------------------
/hiqp_msgs/srv/RemovePrimitive.srv:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | string name # unique primitive identifier
18 | ---
19 | bool success # true upon successful removal
--------------------------------------------------------------------------------
/hiqp_msgs/msg/TaskMeasures.msg:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | time stamp # time stamp of this monitoring data set
18 | TaskMeasure[] task_measures # array of task measures
--------------------------------------------------------------------------------
/hiqp_msgs/srv/ActivateTask.srv:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | string name # name of the task to be activated
18 | ---
19 | bool success # true if activation was successful
20 |
--------------------------------------------------------------------------------
/hiqp_msgs/srv/ActivatePriorityLevel.srv:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | uint16 priority # priority level to activate
18 | ---
19 | bool success # true if activation was successful
20 |
--------------------------------------------------------------------------------
/hiqp_msgs/srv/DeactivateTask.srv:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | string name # name of the task to be deactivated
18 | ---
19 | bool success # true if deactivation was successful
20 |
--------------------------------------------------------------------------------
/hiqp_msgs/srv/DeactivatePriorityLevel.srv:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | uint16 priority # priority level to deactivate
18 | ---
19 | bool success # true if deactivation was successful
20 |
--------------------------------------------------------------------------------
/hiqp_msgs/srv/MonitorTask.srv:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | string name # name of the task to be monitored
18 | ---
19 | bool success # true if monitor activation was successful
20 |
--------------------------------------------------------------------------------
/hiqp_msgs/srv/RemovePriorityLevel.srv:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | uint16 priority # priority level of the tasks to be removed
18 | ---
19 | bool success # true upon successful removal of all primitives
--------------------------------------------------------------------------------
/hiqp_msgs/srv/DemonitorTask.srv:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | string name # name of the task to be demonitored
18 | ---
19 | bool success # true if monitoring deactivation was successful
20 |
--------------------------------------------------------------------------------
/hiqp_msgs/srv/MonitorPriorityLevel.srv:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | uint16 priority # priority level to activate monitoring for
18 | ---
19 | bool success # true if activation of monitoring was successful
20 |
--------------------------------------------------------------------------------
/hiqp_msgs/srv/DemonitorPriorityLevel.srv:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | uint16 priority # priority level to deactivate monitoring for
18 | ---
19 | bool success # true if deactivation of monitoring was successful
20 |
--------------------------------------------------------------------------------
/hiqp_msgs/srv/SetPrimitive.srv:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | string name
18 | string type
19 | string frame_id
20 | bool visible
21 | float64[] color
22 | float64[] parameters
23 | ---
24 | bool success
--------------------------------------------------------------------------------
/hiqp_core/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | hiqp_core
4 | 0.0.1
5 | The HiQP Control Framework
6 |
7 | Marcus A Johansson
8 | Marcus A Johansson
9 |
10 | GPLv3
11 |
12 | catkin
13 |
14 | roscpp
15 | cmake_modules
16 | controller_interface
17 | visualization_msgs
18 |
19 | orocos_kdl
20 | kdl_parser
21 | hiqp_msgs
22 |
23 | roscpp
24 | controller_interface
25 | visualization_msgs
26 | orocos_kdl
27 | kdl_parser
28 | hiqp_msgs
29 |
30 |
--------------------------------------------------------------------------------
/hiqp_msgs/msg/TaskMeasure.msg:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | string task_name # unique string identifier for the task
18 | float64[] e # the task performance value at this time step
19 | float64[] de # the task dynamics value at this time step
20 | float64[] pm # the user-defined custom performance monitoring values for thsi task at this time step
21 |
--------------------------------------------------------------------------------
/hiqp_ros/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | hiqp_ros
4 | 0.0.1
5 | The HiQP_Controllers package
6 |
7 | Marcus A Johansson
8 | Marcus A Johansson
9 |
10 | GPLv3
11 |
12 | catkin
13 |
14 | roscpp
15 | cmake_modules
16 | controller_interface
17 | visualization_msgs
18 | orocos_kdl
19 |
20 | hiqp_core
21 | hiqp_msgs
22 |
23 | roscpp
24 | controller_interface
25 | visualization_msgs
26 | orocos_kdl
27 |
28 | hiqp_core
29 | hiqp_msgs
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/hiqp_core/FindCASADI.cmake:
--------------------------------------------------------------------------------
1 | find_path(CASADI_INCLUDE_DIR
2 | casadi/core/sx/sx_elem.hpp
3 | HINTS $ENV{CASADI_PREFIX}/include
4 | )
5 |
6 | if(CASADI_INCLUDE_DIR)
7 | set(CASADI_INCLUDE_DIR ${CASADI_INCLUDE_DIR} ${CASADI_INCLUDE_DIR}/casadi)
8 | set(CASADI_FOUND_INCLUDE TRUE)
9 | message(STATUS "Found CasADi include dir: ${CASADI_INCLUDE_DIR}")
10 | else()
11 | message(STATUS "Could not find CasADi include dir")
12 | endif()
13 |
14 | set(CASADI_LIBS_LIST
15 | casadi_cplex_interface
16 | casadi_nlpsol_ipopt
17 | casadi_lapack_interface
18 | casadi_sundials_interface
19 | casadi_csparse_interface
20 | casadi_knitro_interface
21 | casadi_optimal_control
22 | casadi_integration
23 | casadi_nonlinear_programming
24 | casadi_csparse
25 | casadi_tinyxml
26 | casadi)
27 |
28 | foreach(LIB in ${CASADI_LIBS_LIST})
29 | find_library(CASADI_LIB_${LIB}
30 | NAMES ${LIB}
31 | HINTS ${CASADI_INCLUDE_DIR}/build/lib $ENV{CASADI_PREFIX}/lib)
32 | if(CASADI_LIB_${LIB})
33 | #message(STATUS "Found ${LIB}: ${CASADI_LIB_${LIB}}")
34 | set(CASADI_LIBRARIES ${CASADI_LIBRARIES} ${CASADI_LIB_${LIB}})
35 | else()
36 | #message(STATUS "Could not find lib${LIB}")
37 | endif()
38 | endforeach()
39 |
40 | if(CASADI_LIBRARIES)
41 | message(STATUS "Found CasADi libs: ${CASADI_LIBRARIES}")
42 | else()
43 | message(STATUS "Could not find CasADi libs")
44 | endif()
45 |
46 | if(CASADI_FOUND_INCLUDE AND CASADI_LIBRARIES)
47 | set(CASADI_FOUND TRUE)
48 | endif()
49 |
--------------------------------------------------------------------------------
/hiqp_msgs/srv/SetTask.srv:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | string name # the name to be associated with this task instantiation
18 | uint16 priority # the task priority (1 is highest)
19 | bool visible # whether or not the task should be visible initially
20 | bool active # whether or not the task should be active initially
21 | bool monitored # whether or not the task should be monitored initially
22 | string[] def_params # the task definition name and a list of strings that is passed to the init function of the task class
23 | string[] dyn_params # the name of the task dynamics along with its parameters
24 | ---
25 | bool success # true if the task creation was successful
26 |
--------------------------------------------------------------------------------
/hiqp_ros/include/hiqp_ros/utilities.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_ROS_UTILITIES_H
18 | #define HIQP_ROS_UTILITIES_H
19 |
20 | #include
21 |
22 | #include
23 | #include
24 | #include
25 | //#include
26 | #include
27 | //#include
28 |
29 | std::ostream& operator<<(std::ostream& os, const KDL::Vector& kdl_vector);
30 | std::ostream& operator<<(std::ostream& os, const KDL::Tree& kdl_tree);
31 | std::ostream& operator<<(std::ostream& os, const KDL::FrameVel& kdl_frame_vel);
32 | std::ostream& operator<<(std::ostream& os, const KDL::JntArrayVel& kdl_joints_vel);
33 | std::ostream& operator<<(std::ostream& os, const KDL::Chain& kdl_chain);
34 |
35 | #endif
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/solvers/casadi_solver.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_CASADI_SOLVER_H
18 | #define HIQP_CASADI_SOLVER_H
19 |
20 | #include
21 |
22 | namespace hiqp
23 | {
24 |
25 | /*! \brief An optimization based solver for a set of stages implemented in CasADi.
26 | * \author Marcus A Johansson */
27 | class CasADiSolver : public HiQPSolver {
28 | public:
29 | CasADiSolver() {}
30 | ~CasADiSolver() noexcept {}
31 |
32 | bool solve(std::vector& solution);
33 |
34 | private:
35 | CasADiSolver(const CasADiSolver& other) = delete;
36 | CasADiSolver(CasADiSolver&& other) = delete;
37 | CasADiSolver& operator=(const CasADiSolver& other) = delete;
38 | CasADiSolver& operator=(CasADiSolver&& other) noexcept = delete;
39 | };
40 |
41 | } // namespace hiqp
42 |
43 | #endif // include guard
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/hiqp_time_point.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_TIME_POINT_H
18 | #define HIQP_TIME_POINT_H
19 |
20 | namespace hiqp {
21 |
22 | /*! \brief Represents a time duration in seconds and nanoseconds.
23 | * \author Marcus A Johansson */
24 | class HiQPTimePoint
25 | {
26 | public:
27 | HiQPTimePoint();
28 | HiQPTimePoint(unsigned int sec, unsigned int nsec);
29 | HiQPTimePoint(const HiQPTimePoint& other);
30 | ~HiQPTimePoint();
31 |
32 | double toSec() const;
33 |
34 | inline void setTimePoint(unsigned int sec, unsigned int nsec)
35 | { this->sec_ = sec; this->nsec_ = nsec; }
36 |
37 | inline unsigned int getSec() const { return sec_; }
38 | inline unsigned int getNSec() const { return nsec_; }
39 |
40 | HiQPTimePoint& operator=(const HiQPTimePoint& other);
41 | HiQPTimePoint operator+(const HiQPTimePoint& other) const;
42 | HiQPTimePoint operator-(const HiQPTimePoint& other) const;
43 | HiQPTimePoint& operator+=(const HiQPTimePoint& other);
44 | HiQPTimePoint& operator-=(const HiQPTimePoint& other);
45 |
46 | private:
47 | unsigned int sec_;
48 | unsigned int nsec_;
49 | };
50 |
51 | } // namespace hiqp
52 |
53 | #endif // include guard
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/solvers/gurobi_solver__original.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_GUROBI_SOLVER_H
18 | #define HIQP_GUROBI_SOLVER_H
19 |
20 | #include
21 | #include
22 |
23 | namespace hiqp
24 | {
25 | /*! \brief An optimization based solver for a set of stages implemented in CasADi.
26 | * \author Robert Krug, Marcus A Johansson */
27 | class GurobiSolver : public HiQPSolver {
28 | public:
29 | GurobiSolver();
30 | ~GurobiSolver() noexcept {}
31 |
32 | bool solve(std::vector& solution);
33 |
34 | private:
35 | GurobiSolver(const GurobiSolver& other) = delete;
36 | GurobiSolver(GurobiSolver&& other) = delete;
37 | GurobiSolver& operator=(const GurobiSolver& other) = delete;
38 | GurobiSolver& operator=(GurobiSolver&& other) noexcept = delete;
39 |
40 | void reset();
41 |
42 | GRBEnv env_;
43 | Eigen::VectorXd x_; // HQP solution (updated sequentially when solving)
44 | Eigen::VectorXd w_; // slack variables (updated sequentially when solving)
45 | Eigen::VectorXd b_;
46 | Eigen::MatrixXd A_;
47 | std::vector senses_;
48 | };
49 |
50 | } // namespace hiqp
51 |
52 | #endif // include guard
53 |
--------------------------------------------------------------------------------
/hiqp_core/src/tasks/tdyn_linear.cpp:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #include
18 |
19 | #include
20 |
21 | #include
22 |
23 | namespace hiqp
24 | {
25 | namespace tasks
26 | {
27 |
28 | int TDynLinear::init(const std::vector& parameters,
29 | RobotStatePtr robot_state,
30 | const Eigen::VectorXd& e_initial,
31 | const Eigen::VectorXd& e_final) {
32 | int size = parameters.size();
33 | if (size != 2) {
34 | printHiqpWarning("TDynFirstOrder requires 2 parameters, got "
35 | + std::to_string(size) + "! Initialization failed!");
36 | return -1;
37 | }
38 |
39 | lambda_ = std::stod( parameters.at(1) );
40 |
41 | e_dot_star_.resize(e_initial.rows());
42 | performance_measures_.resize(e_initial.rows());
43 |
44 | return 0;
45 | }
46 |
47 | int TDynLinear::update(RobotStatePtr robot_state,
48 | const Eigen::VectorXd& e,
49 | const Eigen::MatrixXd& J) {
50 | //e_dot_star_.resize(e.size());
51 | e_dot_star_ = -lambda_ * e;
52 | return 0;
53 | }
54 |
55 | int TDynLinear::monitor() {
56 | return 0;
57 | }
58 |
59 | } // namespace tasks
60 |
61 | } // namespace hiqp
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework
2 | Copyright (C) 2016-2017 Marcus A. Johansson
3 |
4 | HiQP is a whole-body control framework for computing inverse kinematics (and dynamics in future releases) involving multiple objectives which can be incompatible. It uses the inequality task function approach in [1] and is based on hierarchical least-squares optimization. Lower-ranked tasks are fulfilled as good as possible (in the least-square sense) in the null-space of higher-ranked tasks. More details are given in [2] - available at http://www.diva-portal.org/smash/get/diva2:1056500/FULLTEXT01.pdf.
5 |
6 | ## Acknowledgements
7 | Robert Krug and Todor Stoyanov at the AASS Research Institute at Örebro University, Sweden, have been important contributors to this project. Thank you.
8 |
9 | ## Upcoming features/changes
10 | - A Wiki/user guide will be created as a tutorial on how to use HiQP with ROS. In the meantime, we refer to the hiqp_demos package for examples of how to use HiQP: git@github.com:OrebroUniversity/hiqp_demos.git
11 | - The list of available service calls will be revised and extended.
12 | - A capsule primitive will be added to the set of geometric primitives.
13 | - The framework will be extended to compute controls on a joint acceleration level in order to enable inverse dynamics control.
14 |
15 | ## Installation note
16 |
17 | HiQP relies on Gurobi to solve Quadratic Programs (QPs). For academic use, a free license can be obtained at http://www.gurobi.com/. Make sure to set the corresponding environment variables as described in http://www.gurobi.com/documentation/6.5/quickstart_linux/software_installation_guid.html.
18 |
19 | ## How to cite HiQP
20 |
21 | A publication presenting HiQP is in preparation. In the meantime, please refer to [2].
22 |
23 |
24 | [1] ... O. Kanoun, F. Lamiraux and P.-B. Wieber, Kinematic control of redundant manipulators: Generalizing the task-priority framework to inequality task. IEEE T-RO, 27(4):785-792, 2011.
25 |
26 | [2] ... M. A. Johansson, Online whole-body control using hierarchical quadratic programming: implementation and evaluation of the HiQP control framework. MSc Thesis, 2016.
27 |
--------------------------------------------------------------------------------
/hiqp_core/src/tasks/tdyn_jnt_limits.cpp:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #include
18 |
19 | #include
20 |
21 | namespace hiqp
22 | {
23 | namespace tasks
24 | {
25 |
26 | int TDynJntLimits::init(const std::vector& parameters,
27 | RobotStatePtr robot_state,
28 | const Eigen::VectorXd& e_initial,
29 | const Eigen::VectorXd& e_final) {
30 | int size = parameters.size();
31 | if (size != 3) {
32 | printHiqpWarning("TDynJntLimits requires 3 parameters, got "
33 | + std::to_string(size) + "! Initialization failed!");
34 | return -1;
35 | }
36 |
37 | e_dot_star_.resize(4);
38 | dq_max_ = std::stod( parameters.at(1) );
39 | gain_ = std::stod( parameters.at(2) );
40 | performance_measures_.resize(0);
41 | return 0;
42 | }
43 |
44 | int TDynJntLimits::update(RobotStatePtr robot_state,
45 | const Eigen::VectorXd& e,
46 | const Eigen::MatrixXd& J) {
47 | e_dot_star_(0) = -dq_max_;
48 | e_dot_star_(1) = dq_max_;
49 | e_dot_star_(2) = -gain_ * e(2);
50 | e_dot_star_(3) = -gain_ * e(3);
51 | return 0;
52 | }
53 |
54 | int TDynJntLimits::monitor() {
55 | return 0;
56 | }
57 |
58 | } // namespace tasks
59 |
60 | } // namespace hiqp
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/tasks/tdef_full_pose.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_TDEF_FULL_POSE_H
18 | #define HIQP_TDEF_FULL_POSE_H
19 |
20 | #include
21 |
22 | #include
23 | #include
24 |
25 | namespace hiqp
26 | {
27 | namespace tasks
28 | {
29 |
30 | /*! \brief Represents a task definition that sets a specific joint configuration. This task definition does not leave any redundancy available to other tasks!
31 | * \author Marcus A Johansson */
32 | class TDefFullPose : public TaskDefinition {
33 | public:
34 | TDefFullPose(std::shared_ptr geom_prim_map,
35 | std::shared_ptr visualizer)
36 | : TaskDefinition(geom_prim_map, visualizer) {}
37 |
38 | ~TDefFullPose() noexcept {}
39 |
40 | int init(const std::vector& parameters,
41 | RobotStatePtr robot_state);
42 |
43 | int update(RobotStatePtr robot_state);
44 |
45 | int monitor();
46 |
47 | private:
48 | TDefFullPose(const TDefFullPose& other) = delete;
49 | TDefFullPose(TDefFullPose&& other) = delete;
50 | TDefFullPose& operator=(const TDefFullPose& other) = delete;
51 | TDefFullPose& operator=(TDefFullPose&& other) noexcept = delete;
52 |
53 | std::vector desired_configuration_;
54 | };
55 |
56 | } // namespace tasks
57 |
58 | } // namespace hiqp
59 |
60 | #endif // include guard
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/tasks/tdef_jnt_config.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_TDEF_JNT_CONFIG_H
18 | #define HIQP_TDEF_JNT_CONFIG_H
19 |
20 | #include
21 |
22 | #include
23 | #include
24 |
25 | namespace hiqp
26 | {
27 | namespace tasks
28 | {
29 |
30 | /*! \brief A task definition that sets a specific joints position.
31 | * \author Marcus A Johansson */
32 | class TDefJntConfig : public TaskDefinition {
33 | public:
34 | TDefJntConfig(std::shared_ptr geom_prim_map,
35 | std::shared_ptr visualizer)
36 | : TaskDefinition(geom_prim_map, visualizer) {}
37 | ~TDefJntConfig() noexcept {}
38 |
39 | int init(const std::vector& parameters,
40 | RobotStatePtr robot_state);
41 |
42 | int update(RobotStatePtr robot_state);
43 |
44 | int monitor();
45 |
46 | private:
47 | TDefJntConfig(const TDefJntConfig& other) = delete;
48 | TDefJntConfig(TDefJntConfig&& other) = delete;
49 | TDefJntConfig& operator=(const TDefJntConfig& other) = delete;
50 | TDefJntConfig& operator=(TDefJntConfig&& other) noexcept = delete;
51 |
52 | std::string link_name_;
53 | int joint_q_nr_;
54 | double desired_configuration_;
55 | };
56 |
57 | } // namespace tasks
58 |
59 | } // namespace hiqp
60 |
61 | #endif // include guard
--------------------------------------------------------------------------------
/hiqp_core/src/tasks/tdyn_hyper_sin.cpp:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #include
18 | #include
19 |
20 | #include
21 |
22 | #include
23 |
24 | namespace hiqp
25 | {
26 | namespace tasks
27 | {
28 |
29 | int TDynHyperSin::init(const std::vector& parameters,
30 | RobotStatePtr robot_state,
31 | const Eigen::VectorXd& e_initial,
32 | const Eigen::VectorXd& e_final) {
33 | int size = parameters.size();
34 | if (size != 2) {
35 | printHiqpWarning("TDynFirstOrder requires 2 parameters, got "
36 | + std::to_string(size) + "! Initialization failed!");
37 | return -1;
38 | }
39 |
40 | lambda_ = std::stod( parameters.at(1) );
41 |
42 | e_dot_star_.resize(e_initial.rows());
43 | performance_measures_.resize(e_initial.rows());
44 |
45 | return 0;
46 | }
47 |
48 | int TDynHyperSin::update(RobotStatePtr robot_state,
49 | const Eigen::VectorXd& e,
50 | const Eigen::MatrixXd& J) {
51 | e_dot_star_.resize(e.size());
52 | for (unsigned int i=0; i.
16 |
17 | #include
18 |
19 | #include
20 |
21 | namespace hiqp
22 | {
23 | namespace tasks
24 | {
25 |
26 | int TDynCubic::init(const std::vector& parameters,
27 | RobotStatePtr robot_state,
28 | const Eigen::VectorXd& e_initial,
29 | const Eigen::VectorXd& e_final) {
30 | int size = parameters.size();
31 | if (size != 2) {
32 | printHiqpWarning("TDynFirstOrderCubic requires 2 parameters, got "
33 | + std::to_string(size) + "! Initialization failed!");
34 | return -1;
35 | }
36 |
37 | lambda_ = std::stod( parameters.at(1) );
38 | e_dot_star_.resize(e_initial.rows());
39 | performance_measures_.resize(e_initial.rows());
40 | return 0;
41 | }
42 |
43 | int TDynCubic::update(RobotStatePtr robot_state,
44 | const Eigen::VectorXd& e,
45 | const Eigen::MatrixXd& J) {
46 | e_dot_star_.resize(e.size());
47 | std::cout << "i'mhere\n";
48 | for (unsigned int i=0; i.
16 |
17 | #ifndef HIQP_TDYN_CUBIC_H
18 | #define HIQP_TDYN_CUBIC_H
19 |
20 | #include
21 | #include
22 |
23 | namespace hiqp
24 | {
25 | namespace tasks
26 | {
27 |
28 | /*! \brief A cubic dynamics similar to first-order dynamics but with slower convergence around e=0.
29 | * \author Marcus A Johansson */
30 | class TDynCubic : public TaskDynamics {
31 | public:
32 | TDynCubic(std::shared_ptr geom_prim_map,
33 | std::shared_ptr visualizer)
34 | : TaskDynamics(geom_prim_map, visualizer) {}
35 |
36 | ~TDynCubic() noexcept {}
37 |
38 | int init(const std::vector& parameters,
39 | RobotStatePtr robot_state,
40 | const Eigen::VectorXd& e_initial,
41 | const Eigen::VectorXd& e_final);
42 |
43 | int update(RobotStatePtr robot_state,
44 | const Eigen::VectorXd& e,
45 | const Eigen::MatrixXd& J);
46 |
47 | int monitor();
48 |
49 | private:
50 | TDynCubic(const TDynCubic& other) = delete;
51 | TDynCubic(TDynCubic&& other) = delete;
52 | TDynCubic& operator=(const TDynCubic& other) = delete;
53 | TDynCubic& operator=(TDynCubic&& other) noexcept = delete;
54 |
55 | double lambda_;
56 | };
57 |
58 | } // namespace tasks
59 |
60 | } // namespace hiqp
61 |
62 | #endif // include guard
63 |
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/tasks/tdyn_linear.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_TDYN_LINEAR_H
18 | #define HIQP_TDYN_LINEAR_H
19 |
20 | #include
21 | #include
22 |
23 | namespace hiqp
24 | {
25 | namespace tasks
26 | {
27 |
28 | /*! \brief A general first-order task dynamics implementation that enforces an exponential decay of the task performance value.
29 | * \author Marcus A Johansson */
30 | class TDynLinear : public TaskDynamics {
31 | public:
32 | TDynLinear(std::shared_ptr geom_prim_map,
33 | std::shared_ptr visualizer)
34 | : TaskDynamics(geom_prim_map, visualizer) {}
35 |
36 | ~TDynLinear() noexcept {}
37 |
38 | int init(const std::vector& parameters,
39 | RobotStatePtr robot_state,
40 | const Eigen::VectorXd& e_initial,
41 | const Eigen::VectorXd& e_final);
42 |
43 | int update(RobotStatePtr robot_state,
44 | const Eigen::VectorXd& e,
45 | const Eigen::MatrixXd& J);
46 |
47 | int monitor();
48 |
49 | private:
50 | TDynLinear(const TDynLinear& other) = delete;
51 | TDynLinear(TDynLinear&& other) = delete;
52 | TDynLinear& operator=(const TDynLinear& other) = delete;
53 | TDynLinear& operator=(TDynLinear&& other) noexcept = delete;
54 |
55 | double lambda_;
56 | };
57 |
58 | } // namespace tasks
59 |
60 | } // namespace hiqp
61 |
62 | #endif // include guard
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/tasks/tdef_jnt_limits.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_TDEF_JNT_LIMITS_H
18 | #define HIQP_TDEF_JNT_LIMITS_H
19 |
20 | #include
21 |
22 | #include
23 | #include
24 |
25 | namespace hiqp
26 | {
27 | namespace tasks
28 | {
29 |
30 | /*! \brief A task definition that sets velocity and position limitations of a specific joint.
31 | * \author Marcus A Johansson */
32 | class TDefJntLimits : public TaskDefinition {
33 | public:
34 | TDefJntLimits(std::shared_ptr geom_prim_map,
35 | std::shared_ptr visualizer)
36 | : TaskDefinition(geom_prim_map, visualizer) {}
37 |
38 | ~TDefJntLimits() noexcept = default;
39 |
40 | int init(const std::vector& parameters,
41 | RobotStatePtr robot_state);
42 |
43 | int update(RobotStatePtr robot_state);
44 |
45 | int monitor();
46 |
47 | private:
48 | TDefJntLimits(const TDefJntLimits& other) = delete;
49 | TDefJntLimits(TDefJntLimits&& other) = delete;
50 | TDefJntLimits& operator=(const TDefJntLimits& other) = delete;
51 | TDefJntLimits& operator=(TDefJntLimits&& other) noexcept = delete;
52 |
53 | std::string link_frame_name_;
54 | std::size_t link_frame_q_nr_;
55 | double jnt_upper_bound_;
56 | double jnt_lower_bound_;
57 |
58 | };
59 |
60 | } // namespace tasks
61 |
62 | } // namespace hiqp
63 |
64 | #endif // include guard
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/tasks/tdyn_jnt_limits.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_TDYN_JNT_LIMITS_H
18 | #define HIQP_TDYN_JNT_LIMITS_H
19 |
20 | #include
21 | #include
22 |
23 | namespace hiqp
24 | {
25 | namespace tasks
26 | {
27 |
28 | /*! \brief A special task dynamics to be used only with the TDefJntLimits task definition.
29 | * \author Marcus A Johansson */
30 | class TDynJntLimits : public TaskDynamics {
31 | public:
32 | TDynJntLimits(std::shared_ptr geom_prim_map,
33 | std::shared_ptr visualizer)
34 | : TaskDynamics(geom_prim_map, visualizer) {}
35 |
36 | ~TDynJntLimits() noexcept = default;
37 |
38 | int init(const std::vector& parameters,
39 | RobotStatePtr robot_state,
40 | const Eigen::VectorXd& e_initial,
41 | const Eigen::VectorXd& e_final);
42 |
43 | int update(RobotStatePtr robot_state,
44 | const Eigen::VectorXd& e,
45 | const Eigen::MatrixXd& J);
46 |
47 | int monitor();
48 |
49 | private:
50 | TDynJntLimits(const TDynJntLimits& other) = delete;
51 | TDynJntLimits(TDynJntLimits&& other) = delete;
52 | TDynJntLimits& operator=(const TDynJntLimits& other) = delete;
53 | TDynJntLimits& operator=(TDynJntLimits&& other) noexcept = delete;
54 |
55 | double dq_max_;
56 | double gain_;
57 |
58 | };
59 |
60 | } // namespace tasks
61 |
62 | } // namespace hiqp
63 |
64 | #endif // include guard
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/tasks/tdyn_hyper_sin.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_TDYN_HYPER_SIN_H
18 | #define HIQP_TDYN_HYPER_SIN_H
19 |
20 | #include
21 | #include
22 |
23 | namespace hiqp
24 | {
25 | namespace tasks
26 | {
27 |
28 | /*! \brief A general hyperbolic sin task dynamics. Useful for only influencing the manipulator behaviour for task function values within a certain span.
29 | * \author Marcus A Johansson */
30 | class TDynHyperSin : public TaskDynamics
31 | {
32 | public:
33 |
34 | TDynHyperSin(std::shared_ptr geom_prim_map,
35 | std::shared_ptr visualizer)
36 | : TaskDynamics(geom_prim_map, visualizer) {}
37 |
38 | ~TDynHyperSin() noexcept {}
39 |
40 | int init(const std::vector& parameters,
41 | RobotStatePtr robot_state,
42 | const Eigen::VectorXd& e_initial,
43 | const Eigen::VectorXd& e_final);
44 |
45 | int update(RobotStatePtr robot_state,
46 | const Eigen::VectorXd& e,
47 | const Eigen::MatrixXd& J);
48 |
49 | int monitor();
50 |
51 | private:
52 | TDynHyperSin(const TDynHyperSin& other) = delete;
53 | TDynHyperSin(TDynHyperSin&& other) = delete;
54 | TDynHyperSin& operator=(const TDynHyperSin& other) = delete;
55 | TDynHyperSin& operator=(TDynHyperSin&& other) noexcept = delete;
56 |
57 | double lambda_;
58 | };
59 |
60 | } // namespace tasks
61 |
62 | } // namespace hiqp
63 |
64 | #endif // include guard
--------------------------------------------------------------------------------
/hiqp_msgs/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | cmake_minimum_required(VERSION 2.8.3)
18 | project(hiqp_msgs)
19 |
20 | find_package(catkin REQUIRED COMPONENTS message_generation
21 | std_msgs
22 | visualization_msgs
23 | geometry_msgs)
24 |
25 | add_message_files(FILES TaskMeasure.msg
26 | TaskMeasures.msg
27 | StringArray.msg
28 | Vector3d.msg)
29 |
30 | add_service_files(FILES SetTask.srv
31 | RemoveTask.srv
32 | RemoveAllTasks.srv
33 | ListAllTasks.srv
34 | ActivateTask.srv
35 | DeactivateTask.srv
36 | MonitorTask.srv
37 | DemonitorTask.srv
38 | SetPrimitive.srv
39 | RemovePrimitive.srv
40 | RemoveAllPrimitives.srv
41 | ListAllPrimitives.srv
42 | RemovePriorityLevel.srv
43 | ActivatePriorityLevel.srv
44 | DeactivatePriorityLevel.srv
45 | MonitorPriorityLevel.srv
46 | DemonitorPriorityLevel.srv)
47 |
48 | generate_messages(DEPENDENCIES std_msgs
49 | geometry_msgs
50 | visualization_msgs)
51 |
52 | catkin_package(CATKIN_DEPENDS message_runtime
53 | std_msgs
54 | visualization_msgs
55 | geometry_msgs)
--------------------------------------------------------------------------------
/hiqp_core/src/tasks/tdef_jnt_config.cpp:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #include
18 | #include
19 |
20 | #include
21 |
22 | namespace hiqp
23 | {
24 | namespace tasks
25 | {
26 |
27 |
28 | int TDefJntConfig::init(const std::vector& parameters,
29 | RobotStatePtr robot_state) {
30 | int size = parameters.size();
31 | if (size != 3) {
32 | printHiqpWarning("TDefJntConfig requires 3 parameters, got "
33 | + std::to_string(size) + "! Initialization failed!");
34 | return -1;
35 | }
36 |
37 | link_name_ = parameters.at(1);
38 |
39 | joint_q_nr_ = kdl_getQNrFromLinkName(robot_state->kdl_tree_, link_name_);
40 |
41 | if (joint_q_nr_ < 0) {
42 | printHiqpWarning("TDefJntConfig::init, couldn't find joint '" + link_name_ + "'! Initialization failed.");
43 | return -2;
44 | }
45 |
46 | if (!robot_state->isQNrWritable(joint_q_nr_)) {
47 | printHiqpWarning("TDefJntConfig::init, the joint '" + link_name_ + "' is not writable! Initialization failed.");
48 | return -3;
49 | }
50 |
51 | desired_configuration_ = std::stod( parameters.at(2) );
52 |
53 | unsigned int n_joints = robot_state->getNumJoints();
54 | e_.resize(1);
55 | J_.resize(1, n_joints);
56 | performance_measures_.resize(0);
57 | task_types_.insert(task_types_.begin(), 1, 0);
58 |
59 | for (int i=0; ikdl_jnt_array_vel_.q;
69 | e_(0) = desired_configuration_ - q(joint_q_nr_);
70 | return 0;
71 | }
72 |
73 | int TDefJntConfig::monitor() {
74 | return 0;
75 | }
76 |
77 |
78 | } // namespace tasks
79 |
80 | } // namespace hiqp
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/tasks/tdyn_minimal_jerk.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_TDYN_MINIMAL_JERK_H
18 | #define HIQP_TDYN_MINIMAL_JERK_H
19 |
20 | #include
21 | #include
22 |
23 | namespace hiqp
24 | {
25 | namespace tasks
26 | {
27 |
28 | /*! \brief A task dynamics that enforces minimal jerk throughout the whole motion.
29 | * \author Marcus A Johansson */
30 | class TDynMinimalJerk : public TaskDynamics {
31 | public:
32 | TDynMinimalJerk(std::shared_ptr geom_prim_map,
33 | std::shared_ptr visualizer)
34 | : TaskDynamics(geom_prim_map, visualizer) {}
35 |
36 | ~TDynMinimalJerk() noexcept = default;
37 |
38 | int init(const std::vector& parameters,
39 | RobotStatePtr robot_state,
40 | const Eigen::VectorXd& e_initial,
41 | const Eigen::VectorXd& e_final);
42 |
43 | int update(RobotStatePtr robot_state,
44 | const Eigen::VectorXd& e,
45 | const Eigen::MatrixXd& J);
46 |
47 | int monitor();
48 |
49 | private:
50 | TDynMinimalJerk(const TDynMinimalJerk& other) = delete;
51 | TDynMinimalJerk(TDynMinimalJerk&& other) = delete;
52 | TDynMinimalJerk& operator=(const TDynMinimalJerk& other) = delete;
53 | TDynMinimalJerk& operator=(TDynMinimalJerk&& other) noexcept = delete;
54 |
55 | HiQPTimePoint time_start_;
56 | double total_duration_;
57 | double gain_;
58 | Eigen::VectorXd e_initial_;
59 | Eigen::VectorXd e_final_;
60 | Eigen::VectorXd e_diff_;
61 | double f_;
62 | };
63 |
64 | } // namespace tasks
65 |
66 | } // namespace hiqp
67 |
68 | #endif // include guard
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/geometric_primitives/geometric_primitive_visitor.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_GEOMETRIC_PRIMITIVE_VISITOR_H
18 | #define HIQP_GEOMETRIC_PRIMITIVE_VISITOR_H
19 |
20 | #include
21 |
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | namespace hiqp {
31 |
32 | namespace geometric_primitives {
33 |
34 | /*! \brief
35 | * {author Marcus A Johansson */
36 | class GeometricPrimitiveVisitor {
37 | public:
38 | GeometricPrimitiveVisitor() {}
39 | ~GeometricPrimitiveVisitor() noexcept {}
40 |
41 | virtual void visit(std::shared_ptr point) = 0;
42 | virtual void visit(std::shared_ptr line) = 0;
43 | virtual void visit(std::shared_ptr plane) = 0;
44 | virtual void visit(std::shared_ptr box) = 0;
45 | virtual void visit(std::shared_ptr cylinder) = 0;
46 | virtual void visit(std::shared_ptr sphere) = 0;
47 | virtual void visit(std::shared_ptr frame) = 0;
48 |
49 | private:
50 | GeometricPrimitiveVisitor(const GeometricPrimitiveVisitor& other) = delete;
51 | GeometricPrimitiveVisitor(GeometricPrimitiveVisitor&& other) = delete;
52 | GeometricPrimitiveVisitor& operator=(const GeometricPrimitiveVisitor& other) = delete;
53 | GeometricPrimitiveVisitor& operator=(GeometricPrimitiveVisitor&& other) noexcept = delete;
54 | };
55 |
56 | } // namespace geometric_primitives
57 |
58 | } // namespace hiqp
59 |
60 | #endif // include guard
--------------------------------------------------------------------------------
/hiqp_ros/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # The HiQP Control Framework, an optimal control framework targeted at robotics
2 | # Copyright (C) 2016 Marcus A Johansson
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | cmake_minimum_required(VERSION 2.8.6)
18 | project(hiqp_ros)
19 |
20 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR})
21 | set(CMAKE_CXX_FLAGS "-O3 -std=c++11 -Wl,-z,defs")
22 |
23 | set(GUROBI_INCLUDE_DIR "$ENV{GUROBI_HOME}/include")
24 | set(GUROBI_LIB_DIR "$ENV{GUROBI_HOME}/lib")
25 | set(GUROBI_LIBS gurobi_c++ gurobi65)
26 |
27 | find_package(catkin REQUIRED COMPONENTS roscpp
28 | controller_interface
29 | visualization_msgs
30 | hiqp_core
31 | hiqp_msgs)
32 |
33 | find_package(orocos_kdl REQUIRED)
34 | find_package(Eigen3 REQUIRED)
35 |
36 | catkin_package(CATKIN_DEPENDS roscpp controller_interface visualization_msgs hiqp_core hiqp_msgs
37 | INCLUDE_DIRS include
38 | LIBRARIES ${PROJECT_NAME}
39 | DEPENDS orocos_kdl)
40 |
41 | include_directories(include ${catkin_INCLUDE_DIRS})
42 | include_directories(${GUROBI_INCLUDE_DIR})
43 |
44 | link_directories(${GUROBI_LIB_DIR})
45 |
46 | add_library(${PROJECT_NAME} src/hiqp_joint_velocity_controller.cpp
47 | src/hiqp_service_handler.cpp
48 | src/ros_topic_subscriber.cpp
49 | src/ros_visualizer.cpp
50 | src/utilities.cpp)
51 |
52 | target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} ${orocos_kdl_LIBRARIES} ${GUROBI_LIBS})
53 |
54 | install(DIRECTORY include/${PROJECT_NAME}/
55 | DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
56 | FILES_MATCHING PATTERN "*.h")
57 |
58 | install(TARGETS ${PROJECT_NAME}
59 | ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
60 | LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
61 | RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
62 |
63 | install(FILES plugins.xml
64 | DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
65 |
--------------------------------------------------------------------------------
/hiqp_core/src/tasks/tdyn_minimal_jerk.cpp:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #include
18 |
19 | #include
20 |
21 | namespace hiqp
22 | {
23 | namespace tasks
24 | {
25 |
26 | int TDynMinimalJerk::init(const std::vector& parameters,
27 | RobotStatePtr robot_state,
28 | const Eigen::VectorXd& e_initial,
29 | const Eigen::VectorXd& e_final) {
30 | int size = parameters.size();
31 | if (size != 3) {
32 | printHiqpWarning("TDynMinimalJerk requires 3 parameters, got "
33 | + std::to_string(size) + "! Initialization failed!");
34 | return -1;
35 | }
36 |
37 | performance_measures_.resize(e_initial.rows());
38 | e_dot_star_.resize(e_initial.rows());
39 |
40 | time_start_ = robot_state->sampling_time_point_;
41 |
42 | total_duration_ = std::stod( parameters.at(1) );
43 | gain_ = std::stod( parameters.at(2) );
44 |
45 | f_ = 30 / total_duration_;
46 |
47 | e_initial_ = e_initial;
48 | e_final_ = e_final;
49 | e_diff_ = e_final - e_initial;
50 |
51 | return 0;
52 | }
53 |
54 | int TDynMinimalJerk::update(RobotStatePtr robot_state,
55 | const Eigen::VectorXd& e,
56 | const Eigen::MatrixXd& J) {
57 | e_dot_star_.resize(e.size());
58 | double tau = (robot_state->sampling_time_point_ - time_start_).toSec() / total_duration_;
59 |
60 | if (tau > 1) {
61 | e_dot_star_ = 0*e;
62 | } else {
63 | double T = 10*tau*tau*tau - 15*tau*tau*tau*tau + 6*tau*tau*tau*tau*tau;
64 | double t = f_ * (tau*tau - 2*tau*tau*tau + tau*tau*tau*tau);
65 |
66 | Eigen::VectorXd e_star = e_initial_ + e_diff_ * T;
67 |
68 | e_dot_star_ = e_diff_ * t - gain_ * (e - e_star); // minimal jerk + first order
69 | }
70 |
71 | return 0;
72 | }
73 |
74 | int TDynMinimalJerk::monitor() {
75 | return 0;
76 | }
77 |
78 | } // namespace tasks
79 |
80 | } // namespace hiqp
--------------------------------------------------------------------------------
/hiqp_ros/include/hiqp_ros/ros_topic_subscriber.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_ROS_TOPIC_SUBSCRIBER_H
18 | #define HIQP_ROS_TOPIC_SUBSCRIBER_H
19 |
20 | #include
21 | #include
22 |
23 | #include
24 | #include
25 |
26 | #include "ros/ros.h"
27 |
28 | using hiqp::geometric_primitives::GeometricPrimitiveMap;
29 | using hiqp::geometric_primitives::GeometricPoint;
30 | using hiqp::geometric_primitives::GeometricLine;
31 | using hiqp::geometric_primitives::GeometricPlane;
32 | using hiqp::geometric_primitives::GeometricBox;
33 | using hiqp::geometric_primitives::GeometricCylinder;
34 | using hiqp::geometric_primitives::GeometricSphere;
35 | using hiqp::geometric_primitives::GeometricFrame;
36 |
37 | namespace hiqp_ros
38 | {
39 |
40 | class ROSTopicSubscriber {
41 | public:
42 |
43 | ROSTopicSubscriber() {}
44 | ~ROSTopicSubscriber() {}
45 |
46 | int init(hiqp::TaskManager* task_manager) {
47 | task_manager_ = task_manager;
48 | }
49 |
50 | template
51 | int addSubscription(ros::NodeHandle &controller_nh,
52 | const std::string& topic_name,
53 | unsigned int buffer_size) {
54 | sub = controller_nh.subscribe(
55 | topic_name, buffer_size, &ROSTopicSubscriber::topicCallback, this);
56 | ROS_INFO_STREAM("Subsribed to topic '" << topic_name << "'");
57 | }
58 |
59 | /*! \brief Implement this function for your own message! */
60 | template
61 | void topicCallback(const ROSMessageType& msg);
62 |
63 | private:
64 | ROSTopicSubscriber(const ROSTopicSubscriber& other) = delete;
65 | ROSTopicSubscriber(ROSTopicSubscriber&& other) = delete;
66 | ROSTopicSubscriber& operator=(const ROSTopicSubscriber& other) = delete;
67 | ROSTopicSubscriber& operator=(ROSTopicSubscriber&& other) noexcept = delete;
68 |
69 | ros::Subscriber sub;
70 |
71 | hiqp::TaskManager* task_manager_;
72 |
73 | };
74 |
75 | } // namespace hiqp
76 |
77 | #endif // Include guard
--------------------------------------------------------------------------------
/hiqp_core/src/tasks/tdef_full_pose.cpp:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #include
18 |
19 | #include
20 |
21 | #include
22 |
23 | namespace hiqp
24 | {
25 | namespace tasks
26 | {
27 |
28 | int TDefFullPose::init(const std::vector& parameters,
29 | RobotStatePtr robot_state) {
30 | int size = parameters.size();
31 | unsigned int n_controls = robot_state->getNumControls();
32 | unsigned int n_joints = robot_state->getNumJoints();
33 | if (size != 1 && size != n_controls + 1) {
34 | printHiqpWarning("TDefFullPose requires 1 or "
35 | + std::to_string(n_controls+1) + " parameters, got "
36 | + std::to_string(size) + "! Initialization failed!");
37 | return -1;
38 | }
39 |
40 | if (size == 1) {
41 | desired_configuration_ = std::vector(n_controls, 0);
42 | } else {
43 | desired_configuration_.resize(0);
44 | for (int i=1; i < n_controls+1; ++i) {
45 | desired_configuration_.push_back( std::stod( parameters.at(i) ) );
46 |
47 | }
48 | }
49 |
50 | e_ = Eigen::VectorXd::Zero(n_controls);
51 | J_ = Eigen::MatrixXd::Zero(n_controls, n_joints);
52 | performance_measures_.resize(0);
53 | task_types_.insert(task_types_.begin(), n_controls, 0);
54 |
55 | // The jacobian has zero-columns for non-writable joints
56 | // -1 0 0 0 0
57 | // 0 -1 0 0 0
58 | // 0 0 0 -1 0
59 | for (int c=0, r=0; cisQNrWritable(c)) {
61 | J_(r, c) = -1;
62 | r++;
63 | }
64 | }
65 |
66 | return 0;
67 | }
68 |
69 | int TDefFullPose::update(RobotStatePtr robot_state) {
70 | const KDL::JntArray &q = robot_state->kdl_jnt_array_vel_.q;
71 | int j=0;
72 | for (int i=0; iisQNrWritable(i)) {
74 | e_(j) = desired_configuration_.at(j) - q(i);
75 | j++;
76 | }
77 | }
78 | return 0;
79 | }
80 |
81 | int TDefFullPose::monitor() {
82 | return 0;
83 | }
84 |
85 | } // namespace tasks
86 |
87 | } // namespace hiqp
88 |
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/geometric_primitives/geometric_primitive_couter.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_GEOMETRIC_PRIMITIVE_COUTER_H
18 | #define HIQP_GEOMETRIC_PRIMITIVE_COUTER_H
19 |
20 | #include
21 |
22 | #include
23 | #include
24 |
25 | namespace hiqp {
26 |
27 | namespace geometric_primitives {
28 |
29 | /*! \brief A Geometric Primitive Visitor that prints info about the primitive it visits to std::cout.
30 | * \author Marcus A Johansson */
31 | class GeometricPrimitiveCouter : public GeometricPrimitiveVisitor {
32 | public:
33 | GeometricPrimitiveCouter() = default;
34 |
35 | ~GeometricPrimitiveCouter() noexcept = default;
36 |
37 | void visit(std::shared_ptr point) { print(point); std::cout << "point\n"; }
38 | void visit(std::shared_ptr line) { print(line); std::cout << "line\n"; }
39 | void visit(std::shared_ptr plane) { print(plane); std::cout << "plane\n"; }
40 | void visit(std::shared_ptr box) { print(box); std::cout << "box\n"; }
41 | void visit(std::shared_ptr cylinder) { print(cylinder); std::cout << "cylinder\n"; }
42 | void visit(std::shared_ptr sphere) { print(sphere); std::cout << "sphere\n"; }
43 | void visit(std::shared_ptr frame) { print(frame); std::cout << "frame\n"; }
44 |
45 |
46 | private:
47 | GeometricPrimitiveCouter(const GeometricPrimitiveCouter& other) = delete;
48 | GeometricPrimitiveCouter(GeometricPrimitiveCouter&& other) = delete;
49 | GeometricPrimitiveCouter& operator=(const GeometricPrimitiveCouter& other) = delete;
50 | GeometricPrimitiveCouter& operator=(GeometricPrimitiveCouter&& other) noexcept = delete;
51 |
52 | template
53 | void print(std::shared_ptr primitive);
54 |
55 | };
56 |
57 | template
58 | void GeometricPrimitiveCouter::print(std::shared_ptr primitive) {
59 | std::cout << primitive->getName() << ", "
60 | << primitive->getFrameId() << ", "
61 | << primitive->isVisible() << ", "
62 | << primitive->getVisualId() << ", ";
63 | }
64 |
65 | } // namespace geometric_primitives
66 |
67 | } // namespace hiqp
68 |
69 | #endif // include guard
--------------------------------------------------------------------------------
/hiqp_core/src/hiqp_time_point.cpp:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #include
18 |
19 | namespace hiqp {
20 |
21 | HiQPTimePoint::HiQPTimePoint() : sec_(0), nsec_(0) {}
22 |
23 | HiQPTimePoint::HiQPTimePoint(unsigned int sec, unsigned int nsec)
24 | : sec_(sec), nsec_(nsec) {}
25 |
26 | HiQPTimePoint::HiQPTimePoint(const HiQPTimePoint& other)
27 | : sec_(other.getSec()), nsec_(other.getNSec()) {}
28 |
29 | HiQPTimePoint::~HiQPTimePoint() {}
30 |
31 | double HiQPTimePoint::toSec() const {
32 | return static_cast(sec_) + static_cast(nsec_) * 1e-9;
33 | }
34 |
35 | HiQPTimePoint& HiQPTimePoint::operator=(const HiQPTimePoint& other) {
36 | this->sec_ = other.getSec();
37 | this->nsec_ = other.getNSec();
38 | return *this;
39 | }
40 |
41 | HiQPTimePoint HiQPTimePoint::operator+(const HiQPTimePoint& other) const {
42 | unsigned int sec = sec_ + other.getSec();
43 | unsigned int nsec = nsec_ + other.getNSec();
44 | unsigned int overlap = nsec * 1e-9;
45 | return HiQPTimePoint( sec + overlap, nsec - overlap * 1e9 );
46 | }
47 |
48 | HiQPTimePoint HiQPTimePoint::operator-(const HiQPTimePoint& other) const {
49 | unsigned int sec = sec_ - other.getSec();
50 | unsigned int nsec = 0;
51 | unsigned int underlap = 0;
52 |
53 | if (nsec_ >= other.getNSec()) {
54 | nsec = nsec_ - other.getNSec();
55 | } else {
56 | nsec = 1e9 + nsec_ - other.getNSec();
57 | sec -= 1;
58 | }
59 |
60 | return HiQPTimePoint(sec, nsec);
61 | }
62 |
63 | HiQPTimePoint& HiQPTimePoint::operator+=(const HiQPTimePoint& other) {
64 | unsigned int sec = sec_ + other.getSec();
65 | unsigned int nsec = nsec_ + other.getNSec();
66 | unsigned int overlap = nsec * 1e-9;
67 |
68 | this->sec_ = sec + overlap;
69 | this->nsec_ = nsec - overlap * 1e9;
70 |
71 | return *this;
72 | }
73 |
74 | HiQPTimePoint& HiQPTimePoint::operator-=(const HiQPTimePoint& other) {
75 | unsigned int sec = sec_ - other.getSec();
76 | unsigned int nsec = 0;
77 | unsigned int underlap = 0;
78 |
79 | if (nsec_ >= other.getNSec()) {
80 | nsec = nsec_ - other.getNSec();
81 | } else {
82 | nsec = 1e9 + nsec_ - other.getNSec();
83 | sec -= 1;
84 | }
85 |
86 | this->sec_ = sec;
87 | this->nsec_ = nsec;
88 |
89 | return *this;
90 | }
91 |
92 | } // namespace hiqp
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/geometric_primitives/geometric_primitive.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_GEOMETRIC_PRIMITIVE_H
18 | #define HIQP_GEOMETRIC_PRIMITIVE_H
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | namespace hiqp
25 | {
26 | namespace geometric_primitives
27 | {
28 |
29 | /*!
30 | * \class GeometricPrimitive
31 | * \brief Abstract base class for all geometric primitives.
32 | */
33 | class GeometricPrimitive
34 | {
35 | public:
36 | GeometricPrimitive(const std::string& name,
37 | const std::string& frame_id,
38 | bool visible,
39 | const std::vector& color)
40 | : name_(name), frame_id_(frame_id), visible_(visible), visual_id_(-1) {
41 | r_ = color.at(0);
42 | g_ = color.at(1);
43 | b_ = color.at(2);
44 | a_ = color.at(3);
45 | }
46 |
47 | ~GeometricPrimitive() noexcept = default;
48 |
49 | /*! \brief Must be specified by the inheriting class. */
50 | virtual int init(const std::vector& parameters) = 0;
51 |
52 | inline int setVisualId(int visual_id) { visual_id_ = visual_id; }
53 | inline int getVisualId() { return visual_id_; }
54 |
55 | inline std::string getName() { return name_; }
56 | inline std::string getFrameId() { return frame_id_; }
57 | inline bool isVisible() { return visible_; }
58 |
59 | inline double getRedComponent() { return r_; }
60 | inline double getGreenComponent() { return g_; }
61 | inline double getBlueComponent() { return b_; }
62 | inline double getAlphaComponent() { return a_; }
63 |
64 | protected:
65 | std::string name_;
66 | std::string frame_id_;
67 | bool visible_;
68 | int visual_id_;
69 | double r_, g_, b_, a_;
70 |
71 | private:
72 | GeometricPrimitive(const GeometricPrimitive& other) = delete;
73 | GeometricPrimitive(GeometricPrimitive&& other) = delete;
74 | GeometricPrimitive& operator=(const GeometricPrimitive& other) = delete;
75 | GeometricPrimitive& operator=(GeometricPrimitive&& other) noexcept = delete;
76 | };
77 |
78 | } // namespace geometric_primitives
79 |
80 | } // namespace hiqp
81 |
82 | #endif // include guard
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/geometric_primitives/geometric_point.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_GEOMETRIC_POINT_H
18 | #define HIQP_GEOMETRIC_POINT_H
19 |
20 | #include
21 | #include
22 |
23 | #include
24 |
25 | #include
26 |
27 | namespace hiqp
28 | {
29 | namespace geometric_primitives
30 | {
31 |
32 | /*! \brief Parameters: [x, y, z]
33 | * \author Marcus A Johansson */
34 | class GeometricPoint : public GeometricPrimitive {
35 | public:
36 | GeometricPoint(const std::string& name,
37 | const std::string& frame_id,
38 | bool visible,
39 | const std::vector& color)
40 | : GeometricPrimitive(name, frame_id, visible, color) {}
41 |
42 | ~GeometricPoint() noexcept {}
43 |
44 | /*! \brief Parses a set of parameters and initializes the point.
45 | * \param parameters : Should be of size 3. Indices 0-2 (required) defines the position of the point.
46 | * \return 0 on success, -1 if the wrong number of parameters was sent */
47 | int init(const std::vector& parameters) {
48 | int size = parameters.size();
49 | if (size != 3) {
50 | printHiqpWarning("GeometricPoint requires 3 parameters, got "
51 | + std::to_string(size) + "! Initialization failed!");
52 | return -1;
53 | }
54 |
55 | kdl_p_(0) = parameters.at(0);
56 | kdl_p_(1) = parameters.at(1);
57 | kdl_p_(2) = parameters.at(2);
58 |
59 | eigen_p_ << kdl_p_(0), kdl_p_(1), kdl_p_(2);
60 | return 0;
61 | }
62 |
63 | inline const KDL::Vector& getPointKDL() { return kdl_p_; }
64 |
65 | inline const Eigen::Vector3d& getPointEigen() { return eigen_p_; }
66 |
67 | inline double getX() { return kdl_p_(0); }
68 | inline double getY() { return kdl_p_(1); }
69 | inline double getZ() { return kdl_p_(2); }
70 |
71 | protected:
72 | KDL::Vector kdl_p_;
73 | Eigen::Vector3d eigen_p_;
74 |
75 | private:
76 | GeometricPoint(const GeometricPoint& other) = delete;
77 | GeometricPoint(GeometricPoint&& other) = delete;
78 | GeometricPoint& operator=(const GeometricPoint& other) = delete;
79 | GeometricPoint& operator=(GeometricPoint&& other) noexcept = delete;
80 | };
81 |
82 | } // namespace geometric_primitives
83 |
84 | } // namespace hiqp
85 |
86 | #endif // include guard
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/tasks/tdef_geometric_alignment.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_TDEF_GEOMETRIC_ALIGNMENT_H
18 | #define HIQP_TDEF_GEOMETRIC_ALIGNMENT_H
19 |
20 | #include
21 | #include
22 |
23 | #include
24 | #include
25 |
26 | #include
27 | #include
28 |
29 | namespace hiqp
30 | {
31 | namespace tasks
32 | {
33 |
34 | /*! \brief A task definition that rotates primitives to align with each other.
35 | * \author Marcus A Johansson */
36 | template
37 | class TDefGeometricAlignment : public TaskDefinition {
38 | public:
39 | TDefGeometricAlignment(std::shared_ptr geom_prim_map,
40 | std::shared_ptr visualizer);
41 | ~TDefGeometricAlignment() noexcept = default;
42 |
43 | int init(const std::vector& parameters,
44 | RobotStatePtr robot_state);
45 |
46 | int update(RobotStatePtr robot_state);
47 |
48 | int monitor();
49 |
50 | private:
51 | TDefGeometricAlignment(const TDefGeometricAlignment& other) = delete;
52 | TDefGeometricAlignment(TDefGeometricAlignment&& other) = delete;
53 | TDefGeometricAlignment& operator=(const TDefGeometricAlignment& other) = delete;
54 | TDefGeometricAlignment& operator=(TDefGeometricAlignment&& other) noexcept = delete;
55 |
56 | int align(std::shared_ptr first, std::shared_ptr second);
57 | int alignVectors(const KDL::Vector& v1, const KDL::Vector v2);
58 |
59 | /// \brief This sets jacobian columns corresponding to non-writable joints to 0
60 | void maskJacobian(RobotStatePtr robot_state);
61 |
62 | std::shared_ptr fk_solver_pos_;
63 | std::shared_ptr fk_solver_jac_;
64 |
65 | std::shared_ptr primitive_a_;
66 | KDL::Frame pose_a_;
67 | KDL::Jacobian jacobian_a_;
68 |
69 | std::shared_ptr primitive_b_;
70 | KDL::Frame pose_b_;
71 | KDL::Jacobian jacobian_b_;
72 |
73 | double delta_; // the angular error margin
74 |
75 | };
76 |
77 | } // namespace tasks
78 |
79 | } // namespace hiqp
80 |
81 | #include
82 |
83 | #endif // include guard
84 |
--------------------------------------------------------------------------------
/hiqp_core/src/tasks/tdef_jnt_limits.cpp:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #include
18 | #include
19 |
20 | #include
21 |
22 | namespace hiqp
23 | {
24 | namespace tasks
25 | {
26 |
27 | int TDefJntLimits::init(const std::vector& parameters,
28 | RobotStatePtr robot_state) {
29 | int size = parameters.size();
30 | if (size != 4)
31 | {
32 | printHiqpWarning("TDefJntLimits requires 4 parameter, got "
33 | + std::to_string(size) + "! Initialization failed!");
34 | return -1;
35 | }
36 |
37 | link_frame_name_ = parameters.at(1);
38 | link_frame_q_nr_ = kdl_getQNrFromLinkName(robot_state->kdl_tree_, link_frame_name_);
39 |
40 | if (link_frame_q_nr_ < 0) {
41 | printHiqpWarning("TDefJntLimits::init, couldn't find joint '" + link_frame_name_ + "'! Initialization failed.");
42 | return -2;
43 | }
44 |
45 | if (!robot_state->isQNrWritable(link_frame_q_nr_)) {
46 | printHiqpWarning("TDefJntLimits::init, the joint '" + link_frame_name_ + "' is not writable! Initialization failed.");
47 | return -3;
48 | }
49 |
50 | unsigned int n_joints = robot_state->getNumJoints();
51 | e_.resize(4);
52 | J_.resize(4, n_joints);
53 | performance_measures_.resize(0);
54 |
55 | task_types_.resize(4);
56 | task_types_.at(0) = 1; // > -dq_max
57 | task_types_.at(1) = -1; // < dq_max
58 | task_types_.at(2) = 1; // > lower bound
59 | task_types_.at(3) = -1; // < upper bound
60 |
61 |
62 | jnt_lower_bound_ = std::stod( parameters.at(2) );
63 | jnt_upper_bound_ = std::stod( parameters.at(3) );
64 |
65 | //Jacobian entries are 1 at column link_frame_q_nr_ and 0 otherwise
66 | for (int i=0; i<4; ++i) {
67 | for (int j=0; jkdl_jnt_array_vel_.q(link_frame_q_nr_);
77 |
78 | e_(0) = q; //e_(0), and e_(1) do not actually matter, since they're ignored in DynamicsJntLimits where de_*=+/- dq_max
79 | e_(1) = q;
80 | e_(2) = q - jnt_lower_bound_;
81 | e_(3) = q - jnt_upper_bound_;
82 |
83 | return 0;
84 | }
85 |
86 | int TDefJntLimits::monitor() {
87 | return 0;
88 | }
89 |
90 | } // namespace tasks
91 |
92 | } // namespace hiqp
93 |
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/robot_state.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_ROBOT_STATE_H
18 | #define HIQP_ROBOT_STATE_H
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | namespace hiqp {
26 |
27 | /*! \brief Holds information on what q_nr (KDL) is associated with what joint name, and whether that joint's resource is readable/writable.
28 | * \author Marcus A Johansson */
29 | struct JointHandleInfo {
30 | JointHandleInfo(unsigned int q_nr, const std::string& joint_name, bool readable, bool writable)
31 | : q_nr_(q_nr), joint_name_(joint_name), readable_(readable), writable_(writable) {}
32 | unsigned int q_nr_;
33 | std::string joint_name_;
34 | bool readable_;
35 | bool writable_;
36 | };
37 |
38 | /*! \brief Holds the state of the robot (sampling time, kdl tree, joint positions and velocities)
39 | * \author Marcus A Johansson */
40 | struct RobotState {
41 | HiQPTimePoint sampling_time_point_;
42 | double sampling_time_;
43 | KDL::Tree kdl_tree_;
44 | KDL::JntArrayVel kdl_jnt_array_vel_;
45 | KDL::JntArray kdl_effort_;
46 | std::vector joint_handle_info_;
47 |
48 | /// \brief Returns whether the joint with qnr is writable or not
49 | inline bool isQNrWritable(unsigned int qnr) const {
50 | for (auto&& jhi : joint_handle_info_) {
51 | if (jhi.q_nr_ == qnr)
52 | return jhi.writable_;
53 | }
54 | return false;
55 | }
56 |
57 | /// \brief Returns the total number of joints (including read-only joint resources)
58 | inline unsigned int getNumJoints() const {
59 | return kdl_tree_.getNrOfJoints();
60 | }
61 |
62 | /// \brief Returns the number of controllable joints (writable joint resources)
63 | inline unsigned int getNumControls() const {
64 | unsigned int n = 0;
65 | for (auto&& jhi : joint_handle_info_) {
66 | if (jhi.writable_) n++;
67 | }
68 | return n;
69 | }
70 | };
71 |
72 | /// \todo Rename to RobotStateConstPtr
73 | /*! \brief A const pointer type to a robot state. Used to reference to the current robot state throught the framework.
74 | * \author Marcus A Johansson */
75 | typedef std::shared_ptr RobotStatePtr;
76 |
77 | } // namespace hiqp
78 |
79 | #endif // include guard
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/visualizer.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_VISUALIZER_H
18 | #define HIQP_VISUALIZER_H
19 |
20 | #include
21 |
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | namespace hiqp
31 | {
32 | using geometric_primitives::GeometricPoint;
33 | using geometric_primitives::GeometricLine;
34 | using geometric_primitives::GeometricPlane;
35 | using geometric_primitives::GeometricBox;
36 | using geometric_primitives::GeometricCylinder;
37 | using geometric_primitives::GeometricSphere;
38 | using geometric_primitives::GeometricFrame;
39 |
40 | /*! \brief An interface for visualizing geometric primitives. Derive from this class to implement your own visualizer and provide it to TaskManager to get visualization of HiQP.
41 | * \author Marcus A Johansson */
42 | class Visualizer {
43 | public:
44 | Visualizer() {}
45 | ~Visualizer() noexcept {}
46 |
47 | virtual int add(std::shared_ptr point) = 0;
48 | virtual int add(std::shared_ptr line) = 0;
49 | virtual int add(std::shared_ptr plane) = 0;
50 | virtual int add(std::shared_ptr box) = 0;
51 | virtual int add(std::shared_ptr cylinder) = 0;
52 | virtual int add(std::shared_ptr sphere) = 0;
53 | virtual int add(std::shared_ptr frame) = 0;
54 |
55 | virtual void update(int id, std::shared_ptr point) = 0;
56 | virtual void update(int id, std::shared_ptr line) = 0;
57 | virtual void update(int id, std::shared_ptr plane) = 0;
58 | virtual void update(int id, std::shared_ptr box) = 0;
59 | virtual void update(int id, std::shared_ptr cylinder) = 0;
60 | virtual void update(int id, std::shared_ptr sphere) = 0;
61 | virtual void update(int id, std::shared_ptr frame) = 0;
62 |
63 | virtual void remove(int id) = 0;
64 |
65 | virtual void removeMany(const std::vector& ids) = 0;
66 |
67 | private:
68 | Visualizer(const Visualizer& other) = delete;
69 | Visualizer(Visualizer&& other) = delete;
70 | Visualizer& operator=(const Visualizer& other) = delete;
71 | Visualizer& operator=(Visualizer&& other) noexcept = delete;
72 | };
73 |
74 | } // namespace hiqp
75 |
76 | #endif // include guard
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/geometric_primitives/geometric_sphere.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_GEOMETRIC_SPHERE_H
18 | #define HIQP_GEOMETRIC_SPHERE_H
19 |
20 | #include
21 | #include
22 |
23 | #include
24 |
25 | #include
26 |
27 | namespace hiqp
28 | {
29 | namespace geometric_primitives
30 | {
31 |
32 | /*! \brief Parameters: [x, y, z, radius]
33 | * \author Marcus A Johansson */
34 | class GeometricSphere : public GeometricPrimitive {
35 | public:
36 | GeometricSphere(const std::string& name,
37 | const std::string& frame_id,
38 | bool visible,
39 | const std::vector& color)
40 | : GeometricPrimitive(name, frame_id, visible, color) {}
41 |
42 | ~GeometricSphere() noexcept = default;
43 |
44 | /*! \brief Parses a set of parameters and initializes the sphere.
45 | * \param parameters : Should be of size 4.
46 | * - Indices 0-2 (required) defines the position of the center of the sphere.
47 | * - Index 3 (required) defines the radius of the sphere.
48 | *
49 | * \return 0 on success, -1 if the wrong number of parameters was sent */
50 | int init(const std::vector& parameters) {
51 | int size = parameters.size();
52 | if (size != 4) {
53 | printHiqpWarning("GeometricSphere requires 4 parameters, got "
54 | + std::to_string(size) + "! Initialization failed!");
55 | return -1;
56 | }
57 |
58 | kdl_p_(0) = parameters.at(0);
59 | kdl_p_(1) = parameters.at(1);
60 | kdl_p_(2) = parameters.at(2);
61 | radius_ = parameters.at(3);
62 |
63 | eigen_p_ << kdl_p_(0), kdl_p_(1), kdl_p_(2);
64 | return 0;
65 | }
66 |
67 | inline const KDL::Vector& getCenterKDL() { return kdl_p_; }
68 | inline const Eigen::Vector3d& getCenterEigen() { return eigen_p_; }
69 |
70 | inline double getRadius() { return radius_; }
71 | inline double getX() { return kdl_p_(0); }
72 | inline double getY() { return kdl_p_(1); }
73 | inline double getZ() { return kdl_p_(2); }
74 |
75 | protected:
76 | KDL::Vector kdl_p_; // the offset of the sphere
77 | Eigen::Vector3d eigen_p_;
78 | double radius_; // the radius of the sphere
79 |
80 | private:
81 | GeometricSphere(const GeometricSphere& other) = delete;
82 | GeometricSphere(GeometricSphere&& other) = delete;
83 | GeometricSphere& operator=(const GeometricSphere& other) = delete;
84 | GeometricSphere& operator=(GeometricSphere&& other) noexcept = delete;
85 | };
86 |
87 | } // namespace geometric_primitives
88 |
89 | } // namespace hiqp
90 |
91 | #endif // include guard
--------------------------------------------------------------------------------
/hiqp_ros/include/hiqp_ros/hiqp_joint_effort_controller.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_JOINT_EFFORT_CONTROLLER_H
18 | #define HIQP_JOINT_EFFORT_CONTROLLER_H
19 |
20 | #include
21 |
22 | #include
23 | #include
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | namespace hiqp_ros {
31 | typedef hardware_interface::EffortJointInterface JointEffortInterface;
32 |
33 | /*! \brief A joint effort controller that provides full access to the HiQP control framework
34 | * \author Marcus A Johansson */
35 | class HiQPJointEffortController : public BaseController {
36 | public:
37 | HiQPJointEffortController();
38 | ~HiQPJointEffortController() noexcept;
39 |
40 | void initialize();
41 | void computeControls(Eigen::VectorXd& u);
42 |
43 | private:
44 | HiQPJointEffortController(const HiQPJointEffortController& other) = delete;
45 | HiQPJointEffortController(HiQPJointEffortController&& other) = delete;
46 | HiQPJointEffortController& operator=(const HiQPJointEffortController& other) = delete;
47 | HiQPJointEffortController& operator=(HiQPJointEffortController&& other) noexcept = delete;
48 |
49 | void monitorTasks();
50 | void renderPrimitives();
51 |
52 | void loadRenderingParameters();
53 | int loadAndSetupTaskMonitoring();
54 | // void addAllTopicSubscriptions();
55 | void loadJointLimitsFromParamServer();
56 | void loadGeometricPrimitivesFromParamServer();
57 | void loadTasksFromParamServer();
58 |
59 | bool is_active_;
60 |
61 | bool monitoring_active_;
62 | double monitoring_publish_rate_;
63 | ros::Time last_monitoring_update_;
64 |
65 | double rendering_publish_rate_;
66 | ros::Time last_rendering_update_;
67 |
68 | ros::Publisher monitoring_pub_;
69 |
70 | ROSTopicSubscriber topic_subscriber_;
71 |
72 | HiQPServiceHandler service_handler_; // takes care of all ros service calls
73 |
74 | ROSVisualizer ros_visualizer_;
75 | std::shared_ptr visualizer_;
76 |
77 | hiqp::TaskManager task_manager_;
78 | std::shared_ptr task_manager_ptr_;
79 |
80 | };
81 |
82 | } // namespace hiqp_ros
83 |
84 | #endif // include guard
85 |
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/tasks/tdef_geometric_projection.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_TDEF_GEOMETRIC_PROJECTION_H
18 | #define HIQP_TDEF_GEOMETRIC_PROJECTION_H
19 |
20 | #include
21 | #include
22 |
23 | #include
24 | #include
25 |
26 | #include
27 | #include
28 |
29 | namespace hiqp
30 | {
31 | namespace tasks
32 | {
33 |
34 | /*! \brief A task definition that positions geometric primitives relative to each other through mutual geometric projection.
35 | * \author Marcus A Johansson */
36 | template
37 | class TDefGeometricProjection : public TaskDefinition {
38 | public:
39 | TDefGeometricProjection(std::shared_ptr geom_prim_map,
40 | std::shared_ptr visualizer);
41 | ~TDefGeometricProjection() noexcept = default;
42 |
43 | int init(const std::vector& parameters,
44 | RobotStatePtr robot_state);
45 |
46 | int update(RobotStatePtr robot_state);
47 |
48 | int monitor();
49 |
50 | private:
51 | TDefGeometricProjection(const TDefGeometricProjection& other) = delete;
52 | TDefGeometricProjection(TDefGeometricProjection&& other) = delete;
53 | TDefGeometricProjection& operator=(const TDefGeometricProjection& other) = delete;
54 | TDefGeometricProjection& operator=(TDefGeometricProjection&& other) noexcept = delete;
55 |
56 | int project(std::shared_ptr first, std::shared_ptr second);
57 |
58 | /// \brief This sets jacobian columns corresponding to non-writable joints to 0
59 | void maskJacobian(RobotStatePtr robot_state);
60 |
61 | /*! \brief Computes column number q_nr of the resulting jacobian for the
62 | * vector (p2-p1), NOTE! p1 must be related to pose_a_ and p2 to
63 | * pose_b_ !
64 | */
65 | KDL::Vector getVelocityJacobianForTwoPoints
66 | (
67 | const KDL::Vector& p1,
68 | const KDL::Vector& p2,
69 | int q_nr
70 | );
71 |
72 | std::shared_ptr fk_solver_pos_;
73 | std::shared_ptr fk_solver_jac_;
74 |
75 | std::shared_ptr primitive_a_;
76 | KDL::Frame pose_a_;
77 | KDL::Jacobian jacobian_a_;
78 |
79 | std::shared_ptr primitive_b_;
80 | KDL::Frame pose_b_;
81 | KDL::Jacobian jacobian_b_;
82 | };
83 |
84 | } // namespace tasks
85 |
86 | } // namespace hiqp
87 |
88 | #include
89 |
90 | #endif // include guard
91 |
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/geometric_primitives/geometric_plane.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_GEOMETRIC_PLANE_H
18 | #define HIQP_GEOMETRIC_PLANE_H
19 |
20 | #include
21 | #include
22 |
23 | #include
24 |
25 | namespace hiqp
26 | {
27 | namespace geometric_primitives
28 | {
29 |
30 | /*! \brief Parameters: [n.x, n.y, n.z, offset]. The plane equation corresponds to \f$n^T*x-offset=0\f$.
31 | * \author Marcus A Johansson */
32 | class GeometricPlane : public GeometricPrimitive {
33 | public:
34 | GeometricPlane(const std::string& name,
35 | const std::string& frame_id,
36 | bool visible,
37 | const std::vector& color)
38 | : GeometricPrimitive(name, frame_id, visible, color) {}
39 |
40 | ~GeometricPlane() noexcept = default;
41 |
42 | /*! \brief Parses a set of parameters and initializes the plane.
43 | * \param parameters : Should be of size 4.
44 | * - Indices 0-2 (required) defines the normal vector of the plane.
45 | * - Index 3 (required) defines the offset of the plane in the normal direction.
46 | *
47 | * \return 0 on success, -1 if the wrong number of parameters was sent. */
48 | int init(const std::vector& parameters) {
49 | int size = parameters.size();
50 | if (size != 4) {
51 | printHiqpWarning("GeometricPlane requires 4 parameters, got "
52 | + std::to_string(size) + "! Initialization failed!");
53 | return -1;
54 | }
55 |
56 | kdl_n_(0) = parameters.at(0);
57 | kdl_n_(1) = parameters.at(1);
58 | kdl_n_(2) = parameters.at(2);
59 |
60 | kdl_n_.Normalize();
61 | eigen_n_ << kdl_n_(0), kdl_n_(1), kdl_n_(2);
62 | d_ = parameters.at(3);
63 | return 0;
64 | }
65 |
66 | inline const KDL::Vector& getNormalKDL() { return kdl_n_; }
67 | inline const Eigen::Vector3d& getNormalEigen() { return eigen_n_; }
68 |
69 | inline double getOffset() { return d_; }
70 | inline double getNormalX() { return kdl_n_(0); }
71 | inline double getNormalY() { return kdl_n_(1); }
72 | inline double getNormalZ() { return kdl_n_(2); }
73 |
74 | protected:
75 | KDL::Vector kdl_n_; // the normal vector or the plane
76 | Eigen::Vector3d eigen_n_;
77 | double d_; // the offset in the normal direction
78 |
79 | private:
80 | GeometricPlane(const GeometricPlane& other) = delete;
81 | GeometricPlane(GeometricPlane&& other) = delete;
82 | GeometricPlane& operator=(const GeometricPlane& other) = delete;
83 | GeometricPlane& operator=(GeometricPlane&& other) noexcept = delete;
84 | };
85 |
86 | } // namespace geometric_primitives
87 |
88 | } // namespace hiqp
89 |
90 | #endif // include guard
91 |
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/task_dynamics.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_TASK_DYNAMICS_H
18 | #define HIQP_TASK_DYNAMICS_H
19 |
20 | #include
21 | #include
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | #include
28 |
29 | namespace hiqp
30 | {
31 |
32 | using geometric_primitives::GeometricPrimitiveMap;
33 |
34 | class Task;
35 |
36 | /*! \brief A task dynamics enforces the optimizer to produce controls that results is a certain velocity of the task performance value.
37 | * \author Marcus A Johansson */
38 | class TaskDynamics
39 | {
40 | public:
41 | TaskDynamics(std::shared_ptr geom_prim_map,
42 | std::shared_ptr visualizer)
43 | : geometric_primitive_map_(geom_prim_map), visualizer_(visualizer)
44 | {}
45 |
46 | ~TaskDynamics() noexcept {}
47 |
48 | virtual int init(const std::vector& parameters,
49 | RobotStatePtr robot_state,
50 | const Eigen::VectorXd& e_initial,
51 | const Eigen::VectorXd& e_final) = 0;
52 |
53 | virtual int update(RobotStatePtr robot_state,
54 | const Eigen::VectorXd& e,
55 | const Eigen::MatrixXd& J) = 0;
56 |
57 | virtual int monitor() = 0;
58 |
59 | protected:
60 | Eigen::VectorXd e_dot_star_;
61 | Eigen::VectorXd performance_measures_;
62 |
63 | inline std::string getTaskName() { return task_name_; }
64 | inline unsigned int getPriority() { return priority_; }
65 | inline bool getActive() { return active_; }
66 | inline bool getVisible() { return visible_; }
67 | inline std::shared_ptr
68 | getVisualizer() { return visualizer_; }
69 | inline std::shared_ptr
70 | getGeometricPrimitiveMap() { return geometric_primitive_map_; }
71 |
72 | private:
73 | friend Task;
74 |
75 | std::shared_ptr geometric_primitive_map_;
76 | std::shared_ptr visualizer_;
77 |
78 | std::string task_name_;
79 | unsigned int priority_;
80 | bool visible_;
81 | bool active_;
82 |
83 | TaskDynamics(const TaskDynamics& other) = delete;
84 | TaskDynamics(TaskDynamics&& other) = delete;
85 | TaskDynamics& operator=(const TaskDynamics& other) = delete;
86 | TaskDynamics& operator=(TaskDynamics&& other) noexcept = delete;
87 | };
88 |
89 | } // namespace hiqp
90 |
91 | #endif // include guard
--------------------------------------------------------------------------------
/hiqp_core/include/hiqp/solvers/gurobi_solver.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_GUROBI_SOLVER_H
18 | #define HIQP_GUROBI_SOLVER_H
19 |
20 | #include
21 | #include
22 |
23 | namespace hiqp
24 | {
25 | /*! \brief An optimization based solver for a set of stages based on Gurobi.
26 | * \author Robert Krug, Marcus A Johansson */
27 | class GurobiSolver : public HiQPSolver {
28 | public:
29 | GurobiSolver();
30 | ~GurobiSolver() noexcept {}
31 |
32 | /*! \brief Builds and solves the QP:
33 | * min 0.5x^2 + 0.5w^2
34 | * where J*dq + w = de*
35 | */
36 | bool solve(std::vector& solution);
37 |
38 | private:
39 | GurobiSolver(const GurobiSolver& other) = delete;
40 | GurobiSolver(GurobiSolver&& other) = delete;
41 | GurobiSolver& operator=(const GurobiSolver& other) = delete;
42 | GurobiSolver& operator=(GurobiSolver&& other) noexcept = delete;
43 |
44 | struct HQPConstraints {
45 | HQPConstraints() : n_acc_stage_dims_(0) {}
46 |
47 | void reset(unsigned int n_solution_dims);
48 | void appendConstraints(const HiQPStage& current_stage);
49 |
50 | unsigned int n_acc_stage_dims_; // number of accumulated dimensions of all the previously solved stages
51 | unsigned int n_stage_dims_; // number of dimensions of the current stage
52 | Eigen::VectorXd w_;
53 | Eigen::VectorXd de_;
54 | Eigen::MatrixXd J_;
55 | std::vector constraint_signs_;
56 | };
57 |
58 | struct QPProblem {
59 | QPProblem(const GRBEnv& env,
60 | HQPConstraints& hqp_constraints,
61 | unsigned int solution_dims);
62 |
63 | ~QPProblem();
64 |
65 | void setup();
66 | void solve();
67 | void getSolution(std::vector& solution);
68 |
69 | GRBModel model_; // Gurobi model (one per each QP problem is used)
70 | HQPConstraints& hqp_constraints_;
71 | unsigned int solution_dims_;
72 |
73 | GRBVar* dq_; // objective variables for joint velocities
74 | double* lb_dq_; // lower bounds for dq
75 | double* ub_dq_; // upper bounds for dq
76 |
77 | GRBVar* w_; // slack variables
78 | double* lb_w_; // lower bounds for w
79 | double* ub_w_; // upper bounds for w
80 |
81 | double* rhsides_; // Right-hand-side constants
82 | GRBLinExpr* lhsides_; // Left-hand-side expressions
83 | double* coeff_dq_; // Coeffs of dq in LHS expression
84 | double* coeff_w_; // Coeffs of w in LHS expression
85 |
86 | GRBConstr* constraints_; //
87 | };
88 |
89 | GRBEnv env_;
90 | unsigned int n_solution_dims_; // number of solution dimensions
91 | HQPConstraints hqp_constraints_;
92 | };
93 |
94 | } // namespace hiqp
95 |
96 | #endif // include guard
97 |
--------------------------------------------------------------------------------
/hiqp_ros/include/hiqp_ros/hiqp_joint_velocity_controller.h:
--------------------------------------------------------------------------------
1 | // The HiQP Control Framework, an optimal control framework targeted at robotics
2 | // Copyright (C) 2016 Marcus A Johansson
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef HIQP_JOINT_VELOCITY_CONTROLLER_H
18 | #define HIQP_JOINT_VELOCITY_CONTROLLER_H
19 |
20 | #include
21 | #include
22 |
23 | #include
24 | #include
25 |
26 | #include
27 | #include
28 | #include
29 | #include
30 |
31 | #include
32 | #include
33 |
34 | #include