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

Remove parameter to select which stick does steering #91

Merged
merged 3 commits into from
Oct 1, 2021
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion include/pacmod_game_control/controllers.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Controller
void set_controller_input(const sensor_msgs::Joy& joy_msg);
virtual float accelerator_value();
virtual float brake_value();
virtual float steering_value(JoyAxis steering_axis);
virtual float steering_value();
virtual int turn_signal_cmd();
virtual int shift_cmd();
virtual bool horn_cmd();
Expand Down
2 changes: 0 additions & 2 deletions include/pacmod_game_control/publish_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class PublishControl
void callback_rear_pass_door_rpt(const pacmod_msgs::SystemRptInt::ConstPtr& msg);

// public variables
JoyAxis steering_axis = JoyAxis::LEFT_STICK_LR;
float max_rot_rad = MAX_ROT_RAD_DEFAULT;
VehicleType vehicle_type;
GamepadType controller_type = GamepadType::LOGITECH_F310;
Expand Down Expand Up @@ -66,7 +65,6 @@ class PublishControl

// Startup checks
bool run_startup_checks_error();
bool check_steering_stick_left_right(const ros::NodeHandle& nodeH);
bool check_vehicle_type(const ros::NodeHandle& nodeH);
bool check_controller_type(const ros::NodeHandle& nodeH);
bool check_scale_values(const ros::NodeHandle& nodeH);
Expand Down
3 changes: 0 additions & 3 deletions launch/pacmod_game_control.launch
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
JUPITER_SPIRIT -->
<arg name="pacmod_vehicle_type" default="LEXUS_RX_450H" />

<arg name="steering_stick" default="LEFT"/>

<!-- Supported types are:
LOGITECH_F310 (the standard gamepad provided with all vehicles)
XBOX_ONE (Xbox 360 controller works the same)
Expand Down Expand Up @@ -60,7 +58,6 @@

<node pkg="pacmod_game_control" type="pacmod_game_control_node" name="pacmod_game_control" output="screen">
<param name="pacmod_vehicle_type" value="$(arg pacmod_vehicle_type)"/>
<param name="steering_stick" value="$(arg steering_stick)"/>
<param name="controller_type" value="$(arg controller_type)"/>
<param name="steering_max_speed" value="$(arg steering_max_speed)"/>
<param name="accel_scale_val" value="$(arg accel_scale_val)"/>
Expand Down
4 changes: 2 additions & 2 deletions src/controllers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ float Controller::brake_value()
return -(input_msg_.axes[axes_[JoyAxis::LEFT_TRIGGER_AXIS]] - 1.0) / 2.0;
}

float Controller::steering_value(JoyAxis steering_axis)
float Controller::steering_value()
{
return input_msg_.axes[axes_[steering_axis]];
return input_msg_.axes[axes_[JoyAxis::LEFT_STICK_LR]];
}

int Controller::turn_signal_cmd()
Expand Down
4 changes: 2 additions & 2 deletions src/publish_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void PublishControl::publish_steering_message()
range_scale = 1.0;
else
range_scale =
fabs(controller->steering_value(steering_axis)) * (STEER_OFFSET - ROT_RANGE_SCALER_LB) + ROT_RANGE_SCALER_LB;
fabs(controller->steering_value()) * (STEER_OFFSET - ROT_RANGE_SCALER_LB) + ROT_RANGE_SCALER_LB;

// Decreases the angular rotation rate of the steering wheel when moving faster
float speed_based_damping = 1.0;
Expand All @@ -150,7 +150,7 @@ void PublishControl::publish_steering_message()
else
speed_based_damping = 0.33333; // clips the equation assuming 1 offset and 1.5 scale_factor

steer_msg.command = (range_scale * max_rot_rad) * controller->steering_value(steering_axis);
steer_msg.command = (range_scale * max_rot_rad) * controller->steering_value();
steer_msg.rotation_rate = steering_max_speed * speed_based_damping;
steering_set_position_with_speed_limit_pub.publish(steer_msg);
}
Expand Down
34 changes: 0 additions & 34 deletions src/startup_checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,13 @@ bool PublishControl::run_startup_checks_error()
ros::NodeHandle pnh("~");

// Run startup checks
willExit = willExit || check_steering_stick_left_right(pnh);
willExit = willExit || check_vehicle_type(pnh);
willExit = willExit || check_controller_type(pnh);
willExit = willExit || check_scale_values(pnh);

return willExit;
}

// Check which steering stick we should use on the joypad
bool PublishControl::check_steering_stick_left_right(const ros::NodeHandle& nodeH)
{
std::string steering_stick_string;
bool exit = false;

if (nodeH.getParam("steering_stick", steering_stick_string))
{
ROS_INFO("Got steering_stick: %s", steering_stick_string.c_str());

if (steering_stick_string == "LEFT")
{
steering_axis = JoyAxis::LEFT_STICK_LR;
}
else if (steering_stick_string == "RIGHT")
{
steering_axis = JoyAxis::RIGHT_STICK_LR;
}
else
{
ROS_ERROR("steering_stick is invalid. Exiting.");
exit = true;
}
}
else
{
ROS_ERROR("Parameter steering_stick is missing. Exiting.");
exit = true;
}

return exit;
}

bool PublishControl::check_vehicle_type(const ros::NodeHandle& nodeH)
{
bool exit = false;
Expand Down