GithubHelp home page GithubHelp logo

zilantrobotics / innopolis_vtol_dynamics Goto Github PK

View Code? Open in Web Editor NEW
39.0 3.0 8.0 4.03 MB

Cyphal/DroneCAN UAV HITL simulator

License: GNU General Public License v3.0

Shell 53.19% Dockerfile 8.90% Python 37.91%
ros simulation drone uav robotics uavcan cyphal dronecan

innopolis_vtol_dynamics's Introduction

UAV HITL Simulator catkin_build

UAV HITL Simulator brings up a set of ROS packages, config files and instructions to establish a full simulation for UAV based on PX4/Ardupilot autopilot.

drawing

The key feature of this simulation is to run it in such a way that the hardware knows nothing about the simulation. This can be done with Cyphal/DroneCAN. It covers more PX4 modules than standard SITL and HITL.

Purpose

  • Simulation of UAV onboard systems at a low hardware level
  • Testing and debugging of UAV control systems using a CAN-bus
  • Development and testing of intelligent automatic control systems for UAVs
  • Training in the development and use of drones, including creating datasets and automated testing

Requirements

  • Operating System: We've tailored the simulator for modern versions of Windows, Linux, and Mac. Choose the build that matches your OS.

  • CPU: Aim for an Intel i7 from the 11th or 12th generation. For those using AMD, any equivalent processor will suffice.

  • RAM: 16GB is a recommended minimum, but more is always better for performance.

  • Hardware: CUAV V5+, CAN-sniffer

1. Design

VTOL HITL Dynamics Simulator is designed to be modular. It is divided into the following main components:

  1. UAV dynamics is the main node that handles actuator commands from the communicator, performs dynamics simulation, and publishes vehicle and sensors states.
  2. Communicator is the set of nodes that communicate with the PX4 flight stack in HITL (via Cyphal/DroneCAN) and SITL (via MAVLink) modes.
  3. inno_sim_interface is a bridge for interaction with 3D-Simulator through ROS.

The design of the simulator is shown below.

drawing

2. Usage

The simulator is distributed as a Docker image. It is recommended to use the ./scripts/docker.sh script. It configures all the necessary Docker flags, performs automatic firmware upload, configuration, creates a CAN interface, and generally provides a simple interface to interact with the simulator.

Step 1. Clone repository with submodules

git clone https://github.com/ZilantRobotics/innopolis_vtol_dynamics.git --recursive

Whenever you pull this repository, don't forget to update submodules:

git submodule update --init --recursive

Step 2. Build/pull the docker image

To build docker image, type:

./scripts/docker.sh build

An image on dockerhub usually is not up to date, so it's better to build manually

Step 3. Connect everything together for HITL

You should skip this step if you want to run PX4 MAVLink SITL mode. Please follow docs/px4/mavlink for details.

Typically we use CUAV v5+ and RL-programmer-sniffer, but it might be anything else.

An example of a connection is shown in the picture below.

drawing

All default parameters expect that you use CAN1 on the autopilot side.

Step 4. Run the container in force mode

In --force mode the script automatically upload the required firmware and parameters corresponded to the specified mode, create SLCAN and run the container with required docker flags.

To run force mode you need to install autopilot-tools python package: pip install autopilot-tools.

To get the list of all supported modes, just type:

./scripts/docker.sh --help

To run PX4 Cyphal quadcopter, type:

./scripts/docker.sh cq  # cq = px4_v1_15_0_cyphal_quadcopter

To run PX4 Dronecan VTOL, type:

./scripts/docker.sh dv  # cq = dronecan_vtol

Troubleshooting:

  • If your sniffer connection is not found or something else is missing, it will exit in a few seconds.

If something doesn't work, please open an issue.

Step 5. Run ground control station

Here 2 options are suggested.

  1. You can run QGroundControl or MissionPlanner to have manual flight
  2. (soon) You can run a script to run one of the test scenario in automatic mode.

Step 6. (optional) 3D Simulator

A new 3D simulator will appear here soon.

3. Supported modes

You can obrain the actual list of the suported modes by typing ./scripts/docker.sh --help.

Well, here is the output of the command:

Primary supported modes (with aliases):
  px4_v1_15_0_cyphal_quadcopter,cq       | Cyphal     PX4 v1.15-alpha Quadrotor x (4001)
  px4_v1_15_0_cyphal_quadplane_vtol,csv  | Cyphal     PX4 v1.15-alpha Standard VTOL (13000)
  px4_v1_14_0_dronecan_quadrotor,dq      | DroneCAN   PX4 v1.14-beta  Quadrotor (4001)
  px4_v1_14_0_dronecan_quadplane_vtol,dv | DroneCAN   PX4 v1.14-beta  Standard VTOL (13000)
  px4_v1_13_0_dronecan_vtol,dv1130       | DroneCAN   PX4 v1.13.0     vtol 13070

