Skip to content

Implement hardstops for spinningBodiesOneDOF #646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ def test_spinning_body_enforces_limits(max_lim, min_lim):
spinningBody.theta_max = np.deg2rad(max_lim)
spinningBody.theta_min = np.deg2rad(min_lim)

with pytest.raises(ValueError):
spinningBody.Reset(0)
# with pytest.raises(ValueError) as exc:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please split and squash these commits to the final version to clean up the commit history.

spinningBody.Reset(0)


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ void SpinningBodyOneDOFStateEffector::Reset(uint64_t CurrentClock)
}
// Ensure user specified valid angular limits
if (this->theta_max < this->theta_min) {
bskLogger.bskLog(
BSK_ERROR, "theta_max (%f) must be greater than theta_min (%f).", this->theta_max, this->theta_min);
throw std::invalid_argument("theta_max (" + std::to_string(this->theta_max)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to keep the BSK_ERROR message as well, as this is expected behavior of a BSK module across the framework. I don't mind if you also include the throw argument as well.

+ ") must be greater than theta_min (" + std::to_string(this->theta_min) + ").");
}
// Ensure that user specified valid initial angle
if ((this->thetaInit > this->theta_max) || (this->thetaInit < this->theta_min)) {
bskLogger.bskLog(BSK_ERROR, "Initial angle (%f) must be inside of body angle bounds (%f, %f).",
this->thetaInit, this->theta_min, this->theta_max);
throw std::invalid_argument("Initial angle (" + std::to_string(this->thetaInit)
+ ") must be inside of body angle bounds (" + std::to_string(this->theta_min) + ", "
+ std::to_string(this->theta_max) + ").");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

*/

#include <stdexcept>

%exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not following what this swig code is doing? Could you please add some comments on what is being done here?

try {
$action
} catch (std::invalid_argument &e) {
std::string s("spinningBodyOneDOF error: "), s2(e.what());
s = s + s2;
SWIG_exception(SWIG_ValueError, s.c_str());
}
}

%module spinningBodyOneDOFStateEffector
%{
Expand Down