@@ -28,29 +28,56 @@ void WheelSpeedNode::cmdVelCallback(const geometry_msgs::msg::Twist::SharedPtr m
2828 linear *= wheel_speed_factor;
2929 angular *= wheel_speed_factor;
3030
31- // Create vectors of motor commands that correspond to the calculated speeds for left and right wheels
32- std::vector<double > left_wheel_commands = {
33- -linear + angular, // Left Front Wheel
34- -linear + angular, // Left Mid Wheel
35- -linear + angular // Left Rear Wheel
36- };
31+ WheelSpeeds wheel_speeds = schmittTrigger (linear, angular);
32+ // std::vector<double> wheel_commands = ackermann(linear, angular);
33+
34+ // // Create vectors of motor commands that correspond to the calculated speeds for left and right wheels
35+ // std::vector<double> left_wheel_commands = {
36+ // -linear + angular, // Left Front Wheel
37+ // -linear + angular, // Left Mid Wheel
38+ // -linear + angular // Left Rear Wheel
39+ // };
3740
38- std::vector<double > right_wheel_commands = {
39- linear + angular, // Right Front Wheel
40- linear + angular, // Right Mid Wheel
41- linear + angular // Right Rear Wheel
42- };
41+ // std::vector<double> right_wheel_commands = {
42+ // linear + angular, // Right Front Wheel
43+ // linear + angular, // Right Mid Wheel
44+ // linear + angular // Right Rear Wheel
45+ // };
4346
4447 // Publish the separate left and right wheel speed messages
4548 std_msgs::msg::Float64MultiArray left_msg;
46- left_msg.data = left_wheel_commands ; // Set left wheel commands data
49+ left_msg.data = wheel_speeds. left_wheel_speeds ; // Set left wheel commands data
4750 left_wheel_pub_->publish (left_msg); // Publish to "/left_wheel_speeds"
4851
4952 std_msgs::msg::Float64MultiArray right_msg;
50- right_msg.data = right_wheel_commands ; // Set right wheel commands data
53+ right_msg.data = wheel_speeds. right_wheel_speeds ; // Set right wheel commands data
5154 right_wheel_pub_->publish (right_msg); // Publish to "/right_wheel_speeds"
5255}
5356
57+ WheelSpeeds WheelSpeedNode::schmittTrigger (double linear, double angular) {
58+ // Tank drive as placeholder
59+ double l = -linear + angular;
60+ double r = linear + angular;
61+
62+ WheelSpeeds wheelSpeeds;
63+ wheelSpeeds.left_wheel_speeds = { l, l, l };
64+ wheelSpeeds.right_wheel_speeds = { r, r, r };
65+
66+ return wheelSpeeds;
67+ }
68+
69+ WheelSpeeds WheelSpeedNode::ackermann (double linear, double angular) {
70+ // Tank drive as placeholder
71+ double l = -linear + angular;
72+ double r = linear + angular;
73+
74+ WheelSpeeds wheelSpeeds;
75+ wheelSpeeds.left_wheel_speeds = { l, l, l };
76+ wheelSpeeds.right_wheel_speeds = { r, r, r };
77+
78+ return wheelSpeeds;
79+ }
80+
5481// Main function to initialize the ROS2 node and start processing
5582int main (int argc, char *argv[]) {
5683 rclcpp::init (argc, argv); // Initialize the ROS2 system
0 commit comments