Coder Social home page Coder Social logo

publishersubscriberroskinetic's Introduction

Publisher and Subscriber (C++) Ros Kinetic

Making a workspace

$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/
$ catkin_make

catkin_make, Creates CmakeLists.txt file inside src folder

now we go to $ cd ~/catkin_ws/src and create the beginner_tutorials package
$ catkin_create_pkg beginner_tutorials std_msgs rospy roscpp

It creates the beginner_tutorials folder and it has a package.xml and a CmakeLists.tx in it.
Now open the package.xml file and if the package format is "2" then package format = "2" if there is <run_depend> tag, we need to replace it with <exec_depend> because <run_depend> belongs to old version.

Now we write a publisher talker node:

$ roscd beginner_tutorials
$ mkdir -p src

We create the src/talker.cpp file in the beginner_tutorials directory and put the publisher's c++ codes in it. We follow the same steps for the subscriber.

Create msg:

$ roscd beginner_tutorials
$ mkdir msg
$ echo "int64 num" > msg/Num.msg

Create srv:

$ roscd beginner_tutorials
$ mkdir srv
$ roscp rospy_tutorials AddTwoInts.srv srv/AddTwoInts.srv

Then we add the following lines in package.xml and CmakeLists.txt file.

generate_messages(DEPENDENCIES std_msgs)

findg_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
message_generation
genmsg )

In your catkin workspace run the following commands

$ roscd beginner_tutorials
$ cd ../..
$ catkin_make install
$ cd -

Publisher:

$ roscore

In your catkin workspace

$ cd ~/catkin_ws
$ source ./devel/setup.bash
$ rosrun beginner_tutorials talker

Publisher

Subscriber:

$ roscore

In your catkin workspace

$ cd ~/catkin_ws
$ source ./devel/setup.bash
$ rosrun beginner_tutorials listener
Subscriber

publishersubscriberroskinetic's People

Contributors

alibizhan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.