|
@@ -6,6 +6,7 @@
|
|
import os
|
|
import os
|
|
import rospy
|
|
import rospy
|
|
import roslib; roslib.load_manifest('ros_arduino_python')
|
|
import roslib; roslib.load_manifest('ros_arduino_python')
|
|
|
|
+import dynamic_reconfigure.client
|
|
|
|
|
|
from math import sin, cos, pi, sqrt
|
|
from math import sin, cos, pi, sqrt
|
|
from geometry_msgs.msg import Quaternion, Twist
|
|
from geometry_msgs.msg import Quaternion, Twist
|
|
@@ -13,9 +14,9 @@ from nav_msgs.msg import Odometry
|
|
from tf.broadcaster import TransformBroadcaster
|
|
from tf.broadcaster import TransformBroadcaster
|
|
from std_msgs.msg import Int32
|
|
from std_msgs.msg import Int32
|
|
|
|
|
|
-
|
|
|
|
""" Class to receive Twist commands and publish wheel Odometry data """
|
|
""" Class to receive Twist commands and publish wheel Odometry data """
|
|
class BaseController:
|
|
class BaseController:
|
|
|
|
+
|
|
def __init__(self, is_use_serial, arduino, base_frame, name="base_controllers_node"):
|
|
def __init__(self, is_use_serial, arduino, base_frame, name="base_controllers_node"):
|
|
self.use_serial = is_use_serial
|
|
self.use_serial = is_use_serial
|
|
self.arduino = arduino
|
|
self.arduino = arduino
|
|
@@ -26,31 +27,34 @@ class BaseController:
|
|
self.rate = float(rospy.get_param("~base_controller_rate", 20))
|
|
self.rate = float(rospy.get_param("~base_controller_rate", 20))
|
|
self.timeout = rospy.get_param("~base_controller_timeout", 0.7)
|
|
self.timeout = rospy.get_param("~base_controller_timeout", 0.7)
|
|
|
|
|
|
|
|
+ self.debugPID = rospy.get_param('/dynamic_tutorials/debugPID', False)
|
|
|
|
+
|
|
pid_params = dict()
|
|
pid_params = dict()
|
|
- pid_params['wheel_diameter'] = rospy.get_param("~wheel_diameter", 0.058)
|
|
|
|
- pid_params['wheel_track'] = rospy.get_param("~wheel_track", 0.126)
|
|
|
|
- pid_params['encoder_resolution'] = rospy.get_param("~encoder_resolution", 11)
|
|
|
|
- pid_params['gear_reduction'] = rospy.get_param("~gear_reduction", 46)
|
|
|
|
- pid_params['AWheel_Kp'] = rospy.get_param("~AWheel_Kp", 15)
|
|
|
|
- pid_params['AWheel_Kd'] = rospy.get_param("~AWheel_Kd", 15)
|
|
|
|
- pid_params['AWheel_Ki'] = rospy.get_param("~AWheel_Ki", 0)
|
|
|
|
- pid_params['AWheel_Ko'] = rospy.get_param("~AWheel_Ko", 50)
|
|
|
|
-
|
|
|
|
- pid_params['BWheel_Kp'] = rospy.get_param("~BWheel_Kp", 15)
|
|
|
|
- pid_params['BWheel_Kd'] = rospy.get_param("~BWheel_Kd", 15)
|
|
|
|
- pid_params['BWheel_Ki'] = rospy.get_param("~BWheel_Ki", 0)
|
|
|
|
- pid_params['BWheel_Ko'] = rospy.get_param("~BWheel_Ko", 50)
|
|
|
|
-
|
|
|
|
- pid_params['CWheel_Kp'] = rospy.get_param("~CWheel_Kp", 15)
|
|
|
|
- pid_params['CWheel_Kd'] = rospy.get_param("~CWheel_Kd", 16)
|
|
|
|
- pid_params['CWheel_Ki'] = rospy.get_param("~CWheel_Ki", 0)
|
|
|
|
- pid_params['CWheel_Ko'] = rospy.get_param("~CWheel_Ko", 50)
|
|
|
|
-
|
|
|
|
- self.debugPID = rospy.get_param('~debugPID', False)
|
|
|
|
|
|
+ pid_params['wheel_diameter'] = rospy.get_param("~wheel_diameter", 0.058)
|
|
|
|
+ pid_params['wheel_track'] = rospy.get_param("~wheel_track", 0.126)
|
|
|
|
+ pid_params['encoder_resolution'] = rospy.get_param("~encoder_resolution", 11)
|
|
|
|
+ pid_params['gear_reduction'] = rospy.get_param("~gear_reduction", 46)
|
|
|
|
+ pid_params['AWheel_Kp'] = rospy.get_param("~AWheel_Kp", 15)
|
|
|
|
+ pid_params['AWheel_Kd'] = rospy.get_param("~AWheel_Kd", 15)
|
|
|
|
+ pid_params['AWheel_Ki'] = rospy.get_param("~AWheel_Ki", 0)
|
|
|
|
+ pid_params['AWheel_Ko'] = rospy.get_param("~AWheel_Ko", 50)
|
|
|
|
+
|
|
|
|
+ pid_params['BWheel_Kp'] = rospy.get_param("~BWheel_Kp", 15)
|
|
|
|
+ pid_params['BWheel_Kd'] = rospy.get_param("~BWheel_Kd", 15)
|
|
|
|
+ pid_params['BWheel_Ki'] = rospy.get_param("~BWheel_Ki", 0)
|
|
|
|
+ pid_params['BWheel_Ko'] = rospy.get_param("~BWheel_Ko", 50)
|
|
|
|
+
|
|
|
|
+ pid_params['CWheel_Kp'] = rospy.get_param("~CWheel_Kp", 15)
|
|
|
|
+ pid_params['CWheel_Kd'] = rospy.get_param("~CWheel_Kd", 15)
|
|
|
|
+ pid_params['CWheel_Ki'] = rospy.get_param("~CWheel_Ki", 0)
|
|
|
|
+ pid_params['CWheel_Ko'] = rospy.get_param("~CWheel_Ko", 50)
|
|
|
|
+
|
|
self.accel_limit = rospy.get_param('~accel_limit', 0.05)
|
|
self.accel_limit = rospy.get_param('~accel_limit', 0.05)
|
|
self.linear_scale_correction = rospy.get_param("~linear_scale_correction", 1.0)
|
|
self.linear_scale_correction = rospy.get_param("~linear_scale_correction", 1.0)
|
|
self.angular_scale_correction = rospy.get_param("~angular_scale_correction", 1.0)
|
|
self.angular_scale_correction = rospy.get_param("~angular_scale_correction", 1.0)
|
|
|
|
|
|
|
|
+ #rospy.loginfo("pid_params_dict: "+pid_params)
|
|
|
|
+
|
|
# Set up PID parameters and check for missing values
|
|
# Set up PID parameters and check for missing values
|
|
self.setup_pid(pid_params)
|
|
self.setup_pid(pid_params)
|
|
|
|
|