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(msgpublish);......};
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.
Asked by K03059164 on 2017-06-17 05:55:01 UTC
Comments
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.
Asked by gvdhoorn on 2017-06-18 05:56:46 UTC
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,
Asked by K03059164 on 2017-06-18 08:12:51 UTC
"Waiting for your early reply," You get help for free...
Asked by NEngelhard on 2017-06-19 02:19:52 UTC
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.
Asked by Airuno2L on 2017-06-19 06:45:49 UTC
@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......
Asked by K03059164 on 2017-06-19 10:40:23 UTC
Is the /scan data coming from a lidar?
Asked by Airuno2L on 2017-06-19 10:45:13 UTC
@Airuno2L No, just from the simulation.
Asked by K03059164 on 2017-06-19 20:13:47 UTC
@NEngelhard Oops, I apologise for it. :)
Asked by K03059164 on 2017-06-19 21:06:28 UTC