absolutely beginner: publisher and subscriber question
I am an absolute beginner. I just try to send "/cmd_evl" msg to move robot while "/scan" msg is received. The received msg show me the distance between robot and target.
callbackFun(){ ......publish_.publish(msg_publish);......};
I am confused that why the received msg is discontinuous? I hope the received msg is like 20M->19M->18M->......0M? But It's received incorrect data suddenly mixed with correct data. ie: 20->19->5.3->2.7->18->17->......0.
A、 callbackFun(const sensor_msgs::LaserScan& msg) { ......
geometry_msgs::Twist twistMsg;
twistMsg.linear.x = msg.range[i] * cos(angle);
twistMsg.angular.z = msg.rangle[i] * sin(angle);
publisher_.publish(twistMsg);
.....
}
In this case, msg will be received incorrect data.
B、callbackFun(const sensor_msgs::LaserScan& msg)
{ ......
geometry_msgs::Twist twistMsg;
twistMsg.linear.x = msg.range[i] * cos(angle);
twistMsg.angular.z = msg.rangle[i] * sin(angle);
//publisher_.publish(twistMsg);
.....
}
In this case, msg will be received correct data. Of course 20->20->20......
C、 callbackFun(const sensor_msgs::LaserScan& msg) { ......
geometry_msgs::Twist twistMsg;
twistMsg.linear.x = 1;
twistMsg.angular.z = 1;
publisher_.publish(twistMsg);
.....
}
In this case, msg will be received correct data. Of course 20->19->18->19->20->19->18......
The correct msg format like:
"**inf...20.111,23.11,24.111..inf**" <<----first frame
"**inf...20.111,23.11,24.111..inf**" <<---second frame
"**inf...20.111,23.11,24.111..inf**" <<---......
"**inf...20.111,23.11,24.111..inf**" <<---.....
The incorrect msg format like:
"**inf...20.111,23.11,24.111..inf**" <<----first frame
"**...0.444,0.666,0.777,0.888,0.333.....**" <<----second frame
"**...0.444,0.666,0.777,0.888,0.333.....**" <<----third frame
"**...0.444,0.666,0.777,0.888,0.333.....**" <<---fourth frame
"**inf...20.111,23.11,24.111..inf**" <<----......
"**inf...20.111,23.11,24.111..inf**" <<---.....
"**...0.444,0.666,0.777,0.888,0.333.....**"<<---......
Though it can be solved through adding “if(...)”. I think it is an abnormal way.
My question:
A、Why?
B、whether it is a normal situation that has some exceptional data or not. Should I pay attention to something like frequency setting, sync time and so on?
Thanks a lot.
Can you please try to describe what it is that you don't understand? Right now I'm having a hard time understanding your issue.
Thanks for your reply. I hope you understand this time. If you have any confusion, just let me know very soon, Waiting for your early reply, TKS again,
"Waiting for your early reply," You get help for free...
I'm sorry but I also can not understand what you're trying to do or what you're asking. The question is worded confusingly.
@Airuno2L@gvdhoorn I subcribe the "/scan" topic and believe it will send me correct msg data. But actually it's not. So i am confused whether it's coused by my publish msg code or any bug......
Is the /scan data coming from a lidar?
@Airuno2L No, just from the simulation.
@NEngelhard Oops, I apologise for it. :)