Other modes:
  px4_v1_12_0_mavlink_quadplane_vtol    | MAVLink     PX4 v1.12       vtol 13070
  px4_v1_12_0_mavlink_quadcopter        | MAVLink     PX4 v1.12       Quadrotor (4001)
  cyphal_and_dronecan                   | 2 CAN       AP  v4.4.0      Copter
  px4_v1_15_0_cyphal_octorotor,co       | Cyphal      PX4 v1.15-alpha Octorotor Coaxial (12001)

New modes will be extended step by step.

4. Example

Check the video below.

Cyphal/DroneCAN HITL VTOL dynamics simulator

5. Auxilliary documentation

Docs:

Outdated manual instructions:

innopolis_vtol_dynamics's People

Contributors

frontw avatar ponomarevda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

innopolis_vtol_dynamics's Issues

Couldn't run docker image

I get the following error.

$ sudo docker build .
.
.
.
Successfully built 29a64680dfe7
$ sudo docker run 29a64680dfe7
.
.
.
Param node_id: inno.dynamics
terminate called after throwing an instance of 'std::runtime_error'
  what():  Failed to add iface
================================================================================REQUIRED process [px4_uavcan_communicator-3] has died!
process has died [pid 113, exit code -6, cmd /catkin_ws/devel/lib/uavcan_communicator/uavcan_communicator __name:=px4_uavcan_communicator __log:=/root/.ros/log/b9f39b44-9332-11ec-89fc-0242ac110002/px4_uavcan_communicator-3.log].
log file: /root/.ros/log/b9f39b44-9332-11ec-89fc-0242ac110002/px4_uavcan_communicator-3*.log
Initiating shutdown!
================================================================================
RLException: cannot add process [innosim_relay_node-5] after process monitor has been shut down
The traceback for the exception was written to the log file
.
.
# it terminates
$ sudo docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
$

I can not see log file. .ros directory doesn't exist in my /root directory.

I do not know what I am missing.

OS: Ubuntu 18.04
ROS: melodic (I ve changed in ROS_DISTRO as melodic in docker file)

Unknown target error

Probably I miss something. I couldn't fix the problem.

~/PX4-Autopilot$ DONT_RUN=1 make px4_sitl gazebo_innopolis_vtol
ninja: error: unknown target 'gazebo_innopolis_vtol'
Makefile:231: recipe for target 'px4_sitl' failed
make: *** [px4_sitl] Error 1

Setting CMAKE_BUILD_TYPE as Debug causes exiting the program after arming the vehicle in SITL mode

CMAKE_BUILD_TYPE is currently set as RelWithDebInfo in inno_vtol_dynamics project.

CMakeLists.txt:9
SET(CMAKE_BUILD_TYPE RelWithDebInfo)

If I set it to Debug and arm the vehicle. Program exits.

