diff drive controller velocity limit
How does diff drive limits the maximum and minimum velocity limits exactly? I have set the max linear velocity of robot as 0.5 cm which has wheel radius of 0.05 m. When i debug the hardware interface and check the maximum angular velocity at full throttle it shows me w=v/r = 10 rad/sec which i have converted to range i.e [0,255] for pulse wide modulation of dc motors. Here the wheel encoders are sending the wheel angular velocity as 200 rad/sec to the hardware interface at same time. Now how is this actual velocity i.e 200 rad/sec going to be used by diff drive controller and the input velocity i.e 10 rad/sec be controlled ? Cas my robot is colliding with obstacle due to this large velocity of robot. Here are my parameters for the diff drive controller:
base_controller:
type : "diff_drive_controller/DiffDriveController"
left_wheel : 'wheel_left_joint'
right_wheel : 'wheel_right_joint'
publish_rate: 50.0 # default: 50
pose_covariance_diagonal : [0.001, 0.001, 1000000.0, 1000000.0, 1000000.0, 1000.0]
twist_covariance_diagonal: [0.001, 0.001, 1000000.0, 1000000.0, 1000000.0, 1000.0]
# Wheel separation and diameter. These are both optional.
# diff_drive_controller will attempt to read either one or both from the
# URDF if not specified as a parameter
wheel_separation : 1.0
wheel_radius : 0.049
# Wheel separation and radius multipliers
wheel_separation_multiplier: 1.0 # default: 1.0
wheel_radius_multiplier : 1.0 # default: 1.0
# Velocity commands timeout [s], default 0.5
cmd_vel_timeout: 0.25
# Base frame_id
base_frame_id: base_link #default: base_link
# Velocity and acceleration limits
# Whenever a min_* is unspecified, default to -max_*
linear:
x:
has_velocity_limits : true
max_velocity : 0.5 # m/s
min_velocity : -0.5 # m/s
has_acceleration_limits: true
max_acceleration : 0.2 # m/s^2
min_acceleration : -0.2 # m/s^2
has_jerk_limits : true
max_jerk : 1.0 # m/s^3
angular:
z:
has_velocity_limits : true
max_velocity : 1 # rad/s
has_acceleration_limits: false
max_acceleration : 1.5 # rad/s^2
has_jerk_limits : false
max_jerk : 2.5 # rad/s^3
Here is the hardware interface:
#include <medicbot_control/medicbot_hw_interface.h>
#include <exception>
#include <algorithm>
#include <iostream>
#include <bits/stdc++.h>
#include <boost/algorithm/string.hpp>
namespace rrbot_control
{
float myMap(float x, float in_min, float in_max, float out_min, float out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
std::string to_format(const int number,int decPlace) {
std::stringstream ss;
ss << std::setw(decPlace) << std::setfill('0') << number;
return ss.str();
}
RRBotHWInterface::RRBotHWInterface(ros::NodeHandle &nh, urdf::Model *urdf_model)
: ros_control_boilerplate::GenericHWInterface(nh, urdf_model)
{
ROS_INFO_NAMED("rrbot_hw_interface", "RRBotHWInterface Ready.");
Setup();
}
void RRBotHWInterface::read(ros::Duration &elapsed_time)
{
const char* enc_ticks = Read();
std::vector<std::string> result;
boost::split(result, enc_ticks, boost::is_any_of(","));
for (int joint_id = 0; joint_id < result.size(); joint_id++) {
float ang_vel = atof(result[joint_id].c_str());
joint_velocity_[joint_id] = ang_vel*0.049;
joint_position_[joint_id] += joint_velocity_[joint_id] * elapsed_time.toSec();
}
std::cout<<"joint_velocity_got:"<<joint_velocity_[0]<<"\t"<<joint_velocity_[1]<<std::endl;
//std::cout<<"got data:"<<enc_ticks<<std::endl;
}
void RRBotHWInterface::write(ros::Duration &elapsed_time)
{
// Safety
enforceLimits(elapsed_time);
// ----------------------------------------------------
// ----------------------------------------------------
// ----------------------------------------------------
//
// FILL IN YOUR WRITE COMMAND TO USB/ETHERNET/ETHERCAT/SERIAL ETC HERE
//
// FOR A EASY SIMULATION ...