Skip to content

Latest commit

 

History

History
324 lines (225 loc) · 9.74 KB

2024赛季工程入门文档.md

File metadata and controls

324 lines (225 loc) · 9.74 KB

2024赛季工程入门文档

代码部署

建议先在电脑上安装好Cliongit等工具

  • 配置GitHub ssh密钥

    队内pull、push代码到仓库以及连车传代码均使用ssh,在本地配置好ssh之后才可以进行其他内容

    参考文档1(CSDN)

    参考文档2(GitHub文档)

  • 配置rm_ws

    rm_ws是对内代码统一使用的工作空间,在home目录下新建一个名为rm_ws的工作空间

    参考文档(ROS wiki)

  • 从仓库pull代码

    配置好Clion及rm_ws后可以开始部署代码了,以下是工程正在使用的仓库:

    一定要使用ssh来clone仓库

rm_manual:实现键鼠操作

rm_config:放参数的地方,也是最常修改的地方

rm_engineer:工程专用的包,主要实现.action类型的消息以及和manual的交互

rm_bringup:开机自启,硬件映射

rm_control:一些代码中可用的工具,比如滤波器,从yaml拿参数等

rm_description:放置仿真用的stl模型和urdf文件

rm_controllers:各种控制器

​ 把上述仓库全部fork后pull到本地./rm_ws/src

加粗的两个仓库是最常用的

  • 安装软件包所需依赖

    仓库的代码有依赖的其他包,使用rosdep来安装所需依赖,如果没有安装依赖就编译则会报错

    rosdep install --from-paths src --ignore-src -r -y

    rosdep在中国大陆地区因为网络环境问题基本不可用,可以使用代理或搜索rosdep失效的解决方法

调试工具

  • rviz

    mon launch engineer_arm_cofig rviz.launch
    
  • plotjuggler

    rosrun plotjuggler plotjuggler
    
  • rqt

    mon launch rqt rqt s
    
  • moveit_commander

    rosrun moveit_commander moveit_commander_cmdline.py
    
  • actionlib_tools

    rosrun actionlib_tools axclient.py /engineer_middleware/move_steps
    

调试流程

  • 连上工程后关闭自启的服务

    工程自启时会自己开一个master,我们调车时需要频繁关闭程序和master来使修改过的程序重新传到参数服务器中

    stop_master
    stop_ecat_start
    
  • 开终端连车,运行程序

    bringup中已经把所有需要的东西都包括在里面了

    roscore
    bringup
    
  • 校准机械臂

    在右开关位于中间时左开关位于上方是校准状态

  • 测试动作组

    连接客户端使用键鼠进行测试或使用moveit_commander对动作进行单独测试

