Skip to content

sub #14

Description

@0-0hhj

#include "ros/ros.h"
#include "std_msgs/String.h"

void doMsg(const std_msgs::String::ConstPtr &msg){
std::string original_msg = msg->data;
std_msgs::String new_msg;
std::transform(original_msg.begin(),original_msg.end(),original_msg.begin(),::toupper);
new_msg.data = original_msg;
ROS_INFO("%s",new_msg.data.c_str());
ros::NodeHandle nh2;
ros::Publisher pub = nh2.advertise< std_msgs::String>("output_topic", 1000);
pub.publish(new_msg);

}

int main(int argc, char *argv[])
{
ros::init(argc,argv,"string_converter");
ros::NodeHandle nh;
ros::Subscriber sub = nh.subscribe("original_topic",10,doMsg);
ros::spin();
return 0;
}

Activity

  1. JIAlonglong commented on Apr 14, 2023

    @JIAlonglong
    Collaborator

    能把问题描述一下吗,方便大家解答

  2. 0-0hhj commented on Apr 14, 2023

    @0-0hhj
    Author

    没啥问题,发错了O__o...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions