I am facing an issue with visualize(predict_solution), it shows an all-white screen. I have run all Moco examples with the visualiser without any issues. Moreover, when I open the GUI, load the model and then load my solution (.sto), it works fine. The problem is with running the visualiser with my solution through python. Therefore, I can still visualise my solution, but not without the trouble of opening the GUI and loading the solution.
Code
Code: Select all
import os
os.add_dll_directory("C:/OpenSim 4.4/bin")
import opensim as osim
import moco_solve_cycling_helpers as helpers
import numpy as np
crank_torque_driven_model = helpers.get_crank_torque_driven_model()
study = osim.MocoStudy()
problem = study.updProblem()
problem.setModelAsCopy(crank_torque_driven_model)
problem.setTimeBounds(0.0, 2.0)
problem.setStateInfoPattern('/jointset/gear/gear/value', [], 0.0, np.deg2rad(-180.0))
problem.setStateInfoPattern('/jointset/.*/speed', [], 0.0, [])
controlGoal = osim.MocoControlGoal('myeffort')
problem.addGoal(controlGoal)
solver = study.initCasADiSolver()
solver.set_num_mesh_intervals(25)
solver.set_optim_convergence_tolerance(1e-3)
solver.set_optim_constraint_tolerance(1e-3)
predict_solution = study.solve()
predict_solution.write('Results/torque_driven_predicted_cycling_solution.sto')
study.visualize(predict_solution)
I expected to visualise my predicted solution once that is finished.
Actual behaviour
It just opens the visualiser with a white background (see Figure). Additional context
- Actually, I'm using OpenSim 4.4, not 4.3.
- I have some objects in the model. I've tried adding them to the main python script path. But no luck.
- I added my model in case someone wants to try, the one I'm playing with is the crank_torque_driven_model.
I would greatly appreciate any help or guidance you can provide. Thank you in advance for your assistance!
Best regards,
Ana
---