Giter Site home page Giter Site logo

ros2-tuturial's Introduction

Ros2-tuturial

Installation

1- Install ROS2-Humble & colcon(to build the packages) 2- Add it to enviromental variables

gedit ~/.bashrc
source /opt/ros/humble/setup.bash
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash

test it using 3 terminals

ros2 run demo_nodes_cpp talker
ros2 run demo_nodes_cpp listener
rqt_graph

creating working space and add it ot enviromental variables

mkdir ros2_ws
cd ros2_ws
mkdir src
colcon build # it will craete all necessary files and folders including setup.bash so you can run it using 
source ~/dev/ros2_ws/install/setup.bash

create ROS2 python package

cd src
ros2 pkg create my_robot_controler --build-type ament_python  (youc n also use ament_cmake)  --dependencies rclpy
cd ..
colcon build

add code to your package and run it

cd my_robot_controler/my_robot_controler
touch my_first_node.py
chmod +x my_first_node.py

#write your code inside my_first_node (check the example in this repo) first send second line should be #!/usr/bin/env python3 & import rclpy import Node class and inherit from that

run the code itself using ./myfirstnode To be able to run it on your ros2 run you need to add it to setup.py in section"entry_points" e.g sudo vim src/my_robotcontroler/setup.py entry_points={'console_scripts': ["test_node= my_robot_controler.my_first_node:main"],}

cd ~/dev/ros2_ws
colcon build
source ~./bashrc
ros2 run my_robot_controler test_node

if you dont want to type "colcon build" each time you make changes to your code you can type "colcon build --symlink-install" once

command list

Feature/Component Description
ros2 node list list of nodes
ros2 node info get info
ros2 topic list list of topics
ros2 topic info get info
ros2 topic echo see output of a publisher
ros2 topic hz see frequency of publisher outputs
ros2 interface show see data structure of input or output for the topic aftergetting the topic info
ros2 service list list of services
ros2 service type type of service
ros2 interface show show data
rqt_qrt show the gragh
colcon build build project
colcon build --packages-up-to time_controler build a specific package only
ros2 run time_controler nmea_subscriber
ros2 launch fixposition_driver_ros2 tcp.launch
create client. service, publisher, subsriber different type of constructors

PTP

use installation here:// https://tsn.readthedocs.io/timesync.html#introduction//

1- check ethernets
ip link show
2- use ethtool to check if an eth send the ptp
ethtool -T <name from list above>
3- use this command
sudo ptp4l -i eno1 -f configs/gPTP.cfg --step_threshold=1 -m
4- get check_clocks.c and compile it (check if your pc clock is synchronized)
gcc -o check_clocks check_clocks.c
sudo ./check_clocks -d <name from list above>
Clocks on this system are synchronized :)


ros2-tuturial's People

Contributors

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