Skip to content

Commit d137f7c

Browse files
authored
refactor(osqp_interface): added autoware prefix to osqp_interface (#8958)
Signed-off-by: Esteve Fernandez <esteve.fernandez@tier4.jp>
1 parent a71ef19 commit d137f7c

File tree

26 files changed

+81
-105
lines changed

26 files changed

+81
-105
lines changed

common/osqp_interface/CMakeLists.txt common/autoware_osqp_interface/CMakeLists.txt

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.14)
2-
project(osqp_interface)
2+
project(autoware_osqp_interface)
33

44
find_package(autoware_cmake REQUIRED)
55
autoware_package()
@@ -17,9 +17,9 @@ set(OSQP_INTERFACE_LIB_SRC
1717
)
1818

1919
set(OSQP_INTERFACE_LIB_HEADERS
20-
include/osqp_interface/csc_matrix_conv.hpp
21-
include/osqp_interface/osqp_interface.hpp
22-
include/osqp_interface/visibility_control.hpp
20+
include/autoware/osqp_interface/csc_matrix_conv.hpp
21+
include/autoware/osqp_interface/osqp_interface.hpp
22+
include/autoware/osqp_interface/visibility_control.hpp
2323
)
2424

2525
ament_auto_add_library(${PROJECT_NAME} SHARED
@@ -28,18 +28,18 @@ ament_auto_add_library(${PROJECT_NAME} SHARED
2828
)
2929
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-error=old-style-cast -Wno-error=useless-cast)
3030

31-
target_include_directories(osqp_interface
31+
target_include_directories(${PROJECT_NAME}
3232
SYSTEM PUBLIC
3333
"${OSQP_INCLUDE_DIR}"
3434
"${EIGEN3_INCLUDE_DIR}"
3535
)
3636

37-
ament_target_dependencies(osqp_interface
37+
ament_target_dependencies(${PROJECT_NAME}
3838
Eigen3
3939
osqp_vendor
4040
)
4141

42-
# crucial so downstream package builds because osqp_interface exposes osqp.hpp
42+
# crucial so downstream package builds because autoware_osqp_interface exposes osqp.hpp
4343
ament_export_include_directories("${OSQP_INCLUDE_DIR}")
4444
# crucial so the linking order is correct in a downstream package: libosqp_interface.a should come before libosqp.a
4545
ament_export_libraries(osqp::osqp)

common/osqp_interface/design/osqp_interface-design.md common/autoware_osqp_interface/design/osqp_interface-design.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Interface for the OSQP library
22

3-
This is the design document for the `osqp_interface` package.
3+
This is the design document for the `autoware_osqp_interface` package.
44

55
## Purpose / Use cases
66

common/osqp_interface/include/osqp_interface/csc_matrix_conv.hpp common/autoware_osqp_interface/include/autoware/osqp_interface/csc_matrix_conv.hpp

+6-12
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,17 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifndef OSQP_INTERFACE__CSC_MATRIX_CONV_HPP_
16-
#define OSQP_INTERFACE__CSC_MATRIX_CONV_HPP_
15+
#ifndef AUTOWARE__OSQP_INTERFACE__CSC_MATRIX_CONV_HPP_
16+
#define AUTOWARE__OSQP_INTERFACE__CSC_MATRIX_CONV_HPP_
1717

18+
#include "autoware/osqp_interface/visibility_control.hpp"
1819
#include "osqp/glob_opts.h" // for 'c_int' type ('long' or 'long long')
19-
#include "osqp_interface/visibility_control.hpp"
2020

2121
#include <Eigen/Core>
2222

2323
#include <vector>
2424

25-
namespace autoware
26-
{
27-
namespace common
28-
{
29-
namespace osqp
25+
namespace autoware::osqp_interface
3026
{
3127
/// \brief Compressed-Column-Sparse Matrix
3228
struct OSQP_INTERFACE_PUBLIC CSC_Matrix
@@ -46,8 +42,6 @@ OSQP_INTERFACE_PUBLIC CSC_Matrix calCSCMatrixTrapezoidal(const Eigen::MatrixXd &
4642
/// \brief Print the given CSC matrix to the standard output
4743
OSQP_INTERFACE_PUBLIC void printCSCMatrix(const CSC_Matrix & csc_mat);
4844

49-
} // namespace osqp
50-
} // namespace common
51-
} // namespace autoware
45+
} // namespace autoware::osqp_interface
5246

53-
#endif // OSQP_INTERFACE__CSC_MATRIX_CONV_HPP_
47+
#endif // AUTOWARE__OSQP_INTERFACE__CSC_MATRIX_CONV_HPP_

common/osqp_interface/include/osqp_interface/osqp_interface.hpp common/autoware_osqp_interface/include/autoware/osqp_interface/osqp_interface.hpp

+7-13
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifndef OSQP_INTERFACE__OSQP_INTERFACE_HPP_
16-
#define OSQP_INTERFACE__OSQP_INTERFACE_HPP_
15+
#ifndef AUTOWARE__OSQP_INTERFACE__OSQP_INTERFACE_HPP_
16+
#define AUTOWARE__OSQP_INTERFACE__OSQP_INTERFACE_HPP_
1717

18+
#include "autoware/osqp_interface/csc_matrix_conv.hpp"
19+
#include "autoware/osqp_interface/visibility_control.hpp"
1820
#include "osqp/osqp.h"
19-
#include "osqp_interface/csc_matrix_conv.hpp"
20-
#include "osqp_interface/visibility_control.hpp"
2121

2222
#include <Eigen/Core>
2323
#include <rclcpp/rclcpp.hpp>
@@ -28,11 +28,7 @@
2828
#include <tuple>
2929
#include <vector>
3030

31-
namespace autoware
32-
{
33-
namespace common
34-
{
35-
namespace osqp
31+
namespace autoware::osqp_interface
3632
{
3733
constexpr c_float INF = 1e30;
3834

@@ -193,8 +189,6 @@ class OSQP_INTERFACE_PUBLIC OSQPInterface
193189
void logUnsolvedStatus(const std::string & prefix_message = "") const;
194190
};
195191

196-
} // namespace osqp
197-
} // namespace common
198-
} // namespace autoware
192+
} // namespace autoware::osqp_interface
199193

