I am new to programming, I try to use python to access the global variable defined in the compiled dynamic library which compiled in c++.
int acc;
void Cassie2d::Step(ControllerTorque* action)
{
dyn_model_.setState(mj_data_->qpos, mj_data_->qvel);
dyn_state_.UpdateDynamicState(&dyn_model_);
mju_copy(mj_data_->ctrl, action->torques, nU);
mj_step(mj_model_, mj_data_);
acc = mj_data_->qacc;
Render();
}
The code above is c++ code, I define a global variable (int acc) to access the mj data qacc, once I compiled the whole c++ code and form a .so library, I try to use the variable acc in my python code, however, the acc did not exist, is anyone could tell me the problem is?
Or is there any good way to define the global variable in which the python code could access the library and find the global variable?