[ INFO] [1646913596.306345559]: inno_vtol:  mc  [0.00, 0.00, 0.00, 0.00]  fw rpy  [0.00, 0.00, 0.00] throttle  [0.00],  enu pose  [0.0, 0.0, 0.0]
[ INFO] [1646913596.872489711]: cmd: Arm
node: /usr/include/eigen3/Eigen/src/Core/DenseCoeffsBase.h:364: Eigen::DenseCoeffsBase<Derived, 1>::Scalar& Eigen::DenseCoeffsBase<Derived, 1>::operator()(Eigen::Index, Eigen::Index) [with Derived = Eigen::Matrix<double, -1, -1>; Eigen::DenseCoeffsBase<Derived, 1>::Scalar = double; Eigen::Index = long int]: Assertion `row >= 0 && row < rows() && col >= 0 && col < cols()' failed.
================================================================================REQUIRED process [inno_dynamics_sim-4] has died!
process has died [pid 294660, exit code -6, cmd /home/prihex/catkin_ws/devel/lib/innopolis_vtol_dynamics/node __name:=inno_dynamics_sim __log:=/home/prihex/.ros/log/90dcdc54-a069-11ec-9b20-d93dcf7f6b57/inno_dynamics_sim-4.log].
log file: /home/prihex/.ros/log/90dcdc54-a069-11ec-9b20-d93dcf7f6b57/inno_dynamics_sim-4*.log
Initiating shutdown!
================================================================================
[rosapi-9] killing on exit
[rosbridge_websocket-8] killing on exit
[static_transform_publisher_camera-7] killing on exit
[static_transform_publisher1-6] killing on exit

Coudn't run configuration with ./scripts/docker.sh dv --force

Command line:

(sim-pix4) user@user-HP-ProBook-430-G7:~/projects/innopolis_vtol_dynamics$ sudo ./scripts/docker.sh dv --force # dq is abbreviation of dronecan_vtol

Error was raised

/dev/serial/by-id/usb-STMicroelectronics_STM32_STLink_0668FF545151717867185839-if02
Docker Dronecan HITL settings:

  • IMAGE_NAME is ponomarevda/uavcan_hitl_dynamics_simulator:v0.5.0amd64
  • DRONECAN_DEV_PATH_SYMLINK is /dev/serial/by-id/usb-STMicroelectronics_STM32_STLink_0668FF545151717867185839-if02
    WARNING: Package(s) not found: autopilot_tools
    configure.sh ERROR (line 95): autopilot-tools is not installed!

But autopilot_tools are installed in venv

(sim-pix4) user@user-HP-ProBook-430-G7:~/projects/innopolis_vtol_dynamics$ pip list
Package Version


autopilot-tools 0.4.2
certifi 2024.2.2
charset-normalizer 3.3.2
contourpy 1.2.0
cycler 0.12.1
exceptiongroup 1.2.0
fonttools 4.49.0
future 1.0.0
idna 3.6
iniconfig 2.0.0
kiwisolver 1.4.5
lxml 5.1.0
matplotlib 3.8.3
numpy 1.26.4
packaging 24.0
pillow 10.2.0
pip 22.0.2
pluggy 1.4.0
pymavlink 2.4.41
pyparsing 3.1.2
pyserial 3.5
pytest 8.1.1
python-dateutil 2.9.0.post0
PyYAML 6.0.1
requests 2.31.0
setuptools 59.6.0
six 1.16.0
StrEnum 0.4.15
tomli 2.0.1
tqdm 4.66.2
urllib3 2.2.1

Is propeller location calculation is right?

In vtolDynamicsSim.cpp:loadParams() function, propeller locations are created by multiplying sin(45) for x and y locations.

params_.propellersLocation[0] << propLocX * sin(3.1415/4),  propLocY * sin(3.1415/4), propLocZ;
params_.propellersLocation[1] <<-propLocX * sin(3.1415/4), -propLocY * sin(3.1415/4), propLocZ;
params_.propellersLocation[2] << propLocX * sin(3.1415/4), -propLocY * sin(3.1415/4), propLocZ;
params_.propellersLocation[3] <<-propLocX * sin(3.1415/4),  propLocY * sin(3.1415/4), propLocZ;

I think multiplying sin45 is unnecessary and wrong. I am not sure of it, still trying to understand all part of code. In body frame, locx is simply distance in x axis. Please correct me if I'm wrong.

// That might be the solution if i think right
params_.propellersLocation[0] << propLocX,  propLocY,  propLocZ;
params_.propellersLocation[1] <<-propLocX, -propLocY,  propLocZ;
params_.propellersLocation[2] << propLocX, -propLocY,  propLocZ;
params_.propellersLocation[3] <<-propLocX,  propLocY,  propLocZ;

./scripts/sim.py report error because logs directory not exists

./scripts/sim.py needs logs directory to exist. Error gone after creating directory, but better to check it in code

roman@RG5:~/Projects/UAVCAN/innopolis_vtol_dynamics$ ./scripts/sim.py 
Traceback (most recent call last):
  File "./scripts/sim.py", line 164, in <module>
    main()
  File "./scripts/sim.py", line 110, in main
    logging.basicConfig(level=logging.DEBUG,
  File "/usr/lib/python3.8/logging/__init__.py", line 1988, in basicConfig
    h = FileHandler(filename, mode)
  File "/usr/lib/python3.8/logging/__init__.py", line 1147, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/lib/python3.8/logging/__init__.py", line 1176, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
FileNotFoundError: [Errno 2] No such file or directory: '/home/roman/Projects/UAVCAN/innopolis_vtol_dynamics/logs/log_2024-07-08_15-01-56.log'

Into PX4 docs/codelines?

This is awesome. Would be great to get this linked into the PX4 User Guide! Fantastic for people to be able to find this when looking into Simulators and UAVCAN.

  • Is that something that you are planning?
  • I see you branch off version 1.12. Is there an intent to push this into master?
  • What can I do to help with integration into the PX4 docs?

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.