200-
#endif // OSQP_INTERFACE__OSQP_INTERFACE_HPP_
194+
#endif // AUTOWARE__OSQP_INTERFACE__OSQP_INTERFACE_HPP_

common/osqp_interface/include/osqp_interface/visibility_control.hpp common/autoware_osqp_interface/include/autoware/osqp_interface/visibility_control.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifndef OSQP_INTERFACE__VISIBILITY_CONTROL_HPP_
16-
#define OSQP_INTERFACE__VISIBILITY_CONTROL_HPP_
15+
#ifndef AUTOWARE__OSQP_INTERFACE__VISIBILITY_CONTROL_HPP_
16+
#define AUTOWARE__OSQP_INTERFACE__VISIBILITY_CONTROL_HPP_
1717

1818
////////////////////////////////////////////////////////////////////////////////
1919
#if defined(__WIN32)
@@ -34,4 +34,4 @@
3434
#error "Unsupported Build Configuration"
3535
#endif
3636

37-
#endif // OSQP_INTERFACE__VISIBILITY_CONTROL_HPP_
37+
#endif // AUTOWARE__OSQP_INTERFACE__VISIBILITY_CONTROL_HPP_

common/osqp_interface/package.xml common/autoware_osqp_interface/package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="3">
4-
<name>osqp_interface</name>
4+
<name>autoware_osqp_interface</name>
55
<version>1.0.0</version>
66
<description>Interface for the OSQP solver</description>
77
<maintainer email="maxime.clement@tier4.jp">Maxime CLEMENT</maintainer>

common/osqp_interface/src/csc_matrix_conv.cpp common/autoware_osqp_interface/src/csc_matrix_conv.cpp

+3-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "osqp_interface/csc_matrix_conv.hpp"
15+
#include "autoware/osqp_interface/csc_matrix_conv.hpp"
1616

1717
#include <Eigen/Core>
1818
#include <Eigen/SparseCore>
@@ -21,11 +21,7 @@
2121
#include <iostream>
2222
#include <vector>
2323

