-
Notifications
You must be signed in to change notification settings - Fork 481
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
base: gazebo9
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
// 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]); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
Hi @ViaudJV, are you still interested in working on this? |
I won't make any more modification. |
No description provided.