ROS_Basics - RicoJia/notes GitHub Wiki

========================================================================

Basics of the Basics

========================================================================

Node

  1. Example 1: Pub Sub

    • CMakeList

    • package.xml

    • test_pubsub.cpp

      1. logging_and_sleep
      2. pub_sub()
      3. sub_bind_spin
      4. test_server
      5. remap
    • test_launch.launch

      • rosparam, param
    • rospy example

      • another node
        1. private namespace
        2. latched topic (may not be a good idea for anything related to tf, because if your tf changes, the latched topic will be too old and will not be used)
        3. Publish laser scan msg
        4. launch a node
    • Additional Notes:

      1. source devel/setup.bash: contains project-specific env variables. There's a global source devel/setup.bash
      2. double tab to auto complete rosservice call /service_name
      3. Function called by ros upon shutdown. Need to be called explicitly as ros doesn't call del automatically?
        • but after sending shutdown signal, we can close the queues and processes
        • rospy.on_shutdown(cb) calls cb after some objects get destructed
        • object_tracking
    • message_filter?

      • The tf::MessageFilter will take a subscription to any ros Message with a Header and cache it until it is possible to transform it into the target frame. Once data is ready, you can transform it to target_frame_. see tutorial
  2. Launch File

    1. rjje_arm launch file
      • node name
      • roslaunch --wait will wait for a roscore to come up
    2. demo.launch
      • include other launch files
      • arg, default
    3. object_tracking
      • get ros param
  3. test_tf.cpp

    • Affine Transforms
    • tf used in icp project
      • Convert Eigen::Affine3d to tf::Transform:
      • publish "static" transform
    • publish anything related to tf periodically, do not use latched topic
    • Tf2, lookup transform, what's improved
  4. Laser Scans

  5. rostest

    • need roscore, but don't need rostest: upper level
      • load_params.test go into launch
    • nice explanation
    • rostest is 100% compatible with roslaunch
  6. file structure of a package that goes into python space, ROS Python Package: http://wiki.ros.org/rospy_tutorials/Tutorials/Makefile

    ros_utils/setup.py -> scripts as the src folder
    ros_utils/scripts/SimpleRoboticsPythonUtils/__init__.py
    ros_utils/scripts/SimpleRoboticsPythonUtils/OtherFiles
    
  7. printing

    • enable ros debug: you have to specify a rosconsole config file, then export it to ROSCONSOLE_CONFIG_FILE. debug print set up

Misc Commands

  1. see all ros commands export | grep ROS
  2. rosbash commands (defined in setup.bash)
    roscd package
    rospack list
    rospack find
    # see contents of a package 
    rosls sensor_msgs
    
    # Ros bags, <space> for pause
    rosbag play bag
    
    # Ros topic 
    rostopic bw /topic #see bandwidth
    • image topics rosbag are slow, they may cause topics not being able to receive the full messages/

========================================================================

Navigation

========================================================================

  1. gmapping

    • base_scan
    • 2d lidar
    • map msg
      • Error subscribing: Character [ ] at element
    • scan_matching:
      1. for every beam in observation, get the end point (x,y), then in the existing map, find nearest obstacle? and calculate the likelihood of that point being an obstacle, which is gaussian()
  2. minimal_example

========================================================================

Moveit

========================================================================

  1. move group 讲解 

Gazebo

========================================================================

  1. URDF

    1. How to spawn a model separately, see code
    2. Xacro example see code
      1. meshes might be mis-scaled, because of unit setting when created. so do <meshscale="0.01 0.01 0.01"> under xacro
      2. multiply everything in origin_xyz is difficult. See here
      3. use xacro property as a parameter
  2. load a world: gazebo worlds/pioneer2dx.world

  3. spawn a model gz model -f rjje_arm.xacro.urdf -m "rjje_arm". Note that gazebo uses libsdformat, which can read both SDF and URDF files

    1. There might be problems?
  4. ROS Controllers

    1. Types
      1. effort - output is torque
        • input: joint position, velocity, etc.
      2. joint_state
      3. position controller sudo apt-get install ros-noetic-position-controllers
      4. velocity controller
      5. joint_trajecotry
    2. Hardware interface
      • URDF: need gazebo ros_control, transmission
      • config: joints (j1, j2), type (controller position), etc.
      • launch file: controller manager,
    3. Setup
      1. controller.yaml
      2. control.urdf
      3. gazebo_launch
    4. api
      1. rostopic pub /joint_2_controller/command std_msgs/Float64 "data: -1.0"

========================================================================

Object Detection

========================================================================

  1. Yolo, see code
  2. Pointcloud2, Image: see code

========================================================================

Docker

========================================================================

  1. Behavior Tree: example for Docker + makefile: see code
    • You can specify files for building: docker build -f
  2. with GUI: see link
    • xhost +local:root # for the lazy and reckless letting all apps running as root to access xserver. Vulnarable as a malicious app can display something on the screen.
⚠️ **GitHub.com Fallback** ⚠️