ROS 용어 이어서

Topic, Publisher, Subscriber
: 프로그램 하나 하나를 노드라 하고, 메시지를 보내는 노드를 publisher, 메시지 받는 노드를 subscriber라고 함, topic은 publisher와 subscriber의 통신 경로, 예를 들어 publisher는 topic에다가 메시지를 보내고 subscriber는 같은 topic으로부터 메시지를 받음

위의 관계는 rosrun 중에 rqt_graph 로 확인 가능

실습 진행전 catkin_ws 생성

실습 진행 전 workspace 만들기
// workspace 만들기

wget https://raw.githubusercontent.com/katebrighteyes/jetson_ros_melodic/master/install_catkinws.sh

chmod 777 install_catkinws.sh

./install_catkinws.sh

// home 디렉토리 아래 catkin_ws 확인

실습 1. ros_topic_test

  • 패키지 만들기
    cd ~/catkin_ws/src
    catkin_create_pkg ros_topic_test std_msgs roscpp
    // 터미널을 닫는다.
    ..소스 작성 후
    cd
    cd catkin_ws
    catkin_make
    컴파일 성공 후 실행
    cd
    cd catkin_ws
    source ./devel/setup.bash
    rosrun ros_topic_test ros_pub_test
  • 그다음 sub, pub 주고 받기
    ~/catkin_ws$ catkin_make
    echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
    rosrun ros_topic_test topic_pub_test
    rosrun ros_topic_test topic_sub_test

실습 2. LiDAR Test

cd catkin_ws/src/
ls

ls /dev/tty*
ll /dev/ttyUSB0
sudo chmod 777 /dev/ttyUSB0

git clone https://github.com/ROBOTIS-GIT/hls_lfcd_lds_driver
ls
cd ..
catkin_make
source ./devel/setup.bash
roslaunch hls_lfcd_lds_driver view_hlds_laser.launch

실습 3. Camera Test

ls -ltr /dev/video*
// video0은 TX2 보드 카메라, video1은 usb 카메라

cd catkin_ws/src
git clone https://github.com/bosch-ros-pkg/usb_cam
cd ..
sudo apt-get install ros-melodic-camera-info-manager libavcodec-dev libswscale-dev -y
catkin_make
source ~/catkin_ws/devel/setup.bash
rospack find usb_cam
sudo apt-get install ros-melodic-image-view
source ~/catkin_ws/devel/setup.bash
[1]
$ roslaunch usb_cam usb_cam-test.launch
// 에러나면 catkin_ws/src/usb_cam/launch에 launch 파일 video0 -> video1로 수정
[2]
$ rosrun rqt_graph rqt_graph

  • RViz 에서 카메라 연결

터미널에 rviz
add 버튼 누르고 by topic 들어가서 output/image

gazebo 실습

gazebo는 디지털 트윈같은거

설치 참고
https://github.com/katebrighteyes/jetson_ros_melodic/blob/master/next/turtlebot3_sim.txt

실행 참고
https://github.com/katebrighteyes/jetson_ros_melodic/blob/master/next/ros_gazebo_slam_ex.txt

TEST

profile
Backend Web Developer

0개의 댓글

Powered by GraphCDN, the GraphQL CDN