Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Turtlesim pose

I'm using the following code to generate a time-dependent velocity command for the turtle


int main(int argc, char**argv) {

ros::init(argc, argv, "pub_one");

ros::NodeHandle n;

ros::Publisher pub = n.advertise<turtlesim::velocity>("/turtle1/command_velocity", 1000); srand(time(0)); double secs1 =ros::Time::now().toSec();

while(pub.getNumSubscribers() == 0) ros::Duration(0.1).sleep();

ros::Rate r(1);

while(true) {

turtlesim::Velocity msg;

double secs2 =ros::Time::now().toSec();

double secs3=secs2-secs1;




ROS_INFO("Sending random velocity command: linear=%f angular=%f time=%f", msg.linear, msg.angular,secs3);


r.sleep(); } }


I don't know how I can change the code to get the position of the turtle at each time?

In fact, I wanna make a feedback control by using the position of the turtle and a desired position.

I really appreciate if you help me in this case!