Fix sinusoidal_force_sensor build and runtime, set wave to 25 Hz - #4
Merged
Conversation
- Fix compilation error: construct DQ from Vector3d instead of an initializer list (Eigen 3-scalar ctor requires fixed-size vector) - Fix std::bad_weak_ptr crash at startup: build the node in main first, then attach the ForceSensorServer via attach_server() so that shared_from_this() is valid - Set the sinusoidal wave frequency to 25 Hz while keeping the 100 Hz publish tick rate (separate frequency_hz from tick_rate_hz) Co-authored-by: openhands <openhands@all-hands.dev>
mmmarinho
marked this pull request as ready for review
August 17, 2026 21:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the compilation error and the startup crash in the
sinusoidal_force_sensorexample, and sets the sinusoidal wave frequency to 25 Hz while keeping the 100 Hz publish rate.Changes
All in
src/examples/sinusoidal_force_sensor.cpp:Compilation error —
DQ force({value, 0.0, 0.0})failed withstatic assertion failed: THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE. The initializer list built a dynamic-sizeVectorXd, and Eigen's 3-scalar constructor requires a fixed-size vector. Now constructs from an explicitVector3d:std::bad_weak_ptrcrash at startup — the constructor calledshared_from_this()before the owningshared_ptrexisted.mainnow builds the node first and then callsattach_server()(which creates theForceSensorServerand timer), soshared_from_this()is valid.25 Hz wave at 100 Hz publish rate — separated the previously-conflated constants:
The timer period and phase advance use
tick_rate_hz; the sine usesfrequency_hz/angular_frequency. Previously a 100 Hz wave sampled at 100 Hz aliased to ~0.Verification
Verified in the repo's Docker environment (
murilomarinho/sas:jazzy, same as CI):colcon buildfinishes cleanly (exit 0)/sinusoidal_force_sensor/get/wrenchWrenchStampedsamples show one full sine period every 4 ticks (40 ms → 25 Hz) with amplitude 2.0This PR was created by an AI agent (OpenHands) on behalf of the user.