Skip to content
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

fix chrash when use SpaceNav pro #2895

Open
wants to merge 1 commit into
base: gazebo9
Choose a base branch
from

Conversation

ViaudJV
Copy link

@ViaudJV ViaudJV commented Nov 28, 2020

No description provided.

Copy link
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

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

Thank you for the PR!

@@ -147,8 +147,8 @@ void SpaceNav::Run()
{
msgs::Joystick joystickMsg;

// add button state
for (unsigned int i = 0; i < 2; ++i)
// add button state (26 bouttons)
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo

Suggested change
// add button state (26 bouttons)
// add button state (26 buttons)

// add button state
for (unsigned int i = 0; i < 2; ++i)
// add button state (26 bouttons)
for (unsigned int i = 0; i < 26; ++i)
joystickMsg.add_buttons(this->dataPtr->buttons[i]);
Copy link
Contributor

Choose a reason for hiding this comment

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

For users of the old spacenav version, this will populate 24 buttons that don't exist with zeroes, right? Is there a way we can avoid this?

Copy link
Author

Choose a reason for hiding this comment

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

The best is detect the space nav version through the libspnav. But libspnav doesn't implement the possibility to get device id (Apparently in the daemon spacenav have all device id).

Other possibilities
in SpaceNavPrivate.hh
we can declare
std::vector buttons;
int buttons[26];
and in SpaceNav.cc
case SPNAV_EVENT_BUTTON:
{
// update button press
if (sev.button.bnum >= buttons.size())
{
buttons.resize(sev.button.bnum +1);
}
this->dataPtr->buttons[sev.button.bnum] = sev.button.press;
joystickMsg.mutable_buttons()->Set(sev.button.bnum, sev.button.press);
this->dataPtr->joyPub->Publish(joystickMsg);
}

{
this->dataPtr->buttons[sev.button.bnum] = sev.button.press;
joystickMsg.mutable_buttons()->Set(sev.button.bnum, sev.button.press);
this->dataPtr->joyPub->Publish(joystickMsg);
Copy link
Contributor

Choose a reason for hiding this comment

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

Style nitpick: please use 2-space indentation

@traversaro
Copy link
Collaborator

Hi @ViaudJV, are you still interested in working on this?

@ViaudJV
Copy link
Author

ViaudJV commented Sep 30, 2022

Hi @ViaudJV, are you still interested in working on this?

I won't make any more modification.

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.

3 participants