GithubHelp home page GithubHelp logo

0000duck / ros2_basic_test_and_example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jufengwu/ros2_basic_test_and_example

0.0 0.0 0.0 171 KB

this is a basic example and test for ros2

CMake 23.85% C++ 68.83% Python 4.88% C 2.45%

ros2_basic_test_and_example's Introduction

Ros2 basic test and example

This is a basic example and test for ros2

Preparing

  1. Create a folder. If default path as ~/jufengwu_ros2_test, type mkdir ~/jufengwu_ros2_test/src
  2. Go to that folder. Type cd . ~/jufengwu_ros2_test/src
  3. Download this code. Type git clone https://github.com/JuFengWu/ros2_basic_test_and_example.git
  4. Make sure you have install Ros2 before. If yuo don't install before, please install by follow this tutorial. Currently, this example is for Ros2 Dashing versoin.
  5. Type source /opt/ros/dashing/setup.bash .
  6. Type colocn build.

Dependencies:

Because it have yaml test, please the following packages

libyaml-cpp0.5v5
libyaml-cpp-dev

you can type sudo apt install libyaml-cpp0.5v5 libyaml-cpp-dev to install those packages.

Run action

  1. Type ros2 run action_cpp action_member_functions_server to create a action server.
  2. Type ros2 run action_cpp not_composable_client to create a action client.
  3. Yuo will see the action demon.

Run topic test

  1. Open the first terminal and type ros2 run topic_test topic_sub_node
  2. Open the other terminal and typ ros2 run topic_test topic_pub_node
  3. You can see one terminal send message and the other listen message.

Run service test

  1. Open the first terminal and type ros2 run service_test client_topic_node
  2. Open the other terminal and typ ros2 run service_test service_topic_node
  3. You can see one terminal send service and the other listen it and send result back.

Run image test

  1. Go to source code folder. The default is cd ~/jufengwu_ros2_test/src/ros2_basic_test_and_example.
  2. Type ros2 run image_test pub_img
  3. Open the other terminal and type ros2 run image_test sub_img
  4. You can see one terminal send image information and the other listen it and show the image

Run topic test in python

  1. Open the first terminal and type ros2 run topic_py listener
  2. Open the other terminal and type ros2 run topic_py talker
  3. You can see one terminal send message and the other listen message by python.

Run component

  1. Open the first terminal and type ros2 run rclcpp_components component_container
  2. Open the second termianl and type ros2 component load /ComponentManager component_test composition::Talker, the talker will start to work.
  3. Using the second terminal again and type ros2 component load /ComponentManager component_test composition::Listener, the listener will listen what the talker says.

Run life-cycle test

  1. Open the first terminal and type ros2 run lifecycle lifecycle_listener
  2. Open the second terminal and type ros2 run lifecycle lifecycle_talker
  3. Open the third terminal and type ros2 run lifelifecycle_controller
  4. In the third terminal, you can choose which node state do you want to move.
    ⚠️ Before choose the node state, please read the ros2 node life cycle design on this page. If you switch the node state without follow the rules, it will show up some errors or warnings.

Run the ros1 ros2 bridge test

⚠️ Warning!!

  1. This test will use ros1, please make sure you have insatll ros1 in your computer.
  2. This test is not only use this project, but also use this package. Please follow the instruction to install the package.

The steps are:

  1. Build this project.
  2. Open terminal and type ros2 run bridge_test test_send
  3. Open a new terminal to create ros2 ros1_bridge by typing those cmds
. /opt/ros/melodic/setup.bash
. /opt/ros/dashing/setup.bash
export ROS_MASTER_URI=http://localhost:11311
ros2 run ros1_bridge dynamic_bridge __log_disable_rosout:=true
  1. Download this project and follow this instruction to build and install this project.
  2. Open the other terminal and type roslaunch ros2_send_command_test test_bridge.launch

Others

comming soon!

ros2_basic_test_and_example's People

Contributors

jufengwu 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.