MatthewPeterKelly / MatthewPeterKelly/OptimTraj
Problem with initial guess P.x0
Nobody has claimed this yet.
- Dominant language
- MATLAB
- Stars
- 703
- Forks
- 219
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I wrote the matlab function which calculates dynamics for an inverted pendulum and I would like to use OtimTraj to find a Swingup Trajectory however as I run the simulation I see this warning from FMINCON :
Your initial point x0 is not between bounds lb and ub; FMINCON
shifted x0 to strictly satisfy the bounds.
Hier is how P.x0 looks like :

and after that this warning :
Warning: Matrix is close to singular or badly scaled. Results may
be inaccurate. RCOND = 3.066313e-18
Hier is how I set the initial conditions and boundries :
( as an Input I use the Cart's acceleration ! )
`clc; clear;
addpath OptimTraj
dist = 0 ;
maxForce = 40;
duration = 2;
problem.func.dynamics = @(t,x,u)( invPendDynamics(x,u) );
problem.func.pathObj = @(t,x,u)( u.^2 ); %Force-squared cost function
problem.boundslow = 0;
problem.bounds.initialTime.upp = 0;
problem.bounds.finalTime.low = duration;
problem.bounds.finalTime.upp = duration;
problem.bounds.initialState.low = [0;pi;0;0];
problem.bounds.initialState.upp = [0;pi;0;0];
problem.bounds.finalState.low = [0;0;0;0];
problem.bounds.finalState.upp = [0;0;0;0];
problem.bounds.state.low = [-2;-2pi;-inf;-inf];
problem.bounds.state.upp = [2;2pi;inf;inf];
problem.bounds.control.low = -maxForce;
problem.bounds.control.upp = maxForce;
problem.guess.time = [0,duration];
problem.guess.state = [problem.bounds.initialState.low, problem.bounds.finalState.low];
problem.guess.control = [0,0];
`
Do you know what might be causing the error ?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the warning with the provided OptimTraj setup, including the bounds, initial guess, and invPendDynamics entry point. Inspect how the FMINCON initial point is formed and verify the dynamics for numerical conditioning; done means identifying the cause of the bound and singularity warnings and documenting or validating a correction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- matlab
- Domain
- robotics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100