0
$\begingroup$

Rosanswers logo

Dear guys,

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

https://www.generationrobots.com/blog/en/2015/02/robotic-simulation-scenarios-with-gazebo-and-ros/

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 :(


Originally posted by JossiChrist on ROS Answers with karma: 1 on 2018-01-10

Post score: 0


Original comments

Comment by jayess on 2018-01-10:
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.

Comment by JossiChrist on 2018-01-12:
i have showed the code

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by PeteBlackerThe3rd with karma: 9529 on 2018-01-12

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by jayess on 2018-01-12:
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.

Comment by JossiChrist on 2018-01-14:
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 ...

Comment by PeteBlackerThe3rd on 2018-01-14:
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"
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.