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

Add optional axes initial value parameter to handle the trigger behavior #214

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
8 changes: 7 additions & 1 deletion joy/src/joy_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Joystick
std::string joy_dev_name_;
std::string joy_dev_ff_;
double deadzone_;
std::vector<double> axes_init_value_; // initial value for axes, default 0
double autorepeat_rate_; // in Hz. 0 for no repeat.
double coalesce_interval_; // Defaults to 100 Hz rate limit.
int event_count_;
Expand Down Expand Up @@ -310,6 +311,7 @@ class Joystick
nh_param.param<std::string>("dev_ff", joy_dev_ff_, "/dev/input/event0");
nh_param.param<std::string>("dev_name", joy_dev_name_, "");
nh_param.param<double>("deadzone", deadzone_, 0.05);
nh_param.param<std::vector<double>>("axes_init_value", axes_init_value_, std::vector<double>());
nh_param.param<double>("autorepeat_rate", autorepeat_rate_, 0);
nh_param.param<double>("coalesce_interval", coalesce_interval_, 0.001);
nh_param.param<bool>("default_trig_val", default_trig_val_, false);
Expand Down Expand Up @@ -559,9 +561,13 @@ class Joystick
{
size_t old_size = joy_msg.axes.size();
joy_msg.axes.resize(event.number+1);
if (old_size > axes_init_value_.size())
{
axes_init_value_.resize(event.number+1, 0.);
}
for (size_t i = old_size; i < joy_msg.axes.size(); i++)
{
joy_msg.axes[i] = 0.0;
joy_msg.axes[i] = axes_init_value_[i];
}
}
if (default_trig_val_)
Expand Down