Eklavya-Copter-Control : aPR0T0/Eklavya-Copter-Control Repository
- Ubuntu 20.04 OS
- ROS Noetic Ninjemys (Note: We will be using Ros1 and Python3)
- Gazebo and Gazebo Ros Installation
1. Install and initialize ROS Noetic Ninjemys, additional requried ROS packages, catkin-tools and wstool :
(Commands being run in Ubuntu Terminal in Home Directory)
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu `lsb_release -sc` main" > /etc/apt/sources.list.d/ros-latest.list'
wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get install ros-noetic-desktop-full ros-noetic-joy ros-noetic-octomap-ros ros-noetic-mavlink python3-wstool python3-catkin-tools protobuf-compiler libgoogle-glog-dev ros-noetic-control-toolbox ros-noetic-mavros
sudo rosdep init
rosdep update
source /opt/ros/noetic/setup.bash
-
If you don’t have
source /opt/ros/noetic/setup.bash
line in your bash file then run following commandsgedit ~/.bashrc
Add following command at the end of your bash file
source /opt/ros/noetic/setup.bash
“SAVE” and then close the file
Then run following command in terminal
source ~/.bashrc
-
Then just before using
line 3
of the above block just type insudo apt install -f
(This is auto remove feature of ros of unwanted commands) after this the problem should be solved. -
It is not necessary to solve this error (But in few cases it might be required)
Run
sudo rm <path mentioned in error>
, for examplesudo rm /etc/ros/rosdep/sources.list.d/20-default.list
Then Run
sudo rosdep init
Then Run
rosdep update
(Commands being run in Ubuntu Terminal in <workspace_name>/src directory once workspace created)
mkdir -p ~/hexacopter_ws/src
cd ~/hexacopter_ws/src
catkin_init_workspace
wstool init
wget https://raw.githubusercontent.com/ethz-asl/rotors_simulator/master/rotors_hil.rosinstall
wstool merge rotors_hil.rosinstall
wstool update
Note the repository is to be cloned in the <workspace_name>/src directory
(Note : Here we are using https to clone repository, other methods like ssh key,.. can also be used. Also, recursive cloning is used so any linked components if any are not missed (Recursive cloning is not essential, but is done to prevent any missing of essential linked components in certain cases))
cd ~/hexacopter_ws/src
git clone --recursive https://github.com/aPR0T0/Eklavya-Copter-Control.git
(Commands being run in Ubuntu Terminal in <workspace_name> directory)
Checking/Installing python3_catkin_tools
:
sudo apt-get update
sudo apt-get install python3-catkin-tools
Building Workspace :
cd ~/hexacopter_ws
catkin init
catkin build
If any errors occur you could run catkin init
and catkin build
commands again
Note : There should be total 10 packages (maybe more) installed successfully for installation to be successful
echo "source ~/hexacopter_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
Launch the simulator with a hex-rotor helicopter model, in our case, the AscTec Firefly in a basic world.
$ roslaunch rotors_gazebo mav.launch mav_name:=omav world_name:=basic
There are some basic launch files where you can load the different multicopters with additional sensors. They can all be found in ~/catkin_ws/src/rotors_gazebo/launch
.
The world_name
argument looks for a .world file with a corresponding name in ~/catkin_ws/src/rotors_gazebo/worlds
. By default, all launch files, with the exception of those that have the world name explicitly included in the file name, use the empty world described in basic.world
.
To let the multicopter fly you need to generate thrust with the rotors, this is achieved by sending commands to the multicopter, which make the rotors spin. There are currently a few ways to send commands to the multicopter, we will show one of them here. The rest is documented here in our Wiki.
We will for now just send some constant motor velocities to the multicopter.
$ rostopic pub /firefly/command/motor_speed mav_msgs/Actuators '{angular_velocities: [700, 700, 700, 700, 700, 700, 700, 700, 700, 700, 700, 700, 0, 0, 0, 0, 0, 0]}'
Note The size of the
motor_speed
array should be equal to the number of motors you have in your model of choice (e.g. 6 in the Firefly model). Also, the last 6 elements are preserved for the angles of the tilt rotors
You can play with the numbers and will realize that the Firefly will take off with motor speeds of about 545 on each rotor. The multicopter is unstable though, since there is no controller running, if you just set the motor speeds.
You can let the helicopter hover with ground truth odometry (perfect state estimation), by launching:
$ roslaunch rotors_gazebo mav.launch mav_name:=omav world_name:=basic