24-
namespace autoware
25-
{
26-
namespace common
27-
{
28-
namespace osqp
24+
namespace autoware::osqp_interface
2925
{
3026
CSC_Matrix calCSCMatrix(const Eigen::MatrixXd & mat)
3127
{
@@ -136,6 +132,4 @@ void printCSCMatrix(const CSC_Matrix & csc_mat)
136132
std::cout << "]\n";
137133
}
138134

139-
} // namespace osqp
140-
} // namespace common
141-
} // namespace autoware
135+
} // namespace autoware::osqp_interface

common/osqp_interface/src/osqp_interface.cpp common/autoware_osqp_interface/src/osqp_interface.cpp

+4-10
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "osqp_interface/osqp_interface.hpp"
15+
#include "autoware/osqp_interface/osqp_interface.hpp"
1616

17+
#include "autoware/osqp_interface/csc_matrix_conv.hpp"
1718
#include "osqp/osqp.h"
18-
#include "osqp_interface/csc_matrix_conv.hpp"
1919

2020
#include <chrono>
2121
#include <iostream>
@@ -25,11 +25,7 @@
2525
#include <tuple>
2626
#include <vector>
2727

28-
namespace autoware
29-
{
30-
namespace common
31-
{
32-
namespace osqp
28+
namespace autoware::osqp_interface
3329
{
3430
OSQPInterface::OSQPInterface(const c_float eps_abs, const bool polish)
3531
: m_work{nullptr, OSQPWorkspaceDeleter}
@@ -436,6 +432,4 @@ void OSQPInterface::logUnsolvedStatus(const std::string & prefix_message) const
436432
// log with warning
437433
RCLCPP_WARN(rclcpp::get_logger("osqp_interface"), output_message.c_str());
438434
}
439-
} // namespace osqp
440-
} // namespace common
441-
} // namespace autoware
435+
} // namespace autoware::osqp_interface

common/osqp_interface/test/test_csc_matrix_conv.cpp common/autoware_osqp_interface/test/test_csc_matrix_conv.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#include "autoware/osqp_interface/csc_matrix_conv.hpp"
1516
#include "gtest/gtest.h"
16-
#include "osqp_interface/csc_matrix_conv.hpp"
1717

1818
#include <Eigen/Core>
1919

@@ -23,8 +23,8 @@
2323

