7 this->m_servo_position_subscriber =
11 this->m_motor_speed_subscriber =
15 this->m_motor_brake_subscriber =
19 this->m_left_rear_wheel_velocity_publisher =
21 this->m_right_rear_wheel_velocity_publisher =
23 this->m_left_front_wheel_velocity_publisher =
25 this->m_right_front_wheel_velocity_publisher =
28 this->m_left_steering_position_publisher =
30 this->m_right_steering_position_publisher =
33 m_VESC_simulator.
start();
38 std_msgs::Float64 throttle;
41 m_VESC_simulator.
setSpeed(throttle_message->data);
43 this->m_left_rear_wheel_velocity_publisher.publish(throttle);
44 this->m_right_rear_wheel_velocity_publisher.publish(throttle);
45 this->m_left_front_wheel_velocity_publisher.publish(throttle);
46 this->m_right_front_wheel_velocity_publisher.publish(throttle);
51 if (motor_brake->data != 0)
53 std_msgs::Float64 throttle;
58 this->m_left_rear_wheel_velocity_publisher.publish(throttle);
59 this->m_right_rear_wheel_velocity_publisher.publish(throttle);
60 this->m_left_front_wheel_velocity_publisher.publish(throttle);
61 this->m_right_front_wheel_velocity_publisher.publish(throttle);
68 AckermannSteeringAngles angles = calculateSteeringAngles(angle);
72 std_msgs::Float64 left_wheel;
73 left_wheel.data = angles.left_wheel_angle;
75 std_msgs::Float64 right_wheel;
76 right_wheel.data = angles.right_wheel_angle;
78 this->m_left_steering_position_publisher.publish(left_wheel);
79 this->m_right_steering_position_publisher.publish(right_wheel);
82 VESCSimulationDriver::AckermannSteeringAngles VESCSimulationDriver::calculateSteeringAngles(
const double& angle)
84 AckermannSteeringAngles angles;
VESCSimulationDriver()
Constructor that creates subscribers and publishers.
constexpr const char * WHEEL_RIGHT_FRONT_VELOCITY
constexpr double TRANSMISSION
Gear transmission inside the differential of the car. This is an estimate, the exact value is not kno...
void motorSpeedCallback(const std_msgs::Float64::ConstPtr &throttle_message)
Callback for ROS Subscriber.
constexpr double ERPM_TO_RAD_PER_SEC
Conversion factor from electrical revolutions per minute to radian to seconds radian/s * minute = ra...
void motorBrakeCallback(const std_msgs::Float64::ConstPtr &motor_brake)
Callback for ROS Subscriber.
constexpr double REAR_WHEEL_DISTANCE
void setSpeed(const double &data)
constexpr const char * WHEEL_LEFT_BACK_VELOCITY
constexpr const char * WHEEL_LEFT_FRONT_VELOCITY
constexpr double WHEELBASE
The distance between the front and rear axes.
constexpr double STEERING_TO_SERVO_GAIN
Conversion factor from steering angle to servo input 1/radian.
constexpr const char * COMMAND_BRAKE
constexpr const char * COMMAND_THROTTLE
constexpr double STEERING_TO_SERVO_OFFSET
Position of the servo for normal wheel position.
void setServoAngle(const double &data)
constexpr const char * COMMAND_POSITION
constexpr const char * WHEEL_RIGHT_BACK_VELOCITY
constexpr const char * RIGHT_STEERING_POSITION
void servoPositionCallback(const std_msgs::Float64::ConstPtr &servo_position)
Callback for ROS Subscriber.
constexpr const char * LEFT_STEERING_POSITION