49 pn.
param(
"control_rate", control_rate, 50.0);
99 -std::min(fabs(
cmd_vel_.decel_limit) > 0.0 ? fabs(
cmd_vel_.decel_limit) : 9.8,
100 cfg_.decel_max > 0.0 ?
cfg_.decel_max : 9.8),
101 std::min(fabs(
cmd_vel_.accel_limit) > 0.0 ? fabs(
cmd_vel_.accel_limit) : 9.8,
102 cfg_.accel_max > 0.0 ?
cfg_.accel_max : 9.8)
106 if (
cmd_vel_.twist.linear.x <= (
double)1e-2) {
107 accel_cmd = std::min(accel_cmd, -530 / vehicle_mass /
cfg_.wheel_radius);
110 std_msgs::Float64 accel_cmd_msg;
111 accel_cmd_msg.data = accel_cmd;
115 dbw_mkz_msgs::ThrottleCmd throttle_cmd;
116 dbw_mkz_msgs::BrakeCmd brake_cmd;
117 dbw_mkz_msgs::SteeringCmd steering_cmd;
119 throttle_cmd.enable =
true;
120 throttle_cmd.pedal_cmd_type = dbw_mkz_msgs::ThrottleCmd::CMD_PERCENT;
121 if (accel_cmd >= 0) {
125 throttle_cmd.pedal_cmd = 0;
128 brake_cmd.enable =
true;
129 brake_cmd.pedal_cmd_type = dbw_mkz_msgs::BrakeCmd::CMD_TORQUE;
130 if (accel_cmd < -
cfg_.brake_deadband) {
131 brake_cmd.pedal_cmd = -accel_cmd * vehicle_mass *
cfg_.wheel_radius;
133 brake_cmd.pedal_cmd = 0;
136 steering_cmd.enable =
true;
140 if (
cfg_.pub_pedals) {
145 if (
cfg_.pub_steering) {
158 cfg_.vehicle_mass += 150.0;
195 double raw_accel = 50.0 * (msg->speed -
actual_.linear.x);
198 std_msgs::Float64 accel_msg;
207 actual_.angular.z = msg->angular_velocity.z;
static const double GAS_DENSITY
void publish(const boost::shared_ptr< M > &message) const
void setRange(double min, double max)
void recvEnable(const std_msgs::Bool::ConstPtr &msg)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void controlCallback(const ros::TimerEvent &event)
ros::Publisher pub_brake_
double getSteeringWheelAngle(double cmd_vx, double cmd_wz, double speed)
void recvSteeringReport(const dbw_mkz_msgs::SteeringReport::ConstPtr &msg)
ros::Subscriber sub_twist2_
void recvFuel(const dbw_mkz_msgs::FuelLevelReport::ConstPtr &msg)
ros::Timer control_timer_
ros::Subscriber sub_twist3_
void recvTwist(const geometry_msgs::Twist::ConstPtr &msg)
ros::Subscriber sub_enable_
ros::Publisher pub_throttle_
ros::Publisher pub_req_accel_
void setWheelBase(double val)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
void setLateralAccelMax(double val)
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
TwistControllerNode(ros::NodeHandle &n, ros::NodeHandle &pn)
void reconfig(ControllerConfig &config, uint32_t level)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
dbw_mkz_msgs::TwistCmd cmd_vel_
geometry_msgs::Twist actual_
void setGains(double kp, double ki, double kd)
dynamic_reconfigure::Server< ControllerConfig > srv_
void recvTwist2(const dbw_mkz_msgs::TwistCmd::ConstPtr &msg)
ros::Publisher pub_accel_
bool getParam(const std::string &key, std::string &s) const
double step(double error, double sample_time)
void recvImu(const sensor_msgs::Imu::ConstPtr &msg)
ros::Subscriber sub_fuel_level_
ros::Publisher pub_steering_
void setSteeringRatio(double val)
void setParams(double tau, double ts)
ros::Subscriber sub_steering_
ros::Subscriber sub_twist_
static double mphToMps(double mph)
void recvTwist3(const geometry_msgs::TwistStamped::ConstPtr &msg)