2424
TEST(TestCscMatrixConv, Nominal)
2525
{
26-
using autoware::common::osqp::calCSCMatrix;
27-
using autoware::common::osqp::CSC_Matrix;
26+
using autoware::osqp_interface::calCSCMatrix;
27+
using autoware::osqp_interface::CSC_Matrix;
2828

2929
Eigen::MatrixXd rect1(1, 2);
3030
rect1 << 0.0, 1.0;
@@ -117,8 +117,8 @@ TEST(TestCscMatrixConv, Nominal)
117117
}
118118
TEST(TestCscMatrixConv, Trapezoidal)
119119
{
120-
using autoware::common::osqp::calCSCMatrixTrapezoidal;
121-
using autoware::common::osqp::CSC_Matrix;
120+
using autoware::osqp_interface::calCSCMatrixTrapezoidal;
121+
using autoware::osqp_interface::CSC_Matrix;
122122

123123
Eigen::MatrixXd square1(2, 2);
124124
Eigen::MatrixXd square2(3, 3);
@@ -166,10 +166,10 @@ TEST(TestCscMatrixConv, Trapezoidal)
166166
}
167167
TEST(TestCscMatrixConv, Print)
168168
{
169-
using autoware::common::osqp::calCSCMatrix;
170-
using autoware::common::osqp::calCSCMatrixTrapezoidal;
171-
using autoware::common::osqp::CSC_Matrix;
172-
using autoware::common::osqp::printCSCMatrix;
169+
using autoware::osqp_interface::calCSCMatrix;
170+
using autoware::osqp_interface::calCSCMatrixTrapezoidal;
171+
using autoware::osqp_interface::CSC_Matrix;
172+
using autoware::osqp_interface::printCSCMatrix;
173173
Eigen::MatrixXd square1(2, 2);
174174
Eigen::MatrixXd rect1(1, 2);
175175
square1 << 1.0, 2.0, 2.0, 4.0;

common/osqp_interface/test/test_osqp_interface.cpp common/autoware_osqp_interface/test/test_osqp_interface.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#include "autoware/osqp_interface/osqp_interface.hpp"
1516
#include "gtest/gtest.h"
16-
#include "osqp_interface/osqp_interface.hpp"
1717

1818
#include <Eigen/Core>
1919

@@ -39,9 +39,9 @@ namespace
3939

4040
TEST(TestOsqpInterface, BasicQp)
4141
{
42-
using autoware::common::osqp::calCSCMatrix;
43-
using autoware::common::osqp::calCSCMatrixTrapezoidal;
44-
using autoware::common::osqp::CSC_Matrix;
42+
using autoware::osqp_interface::calCSCMatrix;
43+
using autoware::osqp_interface::calCSCMatrixTrapezoidal;
44+
using autoware::osqp_interface::CSC_Matrix;
4545

4646
auto check_result =
4747
[](const std::tuple<std::vector<double>, std::vector<double>, int, int, int> & result) {
@@ -66,20 +66,20 @@ TEST(TestOsqpInterface, BasicQp)
6666
const Eigen::MatrixXd P = (Eigen::MatrixXd(2, 2) << 4, 1, 1, 2).finished();
6767
const Eigen::MatrixXd A = (Eigen::MatrixXd(4, 2) << 1, 1, 1, 0, 0, 1, 0, 1).finished();
6868
const std::vector<double> q = {1.0, 1.0};
69-
const std::vector<double> l = {1.0, 0.0, 0.0, -autoware::common::osqp::INF};
70-
const std::vector<double> u = {1.0, 0.7, 0.7, autoware::common::osqp::INF};
69+
const std::vector<double> l = {1.0, 0.0, 0.0, -autoware::osqp_interface::INF};
70+
const std::vector<double> u = {1.0, 0.7, 0.7, autoware::osqp_interface::INF};
7171

7272
{
7373
// Define problem during optimization
74-
autoware::common::osqp::OSQPInterface osqp;
74+
autoware::osqp_interface::OSQPInterface osqp;
7575
std::tuple<std::vector<double>, std::vector<double>, int, int, int> result =
7676
osqp.optimize(P, A, q, l, u);
7777
check_result(result);
7878
}
7979

8080
{
8181
// Define problem during initialization
82-
autoware::common::osqp::OSQPInterface osqp(P, A, q, l, u, 1e-6);
82+
autoware::osqp_interface::OSQPInterface osqp(P, A, q, l, u, 1e-6);
8383
std::tuple<std::vector<double>, std::vector<double>, int, int, int> result = osqp.optimize();
8484
check_result(result);
8585
}
@@ -92,7 +92,7 @@ TEST(TestOsqpInterface, BasicQp)
9292
std::vector<double> q_ini(2, 0.0);
9393
std::vector<double> l_ini(4, 0.0);
9494
std::vector<double> u_ini(4, 0.0);
95-
autoware::common::osqp::OSQPInterface osqp(P_ini, A_ini, q_ini, l_ini, u_ini, 1e-6);
95+
autoware::osqp_interface::OSQPInterface osqp(P_ini, A_ini, q_ini, l_ini, u_ini, 1e-6);
9696
osqp.optimize();
9797

9898
// Redefine problem before optimization
@@ -105,7 +105,7 @@ TEST(TestOsqpInterface, BasicQp)
105105
// Define problem during initialization with csc matrix
106106
CSC_Matrix P_csc = calCSCMatrixTrapezoidal(P);
107107
CSC_Matrix A_csc = calCSCMatrix(A);
108-
autoware::common::osqp::OSQPInterface osqp(P_csc, A_csc, q, l, u, 1e-6);
108+
autoware::osqp_interface::OSQPInterface osqp(P_csc, A_csc, q, l, u, 1e-6);
109109
std::tuple<std::vector<double>, std::vector<double>, int, int, int> result = osqp.optimize();
110110
check_result(result);
111111
}
@@ -118,7 +118,7 @@ TEST(TestOsqpInterface, BasicQp)
118118
std::vector<double> q_ini(2, 0.0);
119119
std::vector<double> l_ini(4, 0.0);
120120
std::vector<double> u_ini(4, 0.0);
121-
autoware::common::osqp::OSQPInterface osqp(P_ini_csc, A_ini_csc, q_ini, l_ini, u_ini, 1e-6);
121+
autoware::osqp_interface::OSQPInterface osqp(P_ini_csc, A_ini_csc, q_ini, l_ini, u_ini, 1e-6);
122122
osqp.optimize();
123123

124124
// Redefine problem before optimization
@@ -138,7 +138,7 @@ TEST(TestOsqpInterface, BasicQp)
138138
std::vector<double> q_ini(2, 0.0);
139139
std::vector<double> l_ini(4, 0.0);
140140
std::vector<double> u_ini(4, 0.0);
141-
autoware::common::osqp::OSQPInterface osqp(P_ini_csc, A_ini_csc, q_ini, l_ini, u_ini, 1e-6);
141+
autoware::osqp_interface::OSQPInterface osqp(P_ini_csc, A_ini_csc, q_ini, l_ini, u_ini, 1e-6);
142142
osqp.optimize();
143143

144144
// Redefine problem before optimization

control/autoware_mpc_lateral_controller/include/autoware/mpc_lateral_controller/qp_solver/qp_solver_osqp.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#define AUTOWARE__MPC_LATERAL_CONTROLLER__QP_SOLVER__QP_SOLVER_OSQP_HPP_
1717

1818
#include "autoware/mpc_lateral_controller/qp_solver/qp_solver_interface.hpp"
19-
#include "osqp_interface/osqp_interface.hpp"
19+
#include "autoware/osqp_interface/osqp_interface.hpp"
2020
#include "rclcpp/rclcpp.hpp"
2121

2222
namespace autoware::motion::control::mpc_lateral_controller
@@ -58,7 +58,7 @@ class QPSolverOSQP : public QPSolverInterface
5858
double getObjVal() const override { return osqpsolver_.getObjVal(); }
5959

6060
private:
61-
autoware::common::osqp::OSQPInterface osqpsolver_;
61+
autoware::osqp_interface::OSQPInterface osqpsolver_;
6262
rclcpp::Logger logger_;
6363
};
6464
} // namespace autoware::motion::control::mpc_lateral_controller

