Giter VIP home page Giter VIP logo

rmcs's Introduction

RMCS

RoboMaster Control System based on ROS2.

Develop

Configure environment

TODO .

  1. ubuntu-server
  2. ssh-server
  3. docker

Connect with nuc

Net plan

# in /etc/netplan/****.yaml
network:
    renderer: networkd
    version: 2
    ethernets:
        enp1s0:
            optional: true                  # optional enable
            set-name: mid-360
            addresses: [192.168.1.50/24]
            match:
              macaddress: 70:70:fc:03:7f:83

        enx6c1ff703689c:                    # device name
            optional: true                  # optional
            set-name: qzhhhi                # name
            addresses: [192.168.234.2/24]   # static ip address + /24
            match:                          # match:
              macaddress: 6c:1f:f7:03:68:9c # mac address

        enx207bd27efaf5:
            optional: true
            set-name: creeper5820
            addresses: [192.168.234.3/24]
            match:  
              macaddress: 20:7b:d2:7e:fa:f5

    wifis:
        wlp2s0:
            optional: true                  # optional enable
            access-points:
                AllianceTeam5.8G:
                    password: rm-alliance.icu
            dhcp4: true

DHCP server (optional)

# After you set local ip to 192.168.234.1
# And check what is the name of your ethernet device
docker run -it --rm --privileged --network=host qzhhhi/dhcp-server eno1

Sync and Start

# Set remote ip
set-remote 192.168.234.2

# ssh
ssh-remote

# Copy the install directory to remote
# TODO: Remove directory restrictions
sync-remote

How to make NUC connect to Internet

Gateway

To make Ubuntu1 regarded as gateway, edit the /etc/netplan/***.yaml. A possible version is shown below.

# Let NetworkManager manage all devices on this system
network:
    ethernets:
        ens32:                    ## network card name
            dhcp4: false
            addresses:
              - 192.168.234.5/24   ## set static IP
            routes:
              - to: default
                via: 192.168.234.1  ## gateway
    version: 2

Soft Route

Assuming that Ubuntu 1 has wlp4s0 connected to Internet and eno1 connected to NUC, Run commands below in Ubuntu 1 to create a soft route.

sudo iptables -A FORWARD -i eno1 -o wlp4s0 -j ACCEPT
sudo iptables -A FORWARD -i wlp4s0 -o eno1 -m state --state ESTABLISHED,RELATED -j ACCEPT
sudo iptables -t nat -A POSTROUTING -o wlp4s0 -j MASQUERADE

Remap Port of Omni Direction Perception Camera

  1. Check out Pid and Vid.
lsusb | grep DECXIN

As shown below, Pid is 2cd1 while Vid is 1bcf.

Bus 003 Device 011: ID 1bcf:2cd1 Sunplus Innovation Technology Inc. DECXIN CAMERA

  1. Check out port.
udevadm info --attribute-walk --name=/dev/video2 | grep "KERNEL"

As shown below, port is "3-2".

KERNEL=="video2"
KERNELS=="3-2:1.0"
KERNELS=="3-2"
KERNELS=="usb3"
KERNELS=="0000:36:00.4"
KERNELS=="0000:00:08.1"
KERNELS=="pci0000:00"

  1. Edit udev rules
sudo gedit /etc/udev/rules.d/omni.rules 

Type rules below

KERNEL=="video*",KERNELS=="3-2", ATTRS{idProduct}=="2cd1", ATTRS{idVendor}=="1bcf", MODE:="0777", SYMLINK+="leftfront"
KERNEL=="video*",KERNELS=="3-1", ATTRS{idProduct}=="2cd1", ATTRS{idVendor}=="1bcf", MODE:="0777", SYMLINK+="rightfront"
KERNEL=="video*",KERNELS=="3-3", ATTRS{idProduct}=="2cd1", ATTRS{idVendor}=="1bcf", MODE:="0777", SYMLINK+="left"
KERNEL=="video*",KERNELS=="3-4", ATTRS{idProduct}=="2cd1", ATTRS{idVendor}=="1bcf", MODE:="0777", SYMLINK+="right"
  1. Refresh
sudo udevadm control --reload-rules && sudo udevadm trigger

Runtime environment build

  1. Pull or load images
  • Online
sudo docker pull qzhhhi/rmcs-runtime 
  • Offline
sudo docker load -i rmcs-runtime.tar
  1. Start with NUC
sudo vi /etc/init.d/rmcs-runtime.sh

Type content below

### BEGIN INIT INFO
# Providers:         rmcs-runtime.sh
# Description:       run rmcs runtime environment
### END INIT INFO
 
 
systemctl start docker
docker run --restart=always --privileged --network=host -v /dev:/dev qzhhhi/rmcs-runtime

PS: ### BEGIN INIT INFO and ### END INIT INFO are required.

sudo chmod 775 rmcs-runtime.sh
sudo update-rc.d rmcs-runtime.sh defaults 90 

Gimbal calibration

source /opt/ros/humble/setup.bash 
ros2 topic pub -1 /gimbal/calibrate std_msgs/msg/Int32 "{'data':1}"
cat /rmcs.launch.out

Gyro calibration

source /opt/ros/humble/setup.bash 
ros2 topic pub -1 /imu/calibrator std_msgs/msg/Int8 "{'data':1}" # Start calibrating
ros2 topic pub -1 /imu/calibrator std_msgs/msg/Int8 "{'data':0}" # Finish calibrating
cat /rmcs.launch.out

PS: All control should be disabled when calibrating.

rmcs's People

Contributors

qzhhhi avatar kaleckkk avatar 7emotions avatar creeper5820 avatar

Stargazers

skybase avatar  avatar  avatar  avatar  avatar  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.