Ask Your Question
0

controling right and left wheels using ROS

asked 2018-01-10 12:54:51 -0500

JossiChrist gravatar image

updated 2018-01-12 16:37:10 -0500

jayess gravatar image

Dear guys,

Can anyone help me, i just follow a tutorial to make "Differential Drive Robot" from this link:

https://www.generationrobots.com/blog...

in the tutorial, Mobile robot models can be moved using cmd_vel (by controlling linear,x and angular.z). How can i control right and left wheels based on the trajectory? Im newbie :(

Thank you in advance

this is my code:

ros::Publisher pLeft = nh.advertise<std_msgs::Float64>("/my_robot/leftWheel_effort_controller/command",1);

ros::Publisher pRight = nh.advertise<std_msgs::Float64>("/my_robot/rightWheel_effort_controller/command",1);


std_msgs::Float64 stdMessage;

pLeft.publish(stdMessage);

pRight.publish(stdMessage);

But, it do nothing :(

edit retag flag offensive close merge delete

Comments

Welcome! What have you tried so far (an example of your code please)? Showing that you've put forth some effort is likely to increase your chances of getting help with this.

jayess gravatar image jayess  ( 2018-01-10 13:32:06 -0500 )edit

i have showed the code

JossiChrist gravatar image JossiChrist  ( 2018-01-12 08:27:58 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-01-12 11:10:41 -0500

I'm not familiar with this exact robot, but I can see some problems.

you're creating two message objects, but you're setting their values. Each message should contain the velocity (effort) that you want each wheel to move out. The code you have shown is sending values of zero, which may be why the robot isn't moving.

Is there a reason why you're not using the cmd_vel topic? It's usually much easier to use this to drive a robot like this.

edit flag offensive delete link more

Comments

Like @PeteBlackerThe3rd says, when you instantiate the message all of the numerical fields will be 0. The exception to this is when default values are provided in the message definition, but I'm not aware of any std_msgs that provide non-zero default values.

jayess gravatar image jayess  ( 2018-01-12 11:35:03 -0500 )edit

i have already filled the std::Message with some data. but it didnt move.

when i did rostpclist:

/my_robot/leftWheel_effort_controller/command /my_robot/rightWheel_effort_controller/command

this command also dont work: rostopic pub -1 /my_robot/rightWheel_effort_controller/command ...

JossiChrist gravatar image JossiChrist  ( 2018-01-14 01:12:51 -0500 )edit

Did you change the name of the robot from that used in the tutorial? You're using my_robot but the example uses mybot? So the command should be:

rostopic pub -1 /mybot/leftWheel_effort_controller/command std_msgs/Float64 "data: 1.5"
PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-01-14 02:36:41 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-01-10 12:54:51 -0500

Seen: 709 times

Last updated: Jan 12 '18