Skip to content

Commit

Permalink
Update test_pyhelios.py
Browse files Browse the repository at this point in the history
  • Loading branch information
DimasfromLavoisier committed Dec 3, 2024
1 parent b52d787 commit 1cc3fdc
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 33 deletions.
2 changes: 1 addition & 1 deletion pytests/test_pyhelios.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def test_material(test_sim):
assert mat0.specularity == 0.0
assert mat0.specular_exponent == 0.0
assert mat0.classification == 0
assert np.isclose(mat0.kd[0], 0.20, atol=1e-2)
assert np.isclose(mat0.diffuse_components[0], 0.20, atol=1e-2)


def test_scanner(test_sim):
Expand Down
11 changes: 1 addition & 10 deletions src/python/SimulationCycleCallbackWrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,20 @@ class PySimulationCycleCallback : public SimulationCycleCallback {
std::vector<Trajectory>& trajectories,
const std::string& outpath) override {

if (is_callback_in_progress) {
//std::cout << "Callback already in progress, skipping." << std::endl;
return;
}
if (is_callback_in_progress) return;

is_callback_in_progress = true; // Set the flag to prevent recursion

py::gil_scoped_acquire acquire; // Acquire GIL before calling Python code
// std::cout << "EKFKOEKFEOF IT IS IN THE TRAMPOLINE" << std::endl;

py::object py_self = py::cast(this, py::return_value_policy::reference); // Reference to the Python object

if (py::hasattr(py_self, "__call__")) {
// std::cout << "EKFKOEKFEOF IT IS IN THE TRAMPOLINE 2" << std::endl;

// Convert C++ vectors to Python lists
py::list measurements_list = py::cast(measurements);
py::list trajectories_list = py::cast(trajectories);

// Call the Python __call__ method with converted arguments
// std::cout << "EKFKOEKFEOF IT IS IN THE TRAMPOLINE 3" << std::endl;
py_self.attr("__call__")(measurements_list, trajectories_list, outpath);
// std::cout << "EKFKOEKFEOF IT IS IN THE TRAMPOLINE 4" << std::endl;
} else {
throw std::runtime_error("Python __call__ method is missing on SimulationCycleCallback.");
}
Expand Down
22 changes: 0 additions & 22 deletions src/scanner/SingleScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,6 @@ void SingleScanner::applySettings(
std::shared_ptr<ScannerSettings> settings, size_t const idx
){
// Configure scanner and scanning device
std::cout<<"NOOOOOOOAWOY SingleScanner::applySettings"<<std::endl;
std::cout<<"settings->active: "<<settings->active<<std::endl;
std::cout<<"settings->pulseFreq_Hz: "<<settings->pulseFreq_Hz<<std::endl;
std::cout<<"settings->beamDivAngle: "<<settings->beamDivAngle<<std::endl;
std::cout<<"settings->trajectoryTimeInterval: "<<settings->trajectoryTimeInterval<<std::endl;

std::cout<<"scanDev beamDivergence_rad: "<<scanDev.beamDivergence_rad<<std::endl;
std::cout<<"scanDev beam quality: "<<scanDev.beamQuality<<std::endl;
std::cout<<"scanDev wavelength_m: "<<scanDev.wavelength_m<<std::endl;
std::cout<<"detector: "<<getDetector(0)<<std::endl;
std::cout<<"scannerHead: "<<getScannerHead(0)<<std::endl;
std::cout<<"beamDeflector: "<<getBeamDeflector(0)<<std::endl;
std::cout<<"FINISH NOOOOOOOAWOY SingleScanner::applySettings"<<std::endl;
setPulseFreq_Hz(settings->pulseFreq_Hz);
setActive(settings->active);
setBeamDivergence(settings->beamDivAngle, 0);
Expand All @@ -148,15 +135,6 @@ void SingleScanner::doSimStep(
){
// Check whether the scanner is active or not
bool const _isActive = isActive();
// std::cout<<"???????????????????????????????????"<<std::endl;
// std::cout<<"LALALALALALLA SingleScanner::doSimStep"<<std::endl;
// std::cout<<"_isActive: "<<_isActive<<std::endl;
// std::cout<<"legIndex: "<<legIndex<<std::endl;
// std::cout<<"currentGpsTime: "<<currentGpsTime<<std::endl;
// std::cout<<"cfg_setting_pulseFreq_Hz: "<<cfg_setting_pulseFreq_Hz<<std::endl;
// std::cout<<"absoluteMountPosition: "<<platform->getAbsoluteMountPosition()<<std::endl;
// std::cout<<"absoluteMountAttitude: "<<platform->getAbsoluteMountAttitude()<<std::endl;
// std::cout<<"???????????????????????????????????"<<std::endl;
// Simulate scanning devices
scanDev.doSimStep(
legIndex,
Expand Down

0 comments on commit 1cc3fdc

Please sign in to comment.