环境配置

  • bashrc

    先修改bashrc,方便后续调试

    vim .bashrc

    直接复制粘贴如下内容

    # ~/.bashrc: executed by bash(1) for non-login shells.
    # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
    # for examples
    
    # If not running interactively, don't do anything
    case $- in
    *i*) ;;
    *) return;;
    esac
    
    # don't put duplicate lines or lines starting with space in the history.
    # See bash(1) for more options
    HISTCONTROL=ignoreboth
    
    # append to the history file, don't overwrite it
    shopt -s histappend
    
    # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
    HISTSIZE=1000
    HISTFILESIZE=2000
    
    # check the window size after each command and, if necessary,
    # update the values of LINES and COLUMNS.
    shopt -s checkwinsize
    
    # If set, the pattern "**" used in a pathname expansion context will
    # match all files and zero or more directories and subdirectories.
    #shopt -s globstar
    
    # make less more friendly for non-text input files, see lesspipe(1)
    [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
    
    # set variable identifying the chroot you work in (used in the prompt below)
    if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
    fi
    
    # set a fancy prompt (non-color, unless we know we "want" color)
    case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
    esac
    
    # uncomment for a colored prompt, if the terminal has the capability; turned
    # off by default to not distract the user: the focus in a terminal window
    # should be on the output of commands, not on the prompt
    #force_color_prompt=yes
    
    if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
    # We have color support; assume it's compliant with Ecma-48
    # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
    # a case would tend to support setf rather than setaf.)
    color_prompt=yes
    else
    color_prompt=
    fi
    fi
    
    if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    fi
    unset color_prompt force_color_prompt
    
    # If this is an xterm set the title to user@host:dir
    case "$TERM" in
    xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
    *)
    ;;
    esac
    
    # enable color support of ls and also add handy aliases
    if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'
    
        alias grep='grep --color=auto'
        alias fgrep='fgrep --color=auto'
        alias egrep='egrep --color=auto'
    fi
    
    # colored GCC warnings and errors
    #export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
    
    # some more ls aliases
    alias ll='ls -alF'
    alias la='ls -A'
    alias l='ls -CF'
    
    # Add an "alert" alias for long running commands.  Use like so:
    #   sleep 10; alert
    alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
    
    # Alias definitions.
    # You may want to put all your additions into a separate file like
    # ~/.bash_aliases, instead of adding them here directly.
    # See /usr/share/doc/bash-doc/examples in the bash-doc package.
    
    if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
    fi
    
    # enable programmable completion features (you don't need to enable
    # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
    # sources /etc/bash.bashrc).
    if ! shopt -oq posix; then
    if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
    elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
    fi
    fi
    
    
    #export ROS_IP=`ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | grep -v '172.17.0.1'`
    
    #if  test -z "${ROS_IP}"
    #then
    #        export ROS_IP=`dig +short localhost`
    #fi
    
    
        net='sw'
    
    if [ "$net" == "sw" ]; then
    export ROS_IP='192.168.100.1'
    export ROS_MASTER_URI=http://192.168.100.2:11311
    elif [ "$net" == "wifi" ]; then
    export ROS_IP='192.168.1.16'
    export ROS_MASTER_URI=http://192.168.1.194:11311
    elif [ "$net" == "local" ]; then
    export ROS_IP='127.0.0.1'
    export ROS_MASTER_URI=http://127.0.0.1:11311
    fi
    
    echo "ROS IP: ${ROS_IP}
    ROS Master URI: ${ROS_MASTER_URI}"
    export ROBOT_TYPE=engineer
    echo "ROBOT_TYPE: ${ROBOT_TYPE}"
    
    alias setcan0='sudo ip link set can0 up type can bitrate 1000000'
    alias setcan1='sudo ip link set can1 up type can bitrate 1000000'
    alias setcan2='sudo ip link set can2 up type can bitrate 1000000'
    alias setcan3='sudo ip link set can3 up type can bitrate 1000000'
    
    alias engineer_client='rosrun actionlib_tools axclient.py /engineer_middleware/move_steps'
    alias fishros='wget http://fishros.com/install -O fishros && . fishros'
    alias bashrc='vim /home/cch/.bashrc'
    alias bash='source /home/cch/.bashrc'
    alias engineer_client='rosrun actionlib_tools axclient.py /engineer_middleware/move_steps'
    alias rqt_joint='rosrun rqt_joint_trajectory_controller rqt_joint_trajectory_controller'
    export filepath="/etc/apt/"
    alias engineer='ssh [email protected]'
    alias engineer_w='ssh [email protected]'
    alias wired='ssh -o StrictHostKeyChecking=no -l "dynamicx" "192.168.100.2"'
    alias insdep='rosdepc install --from-paths src --ignore-src -r -y'
    # >>> fishros initialize >>>
    source /opt/ros/noetic/setup.bash
    # <<< fishros initialize <<<
    
    source /home/cch/rm_ws/devel/setup.bash
    
    # >>> fishros scripts >>>
    export PATH=$PATH:/home/cch/.fishros/bin/
    # <<< fishros scripts <<<
    

    保存并退出vim,在终端中输入bash


  • 配置连车SSH

    要使用ssh连接到工程,首先要知道工程的IP地址:浏览器输入192.168.1.1,账号及密码均为admin,在已链接设备中找到engineer,记住其IP地址

    连接到队内WiFi,终端输入 ssh [email protected],弹出提示后输入密码dynamicx

    一切顺利的话,终端开头绿色的字符应该变为dynamicx@engineer

    • ssh免密

      在终端输入ssh-copy-id [email protected],之后再连接工程无需输入密码

    • bashrc配置alias快速连接工程 在bashrc中写入alias engineer='ssh [email protected]',即可输入engineer直接连接工程


  • Clion配置

​ 参考rm-control文档