Skip to content

add option to register callbacks for torque estimates messages#6

Merged
samuelsadok merged 2 commits intoodriverobotics:masterfrom
maxipalay:can-torque-feedback
Jan 23, 2025
Merged

add option to register callbacks for torque estimates messages#6
samuelsadok merged 2 commits intoodriverobotics:masterfrom
maxipalay:can-torque-feedback

Conversation

@maxipalay
Copy link
Copy Markdown
Contributor

Added option to register a callback for an incoming message of type Get_Torques_msg_t . This enables registering a callback to process incoming torque messages. I do not have the hardware to test this right now, but I have tested it previously and got good results.

Copy link
Copy Markdown
Member

@samuelsadok samuelsadok left a comment

Choose a reason for hiding this comment

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

small oversight error, otherwise looks good

Comment thread src/ODriveCAN.h Outdated
*/
void onTorques(void (*callback)(Get_Torques_msg_t& feedback, void* user_data), void* user_data = nullptr) {
torques_callback_ = callback;
feedback_user_data_ = user_data;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be a new variable torques_user_data_.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added torques_user_data_ as a private variable and addressed the change accordingly in the onTorques function.

Comment thread src/ODriveCAN.cpp Outdated
Get_Torques_msg_t estimates;
estimates.decode_buf(data);
if (torques_callback_)
torques_callback_(estimates, feedback_user_data_);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed this on latest update.

@samuelsadok samuelsadok merged commit da0f624 into odriverobotics:master Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants