ros-student | A student portal for Roots of Success | Portal library
kandi X-RAY | ros-student Summary
kandi X-RAY | ros-student Summary
A student portal for Roots of Success
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ros-student
ros-student Key Features
ros-student Examples and Code Snippets
Community Discussions
Trending Discussions on ros-student
QUESTION
I am working on an assignment that requires you to subscribe to a topic, retrieve a message, then remove a character from a random spot in the string. Then republish that message to another topic. I am stuck on editing the the string and setting it to an empty space, I can not find the an ROS String solution to this problem. Any help is much appreciated.
...ANSWER
Answered 2020-Jan-29 at 21:02You are passing the string as const &
which as the const
implies can't be changed.
Change the signature to void callback_func_name(std_msgs::String& msg){
so you take a reference to the message, which will modify the original object.
Note when taking a reference, you need to ensure that the object is still valid at the time and during the function call. If you can't make that guarantee you'll have to adjust your code.
The line msg[x] = " ";
should be msg.data[x] = ' ';
because the data is contained in the data field and the subscript operator will return you a reference to the character.
The correct headers for C++ are:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ros-student
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page