Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong claculations at roboteq_motor_controller_driver_node.cpp #9

Open
noam7777 opened this issue Oct 14, 2020 · 1 comment
Open

wrong claculations at roboteq_motor_controller_driver_node.cpp #9

noam7777 opened this issue Oct 14, 2020 · 1 comment

Comments

@noam7777
Copy link

there is a wrong calculation of the command to the motors.
what you have now:

void Driver::cmd_vel_callback(const geometry_msgs::Twist& msg){
std::stringstream cmd_sub;
cmd_sub << "!G 1" << " " << msg.linear.x << "" << "!G 2" << " " << msg.angular.z << "";

	ser.write(cmd_sub.str());
ROS_INFO_STREAM(cmd_sub.str());	

}
void Driver::roboteq_subscriber(){
ros::NodeHandle n;
cmd_vel_sub = n.subscribe("/cmd_vel",10,&Driver::cmd_vel_callback,this);

}

void Driver::roboteq_subscriber(){
ros::NodeHandle n;
cmd_vel_sub = n.subscribe("/cmd_vel",10,&Driver::cmd_vel_callback,this);

}

and what you need is
void Driver::cmd_vel_callback(const geometry_msgs::Twist& msg){
std::stringstream cmd_sub;
double cmd_left, cmd_right;
int kW = 1; //TODO:gemotrical property of the robot(width,radius)
cmd_left = msg.linear.x-msg.angular.zkW;
cmd_right = msg.linear.x+msg.angular.z
kW;
cmd_sub << "!G 1" << " " << cmd_left << "" << "!G 2" << " " << cmd_right << "";

	ser.write(cmd_sub.str());
ROS_INFO_STREAM(cmd_sub.str());	

}
void Driver::roboteq_subscriber(){
ros::NodeHandle n;
cmd_vel_sub = n.subscribe("/cmd_vel",10,&Driver::cmd_vel_callback,this);

}

this is a more logical way to calculate the angular velocity to the wheels then before

@zhughesjd
Copy link

zhughesjd commented Feb 10, 2021

@noam7777
After reading:

http://wiki.ros.org/simple_drive#Twist_to_Tank_Calculation

I found that the code below did the trick for skid steer type vehicles.

void Driver::cmd_vel_callback(const geometry_msgs::Twist& msg)
{
std::stringstream cmd_sub;
double cmd_left, cmd_right;
cmd_left = msg.linear.x-msg.angular.z;
cmd_right = msg.linear.x+msg.angular.z;
cmd_sub << "!G 1" << " " << cmd_left << "_" << "!G 2" << " " << cmd_right << "_";
ser.write(cmd_sub.str());
ROS_INFO_STREAM(cmd_sub.str());
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants