Skip to content

Commit 15164e8

Browse files
committed
Fix ROS/ROS2 generated interface issues
- allow small positive initial penalties in ROS/ROS2 - ROS/ROS2 messages: using uint64 to avoid overflow - update ROS2 test helpers to work reliably in micromamba/conda - update the related docs and MATLAB examples
1 parent ef0de71 commit 15164e8

14 files changed

Lines changed: 102 additions & 33 deletions

docs/content/example_navigation_ros_codegen.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ private:
326326
*/
327327
void updateInputData()
328328
{
329-
init_penalty = (params.initial_penalty > 1.0)
329+
init_penalty = (params.initial_penalty > std::numeric_limits<double>::epsilon())
330330
? params.initial_penalty
331331
: ROS_NODE_MPC_CONTROLLER_DEFAULT_INITIAL_PENALTY;
332332

docs/content/matlab-api.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ optimizer directory, MATLAB can read the TCP endpoint automatically:
115115
```matlab
116116
manifestPath = fullfile( ...
117117
pwd, ...
118-
'open-codegen', ...
118+
'python', ...
119119
'.python_test_build_ocp', ...
120120
'ocp_single_tcp', ...
121121
'optimizer_manifest.json');
@@ -155,7 +155,7 @@ provided:
155155
```matlab
156156
manifestPath = fullfile( ...
157157
pwd, ...
158-
'open-codegen', ...
158+
'python', ...
159159
'.python_test_build_ocp', ...
160160
'ocp_manifest_bindings', ...
161161
'optimizer_manifest.json');
@@ -172,7 +172,7 @@ state trajectory:
172172
```matlab
173173
manifestPath = fullfile( ...
174174
pwd, ...
175-
'open-codegen', ...
175+
'python', ...
176176
'.python_test_build_ocp', ...
177177
'ocp_multiple_tcp', ...
178178
'optimizer_manifest.json');

docs/content/python-ros.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The input parameters message follows the following specification:
2929
float64[] parameter # parameter p (mandatory)
3030
float64[] initial_guess # u0 (optional/recommended)
3131
float64[] initial_y # y0 (optional)
32-
float64 initial_penalty # initial penalty (optional)
32+
float64 initial_penalty # positive initial penalty (optional)
3333
```
3434

3535
An example of such a message is
@@ -41,6 +41,10 @@ initial_penalty: 1000,
4141
initial_y: []
4242
```
4343
44+
`initial_penalty` is applied whenever it is strictly greater than a small
45+
positive epsilon. If it is omitted, zero, or too close to zero, the generated
46+
default initial penalty is used instead.
47+
4448

4549
#### Result
4650

@@ -74,8 +78,8 @@ uint8 STATUS_NOT_CONVERGED_COST=3
7478
uint8 STATUS_NOT_CONVERGED_FINITE_COMPUTATION=4
7579
7680
float64[] solution # optimizer (solution)
77-
uint8 inner_iterations # number of inner iterations
78-
uint16 outer_iterations # number of outer iterations
81+
uint64 inner_iterations # number of inner iterations
82+
uint64 outer_iterations # number of outer iterations
7983
uint8 status # status code
8084
float64 cost # cost value at solution
8185
float64 norm_fpr # norm of FPR of last inner problem
@@ -182,4 +186,4 @@ OpEn generates a README file that you will find in `my_optimizers/rosenbrock/par
182186
- Compile with `catkin_make`
183187
- Run using the auto-generated launch file
184188

185-
Check out the auto-generated README.md file for details.
189+
Check out the auto-generated README.md file for details.

docs/content/python-ros2.mdx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ OpEn can generate ready-to-use ROS2 packages directly from a parametric optimize
2424

2525
The input message matches the [ROS1 package documentation](./python-ros#messages). The ROS2 output message additionally includes `error_code` and `error_message` fields so that invalid requests and solver failures can be reported with more detail.
2626

27+
For scalar warm-starting, `initial_penalty` is used whenever it is strictly
28+
greater than a small positive epsilon. If it is omitted, zero, or too close to
29+
zero, the generated default initial penalty is used instead.
30+
2731
## Configuration Parameters
2832

2933
The configuration parameters are the same as in the [ROS1 package documentation](./python-ros#configuration-parameters): you can configure the node rate, the input topic name, and the output topic name.
@@ -203,10 +207,10 @@ solve_time_ms: 0.2175
203207
uint8 STATUS_INVALID_REQUEST=5
204208
205209
float64[] solution # solution
206-
uint8 inner_iterations # number of inner iterations
207-
uint16 outer_iterations # number of outer iterations
210+
uint64 inner_iterations # number of inner iterations
211+
uint64 outer_iterations # number of outer iterations
208212
uint8 status # coarse status code
209-
int32 error_code # detailed error code (0 on success)
213+
uint16 error_code # detailed error code (0 on success)
210214
string error_message # detailed error message (empty on success)
211215
float64 cost # cost value at solution
212216
float64 norm_fpr # norm of FPR of last inner problem

docs/website/publish.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22
GIT_USER=alphaville \
3-
CURRENT_BRANCH=master \
3+
CURRENT_BRANCH=dev/release \
44
USE_SSH=true \
55
yarn deploy
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
float64[] parameter # parameter p (mandatory)
22
float64[] initial_guess # u0 (optional/recommended)
33
float64[] initial_y # y0 (optional)
4-
float64 initial_penalty # initial penalty (optional)
4+
float64 initial_penalty # positive initial penalty (optional)

python/opengen/templates/ros/OptimizationResult.msg

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ uint8 STATUS_NOT_CONVERGED_COST=3
66
uint8 STATUS_NOT_CONVERGED_FINITE_COMPUTATION=4
77

88
float64[] solution # optimizer (solution)
9-
uint8 inner_iterations # number of inner iterations
10-
uint16 outer_iterations # number of outer iterations
9+
uint64 inner_iterations # number of inner iterations
10+
uint64 outer_iterations # number of outer iterations
1111
uint8 status # status code
1212
float64 cost # cost at solution
1313
float64 norm_fpr # norm of FPR of last inner problem
@@ -16,4 +16,3 @@ float64[] lagrange_multipliers # vector of Lagrange multipliers
1616
float64 infeasibility_f1 # infeasibility wrt F1
1717
float64 infeasibility_f2 # infeasibility wrt F2
1818
float64 solve_time_ms # solution time in ms
19-

python/opengen/templates/ros/open_optimizer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* dually licensed under the MIT and Apache v2 licences.
66
*
77
*/
8+
#include <limits>
9+
810
#include "ros/ros.h"
911
#include "{{ros.package_name}}/OptimizationResult.h"
1012
#include "{{ros.package_name}}/OptimizationParameters.h"
@@ -70,7 +72,7 @@ class OptimizationEngineManager {
7072
*/
7173
void updateInputData()
7274
{
73-
init_penalty = (params.initial_penalty > 1.0)
75+
init_penalty = (params.initial_penalty > std::numeric_limits<double>::epsilon())
7476
? params.initial_penalty
7577
: ROS_NODE_{{meta.optimizer_name|upper}}_DEFAULT_INITIAL_PENALTY;
7678

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
float64[] parameter # parameter p (mandatory)
22
float64[] initial_guess # u0 (optional/recommended)
33
float64[] initial_y # y0 (optional)
4-
float64 initial_penalty # initial penalty (optional)
4+
float64 initial_penalty # positive initial penalty (optional)

python/opengen/templates/ros2/OptimizationResult.msg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ uint8 STATUS_NOT_CONVERGED_FINITE_COMPUTATION=4
77
uint8 STATUS_INVALID_REQUEST=5
88

99
float64[] solution # optimizer (solution)
10-
uint8 inner_iterations # number of inner iterations
11-
uint16 outer_iterations # number of outer iterations
10+
uint64 inner_iterations # number of inner iterations
11+
uint64 outer_iterations # number of outer iterations
1212
uint8 status # coarse status code
13-
int32 error_code # detailed error code (0 on success)
13+
uint16 error_code # detailed error code (0 on success)
1414
string error_message # detailed error message (empty on success)
1515
float64 cost # cost at solution
1616
float64 norm_fpr # norm of FPR of last inner problem

0 commit comments

Comments
 (0)