control/autoware_mpc_lateral_controller/package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<depend>autoware_control_msgs</depend>
2121
<depend>autoware_interpolation</depend>
2222
<depend>autoware_motion_utils</depend>
23+
<depend>autoware_osqp_interface</depend>
2324
<depend>autoware_planning_msgs</depend>
2425
<depend>autoware_trajectory_follower_base</depend>
2526
<depend>autoware_universe_utils</depend>
@@ -29,7 +30,6 @@
2930
<depend>diagnostic_updater</depend>
3031
<depend>eigen</depend>
3132
<depend>geometry_msgs</depend>
32-
<depend>osqp_interface</depend>
3333
<depend>rclcpp</depend>
3434
<depend>rclcpp_components</depend>
3535
<depend>std_msgs</depend>

control/autoware_trajectory_follower_base/package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<depend>autoware_control_msgs</depend>
2424
<depend>autoware_interpolation</depend>
2525
<depend>autoware_motion_utils</depend>
26+
<depend>autoware_osqp_interface</depend>
2627
<depend>autoware_planning_msgs</depend>
2728
<depend>autoware_universe_utils</depend>
2829
<depend>autoware_vehicle_info_utils</depend>
@@ -31,7 +32,6 @@
3132
<depend>diagnostic_updater</depend>
3233
<depend>eigen</depend>
3334
<depend>geometry_msgs</depend>
34-
<depend>osqp_interface</depend>
3535
<depend>rclcpp</depend>
3636
<depend>rclcpp_components</depend>
3737
<depend>std_msgs</depend>

0 commit comments

Comments
 (0)