rostopic pub does not allow carriage return or line feed in the string
Am am trying to send a string like
AT\r\n
to a modem through a String topic in ROS
I am able to do it in code but I can not do it in a terminal window
rostopic pub /mytopic stdmsgs/String "data: 'AT\r\n'"
Is there a way to do this?
Asked by borgcons on 2019-10-18 17:03:07 UTC
Answers
s.macenski@reese:~$ echo $'\r'
s.macenski@reese:~$ echo '\r'
\r
Does the $
fix your issue?
Edit: I think you actually want \\
out instead. But you'd have to indicate specifically what issue you're having that you're looking to solve, its not necessarily clear to me, maybe I'm misreading what you're looking for
Asked by stevemacenski on 2019-10-18 19:08:19 UTC
Comments
I'm not sure how this helps me do a rostopic pub
Asked by borgcons on 2019-10-18 19:27:02 UTC
because its still your shell interpreting the return. Did you try it?
Asked by stevemacenski on 2019-10-18 19:46:45 UTC
This is what I am trying to do:
rostopic pub /my_topic std_msgs/String "data: 'AT\r\n'"
How do I use the $ for this?
I just don't get it yet
Asked by borgcons on 2019-10-18 21:46:59 UTC
I'm suggesting trying 'AT$\r\n' but I'm not sure if it'll work, I was looking to you to tell me if that fixes it.
If not another option to try is double slash, ei 'AT<2 \>r<2 \>n' which should also potentially give you the viable solution
Asked by stevemacenski on 2019-10-18 23:30:57 UTC
Neither work
Asked by borgcons on 2019-10-19 17:10:44 UTC
If you want \n
to be translated into a newline, you can combine echo -e
with rostopic pub
rostopic pub /my_topic std_msgs/String "$(echo -e "data: 'AT\r\n")"
ref: https://stackoverflow.com/questions/8467424/echo-newline-in-bash-prints-literal-n
Asked by Rufus on 2023-06-08 05:48:15 UTC
Comments
I have one terminal opened with
$ rostopic echo /foo
and another where I do$ rostopic pub /foo std_msgs/String 'AT\r\n'
. The first one receives, as expected:The same output can be achieved with
$ rostopic pub /banana std_msgs/String "{data: AT\r\n}"
which is more similar to your syntax.This to say I don't think your issue is clear. Is it that you don't want the double backslash? Or you want the
\r
and\n
to be interpreted as carriage return?Asked by aPonza on 2019-10-23 11:06:07 UTC
Yes I want the \r and \n to be interpreted as CR and LF
Asked by borgcons on 2020-05-12 04:26:45 UTC