diff --git a/README.md b/README.md index 4595af6..27a71f1 100644 --- a/README.md +++ b/README.md @@ -37,3 +37,7 @@ Here are the articles in this book: {% content-ref url="resources/" %} [resources](resources/) {% endcontent-ref %} + +{% content-ref url="setting-up-offboard-mission/" %} +[setting-up-offboard-mission](setting-up-offboard-mission/) +{% endcontent-ref %} diff --git a/SUMMARY.md b/SUMMARY.md index 1a304be..4f22b78 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -69,7 +69,6 @@ * [PID Controller](control-system/pid-controller/README.md) * [Introduction](https://www.youtube.com/watch?v=4Y7zG48uHRo) * [Basic Theory](https://www.youtube.com/watch?v=UR0hOmjaHp0\&feature=youtu.be\&t=215) - * [Offboard mode](control-system/offboard-mode.md) * [Estimation](estimation/README.md) * [Visual-Inertial Odometry](estimation/vio/README.md) * [Hardware Requirements](estimation/vio/hardware.md) @@ -110,3 +109,8 @@ * [IMAV 2019, Madrid, Spain](competitions/imav-2019-madrid-spain.md) * [Inter-IIT TechMeet 10.0](competitions/inter-iit-techmeet-10.0.md) * [Inter-IIT TechMeet 11.0](competitions/inter-iit-techmeet-11.0.md) +* [Setting up Offboard Mission](setting-up-offboard-mission/README.md) + * [Setting up Companion Computer](setting-up-offboard-mission/setting-up-companion-computer/README.md) + * [Raspberry Pi 4B Setup](setting-up-offboard-mission/setting-up-companion-computer/raspberry-pi-4b-setup.md) + * [Communication Setup](setting-up-offboard-mission/communication-setup.md) + * [Guided mode](setting-up-offboard-mission/offboard-mode.md) diff --git a/setting-up-offboard-mission/README.md b/setting-up-offboard-mission/README.md new file mode 100644 index 0000000..f3df406 --- /dev/null +++ b/setting-up-offboard-mission/README.md @@ -0,0 +1,22 @@ +--- +description: >- + This section contains information about different aspects of communication and + offboard setup +--- + +# Setting up Offboard Mission + + + +{% content-ref url="setting-up-companion-computer/" %} +[setting-up-companion-computer](setting-up-companion-computer/) +{% endcontent-ref %} + +{% content-ref url="communication-setup.md" %} +[communication-setup.md](communication-setup.md) +{% endcontent-ref %} + +{% content-ref url="offboard-mode.md" %} +[offboard-mode.md](offboard-mode.md) +{% endcontent-ref %} + diff --git a/setting-up-offboard-mission/communication-setup.md b/setting-up-offboard-mission/communication-setup.md new file mode 100644 index 0000000..5e41a0b --- /dev/null +++ b/setting-up-offboard-mission/communication-setup.md @@ -0,0 +1,239 @@ +--- +description: >- + This page covers the configuration of ROS MASTER and MULTIMASTER, along with + instructions on connecting to Wi-Fi using the terminal +--- + +# Communication Setup + +## Ros Master + +First we setup the commnunication between the computers. In this one computer is master and remaining computers are slave. + +### Setup + +First connect all the computers in the same network. Every computer will have their IP assigned in the network in the subnet mask of 24. Check the IP all computer by typing _**ifconfig**_ in the terminal. Note the IP of the master computer. Run the following command in all the slave computer. + +```bash +export ROS_MASTER_URI=http://:11311 +``` + +Now, Every computer should also export their own IP. Type the following command in every computer. + +```bash +export ROS_IP= +``` + +To check everything is setup, type the following commands. + +```bash +echo $ROS_MASTER_URI +echo $ROS_IP +``` + +Now, everything is established. You can now run the _**roscore**_ on the master computer. Now you can run nodes on computer and view their topics on any computer. + +#### Example + +I am running talker on one computer + +```bash +rosrun rospy_tutorials talker +``` + +Check on others computer if this node is running by typing _**rosnode list**_ . This will show talker node running. + +Now you can run listener on other computer to see the talker message. + +```bash +rosrun rospy_tutorials listener +``` + +## $${\color{red}Warning}$$ + +Firewall should be disabled on all the computer for proper communication setup. + +You can check it by following command + +```bash +sudo ufw status +``` + +This should show _inactive_. But if it is active, then you have to disable it by following command. + +```bash +sudo ufw disable +``` + +## Multimaster fkie + +This is different from ROS Master in a way that in this multiple masters are running and are communicating with each other. + +### Master running on same computer(host) + +In this we start two ROS master on the same host using different ROS\_MASTER\_URI. Then we start the synchronization to let rostopic pub and rostopic echo communicate together. + +#### Setup the environment + +In the first console we start the ROS master and an example publisher, which publish Hello World to topic with name /test/topic: + +```bash +export ROS_MASTER_URI=http://localhost:11311 +roscore --port 11311 >/dev/null 2>&1 & +rostopic pub /test/topic std_msgs/String 'Hello World' -r 1 & +``` + +In the second console we start a second ROS master and a rostopic echo to receive the Hello World messages: + +```bash +export ROS_MASTER_URI=http://localhost:11312 +roscore --port 11312 >/dev/null 2>&1 & +rostopic echo /test/topic & +``` + +At this moment, no topic is being published on the master at localhost:11312 so rostopic echo command shouldn't print any topic. + +#### Download the Required Packages + +```bash +sudo apt install ros-noetic-multimaster-fkie +sudo apt install ros-noetic-fkie-master-sync +``` + +#### Multi-master Synchronization + +On the 1st console in the previous section, run the following code + +```bash +rosrun fkie_master_discovery master_discovery >/dev/null 2>&1 & +rosrun fkie_master_sync master_sync >/dev/null 2>&1 & +``` + +Do exactly the same on the 2nd console: + +```bash +rosrun fkie_master_discovery master_discovery >/dev/null 2>&1 & +rosrun fkie_master_sync master_sync >/dev/null 2>&1 & +``` + +Now both ROS masters are synchronized, and the 2nd console should start printing the message ('Hello World') being published on the ROS master at localhost:11311 on the 1st console. + +### Master running on different computers(hosts) + +In this we will start two ROS masters on two different hosts + +First, we will make sure we have the correct settings enabled. After that we will register the hostnames of the machines so that the two hosts can identify each other. + +#### Enable the network settings + +We will need to make sure two settings are working: IP forwarding and multicasting should be enabled. We can check if IP forwarding is enabled by executing the following command in a console on both hosts: + +```bash +cat /proc/sys/net/ipv4/ip_forward +``` + +If this command returns 1 then IP forwarding is enabled. If it is not you can temporarily enable it using: + +```bash +sudo sh -c "echo 1 >/proc/sys/net/ipv4/ip_forward" +``` + +To find out whether multicasting is enabled you can execute the following command: + +```bash +cat /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts +``` + +If this command returns 0 then multicasting is enabled. If it is not you can temporarily enable it using: + +```bash +sudo sh -c "echo 0 >/proc/sys/net/ipv4/icmp_echo_ignore_broadcasts" +``` + +Now you can test the network setup utilizing the code from the first example on two machines. The nodes should be able to discover each other but a warning is expected: "Master discovered with not known hostname". You cannot yet send messages from one host to the other. + +#### Set the necessary hostname information + +Linux keeps a file that contains information on the IP addresses that the computer can connect to and their respective hostnames. This file can be found under /etc/hosts. The warning that we got in the previous subsection told us that the computer found an IP address for which no host was set. We will do that now. + +You can discover the hostname of a computer and the corresponding IP address by executing the following commands: + +```bash +hostname +hostname -I +``` + +Now we need to specify the IP and corresponding hostname in each host for the other host. Simply add a line to the /etc/hosts file in each host containing the IP address and the hostname seperated by a tab (you will need administrator rights for this). + +```bash +sudo nano /etc/hosts +``` + +Running the aforementioned commands should now allow you to send messages from one host to the other! + +## Connecting to WiFi through terminal + +### Check Your Wireless Interface Name + +First, we need to identify the network devices that we are going to use to connect to our wifi network. We can list our interfaces with the following command + +```bash +iwconfig +``` + +Interface should be like that starts with "wlan" or "wlp1s0". This is your wireless interface name. + +Now check the WiFi radio status with the following command. + +```bash +nmcli radio wifi +``` + +This should show enabled. If this is disabled then enable it by + +```bash +nmcli radio wifi on +``` + +You can check the status of your network interface cards with + +```bash +nmcli dev status +``` + +If your wifi card is hard blocked on your Laptop/Computer, you need to execute the following commands and repeat the above steps + +```bash +echo "blacklist hp_wmi" | sudo tee /etc/modprobe.d/hp.conf +sudo rfkill unblock all +``` + +### Scan For Available Wifi Networks + +We need to scan for available wifi networks with which we can connect to + +```bash +nmcli dev wifi list +``` + +or + +```bash +sudo iw wlp1s0 scan | grep SSID +``` + +This should list out the names of all the available wifi networks around you. + +### Connect To The Wifi Network + +You can connect to a network simply by the following command + +```bash +sudo nmcli dev wifi connect password +``` + +or + +```bash +sudo nmcli --ask dev wifi connect +``` diff --git a/setting-up-offboard-mission/offboard-mode.md b/setting-up-offboard-mission/offboard-mode.md new file mode 100644 index 0000000..dbf597c --- /dev/null +++ b/setting-up-offboard-mission/offboard-mode.md @@ -0,0 +1,22 @@ +--- +description: Description about Guided mode of ArduPilot +--- + +# Guided mode + +In this mode the position, velocity or attitude reference / target / setpoint is provided by a companion computer connected via serial cable and MAVLink. The offboard setpoint can be provided by API like [MAVROS](https://github.com/mavlink/mavros). + +Normal mainstream Ardupilot Firmware uses this message flow and Runs a high-level PID Controller: + +### Message Flows + +| ROS msg name | msg type | uses | +| ------------------------------- | --------------------------- | ------------------------------------------ | +| mavros/local\_position/odom | nav\_msgs::Odometry | Contains local odometry data | +| mavros/setpoint\_position/local | geometry\_msgs::PoseStamped | Used in offboard mode for postion setpoint | + +### Example + +![](<../.gitbook/assets/Untitled presentation (1).png>) + +The instructions for assembling the “essential components” of Copter on Pixhawk and other autopilots. The instructions for adding other hardware are covered in [Optional Hardware](https://ardupilot.org/copter/docs/common-optional-hardware.html#common-optional-hardware). diff --git a/setting-up-offboard-mission/setting-up-companion-computer/README.md b/setting-up-offboard-mission/setting-up-companion-computer/README.md new file mode 100644 index 0000000..63e095b --- /dev/null +++ b/setting-up-offboard-mission/setting-up-companion-computer/README.md @@ -0,0 +1,11 @@ +--- +description: >- + The following pages provide concise instructions for configuring various + Companion computers currently available in our inventory. +--- + +# Setting up Companion Computer + +{% content-ref url="raspberry-pi-4b-setup.md" %} +[raspberry-pi-4b-setup.md](raspberry-pi-4b-setup.md) +{% endcontent-ref %} diff --git a/setting-up-offboard-mission/setting-up-companion-computer/raspberry-pi-4b-setup.md b/setting-up-offboard-mission/setting-up-companion-computer/raspberry-pi-4b-setup.md new file mode 100644 index 0000000..1795512 --- /dev/null +++ b/setting-up-offboard-mission/setting-up-companion-computer/raspberry-pi-4b-setup.md @@ -0,0 +1,127 @@ +# Raspberry Pi 4B Setup + +Setting up a Raspi Onboard companion computer from scratch without a mouse and keys (making rocks sophisticated with bare hands). Keep a microSD card ready. We are using Ubuntu 20.04 Server Image. Simulation software are not needed and also won't work in this OS. + +## Flashing OS on the board + +Install "rpi-imager" + +```bash +sudo apt install rpi-imager +``` + +Start the Raspberry Pi Imager. Put your microSD card into your computer. + +On the Raspberry Pi Imager, click on “Choose OS”. Navigate to your preferred OS(Ubuntu 20.04 Server image). + +Also, click on “Choose Storage” and you should find your microSD card. + +The configuration is not complete, do not click on “Write” yet. + +Instead, click on the settings icon. + +Then, here are the settings you need to enable: + +* “Enable SSH” to enable SSH. +* “Set username”. For the username you can choose whatever you want, I will use “pi” for the following of this tutorial. You also need to choose a password. +* “Configure wireless LAN”. This will enable the Wi-Fi and automatically connect to the network + password you provide. Of course, this Wi-Fi network should be the same as the one your computer is currently connected to, otherwise, the rest of this tutorial won’t work. + +(a few moments later 0\_0) + +Put the SD card into the Board. Check the LED status of the board to see if it is booting from the card, otherwise, format the card and try again. + +## Setup Ubuntu Server Image for ARIITK + +* Basic Linux Setup + +```bash +sudo apt-get update +sudo apt-get upgrade +timedatectl set-local-rtc 1 --adjust-system-clock +sudo apt-get install git +``` + +* ROS Setup + +```bash +# setup sources.list +sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' + +# setup keys +sudo apt install curl # if you haven't already installed curl +curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - + +# installation +sudo apt update +sudo apt install ros-noetic-base + +#initialize rosdep +sudo apt install python3-rosdep #if you have not yet installed rosdep,run this line otherwise skip +sudo rosdep init +rosdep update + +# setup environment +echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc +source ~/.bashrc + +# fulfill dependencies +sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential +``` + +* Setup MAVROS for communicating to ROS via MAVlink protocol + +```bash +# install some dependencies +sudo apt install python3-rosinstall python3-rosinstall-generator python3-wstool build-essential + +# install MAVROS +sudo apt-get install ros-noetic-mavros ros-noetic-mavros-extras + +cd ~/ + +wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh + +sudo chmod a+x install_geographiclib_datasets.sh + +sudo ./install_geographiclib_datasets.sh + +# Install catkin tools +sudo apt-get install python3-catkin-tools + +# Updating MAVProxy and pymavlink (new versions released now and then) +sudo pip install --upgrade pymavlink MAVProxy + +#Setup MAVROS to begin communication +cd ~/ + +mkdir -p ardupilot_ws/src + +cd ardupilot_ws + +catkin init + +cd src + +mkdir launch + +cd launch + +roscp mavros apm.launch apm.launch + +sudo gedit apm.launch #opens a text editor, follow the next command (you can also do it using any other editor of your choice, for eg. by using 'code' commmand) + +#To proxy to a Ground Control Station like QGC or Mission Planner on ground we just need to modify the first line to . save you file and launch it with- + +cd ~/ardupilot_ws/src/launch + +roslaunch apm.launch + +``` + +* QGC Setup for proxy via MAVROS (set the ground-port and ground-hostname here) + +Open QGC > Go to 'Application Settings' > Go to 'Comm Links' tab from side menu > Click 'Add' in options menu below > Select 'Type' as 'UDP' > Type {ground-port} in + +"Port" and {ground-hostname} in "Server Addresses (optional)" > Click "OK" > Click on "Connect" tab from side menu + +**MAKE SURE YOUR BOARD AND GROUND STATION ARE CONNECTED TO THE SAME LAN SETUP VIA A ROUTER FOR PROXY TO WORK**