Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dodecarotor Cox Mod - Issues #45

Open
mariepierb opened this issue Mar 25, 2021 · 1 comment
Open

Dodecarotor Cox Mod - Issues #45

mariepierb opened this issue Mar 25, 2021 · 1 comment

Comments

@mariepierb
Copy link

Hi!
I am trying to simulate a Dodecarotor Cox multicopter. I started my mod from your hexacopter vehicle, and followed the numbering so that it matches the PX4 - QGC numbering found here (https://docs.px4.io/master/en/airframes/airframe_reference.html).

Dodecarotor.java:
package me.drton.jmavsim.vehicle;

import me.drton.jmavsim.Rotor;
import me.drton.jmavsim.World;

import javax.vecmath.Matrix3d;
import javax.vecmath.Vector3d;

/**

  • Generic Dodecarotor model.
    */
    public class Dodecarotor extends AbstractMulticopter {
    private static final int rotorsNum = 12;
    private Vector3d[] rotorPositions = new Vector3d[rotorsNum];
    // private int[] rotorRotations = new int[rotorsNum];

    /**

    • Generic Dodecarotor constructor.

    • @param world world where to place the vehicle

    • @param modelName filename of model to load, in .obj format

    • @param orientation "x" or "+"

    • @param armLength length of arm from center (m)

    • @param rotorThrust full thrust of one rotor (N)

    • @param rotorTorque torque at full thrust of one rotor (Nm)

    • @param rotorTimeConst spin-up time of rotor

    • @param rotorHeight height of propeller from center point (m)

    • @param rotorsOffset rotors positions offset from gravity center

    • @param showGui false if the GUI has been disabled
      */
      public Dodecarotor(World world, String modelName, String orientation, double armLength,
      double rotorThrust, double rotorTorque, double rotorTimeConst, double rotorHeight,
      Vector3d rotorsOffset, boolean showGui) {
      super(world, modelName, showGui);

       rotorPositions[0] = new Vector3d(0.0, armLength, -rotorHeight);
       rotorPositions[1] = new Vector3d(0.0,-armLength, -rotorHeight);
       rotorPositions[2] = new Vector3d(armLength * Math.sin(Math.PI / 3),
       								-armLength * Math.cos(Math.PI / 3), -rotorHeight);
       rotorPositions[3] = new Vector3d(-armLength * Math.sin(Math.PI / 3),
       								armLength * Math.cos(Math.PI / 3), -rotorHeight);
       rotorPositions[4] = new Vector3d(armLength * Math.sin(Math.PI / 3),
       								armLength * Math.cos(Math.PI / 3), -rotorHeight);
       rotorPositions[5] = new Vector3d(-armLength * Math.sin(Math.PI / 3),
       								-armLength * Math.cos(Math.PI / 3), -rotorHeight);
       rotorPositions[6] = new Vector3d(0.0, armLength, rotorHeight);
       rotorPositions[7] = new Vector3d(0.0,-armLength, rotorHeight);
       rotorPositions[8] = new Vector3d(armLength * Math.sin(Math.PI / 3),
       								-armLength * Math.cos(Math.PI / 3), rotorHeight);
       rotorPositions[9] = new Vector3d(-armLength * Math.sin(Math.PI / 3),
       								armLength * Math.cos(Math.PI / 3), rotorHeight);
       rotorPositions[10] = new Vector3d(armLength * Math.sin(Math.PI / 3),
       								armLength * Math.cos(Math.PI / 3), rotorHeight);
       rotorPositions[11] = new Vector3d(-armLength * Math.sin(Math.PI / 3),
       								-armLength * Math.cos(Math.PI / 3), rotorHeight);				
      

      if (orientation.equals("x") || orientation.equals("X")) {
      Matrix3d r = new Matrix3d();
      r.rotZ(-Math.PI / 2);
      for (int i = 0; i < rotorsNum; i++) {
      r.transform(rotorPositions[i]);
      }

      } else {
      throw new RuntimeException("Unknown orientation: " + orientation);
      }
      for (int i = 0; i < rotors.length; i++) {
      rotorPositions[i].add(rotorsOffset);
      Rotor rotor = rotors[i];
      rotor.setFullThrust((i > 5) ? 0.9*rotorThrust : rotorThrust); //Lower propeller reduced efficiency
      rotor.setFullTorque((i == 6 || i == 3 || i == 4 || i == 6 || i == 8 || i == 11) ? -rotorTorque : rotorTorque);
      rotor.setTimeConstant(rotorTimeConst);
      }
      }

    @OverRide
    protected int getRotorsNum() {
    return rotorsNum;
    }

    @OverRide
    protected Vector3d getRotorPosition(int i) {
    return rotorPositions[i];
    }
    }

I am calling it from Simulator.java using these specific values :

private AbstractMulticopter buildMulticopter() {
Vector3d gc = new Vector3d(0.0, 0.0, 0.0); // gravity center

	AbstractMulticopter vehicle = new Dodecarotor(world, DEFAULT_VEHICLE_MODEL, "x",
                                           0.6096, 306.26, 19.07, 0.005, 0.114, gc, SHOW_GUI);
	
    Matrix3d I = new Matrix3d();
    // Moments of inertia
    I.m00 = 39.0;  // X
    I.m11 = 39.0;  // Y
    I.m22 = 52.0;  // Z
    vehicle.setMomentOfInertia(I);
    vehicle.setMass(100);
    vehicle.setDragMove(2);
    SimpleSensors sensors = new SimpleSensors();
    sensors.setGPSInterval(50);
    sensors.setGPSDelay(200);
    sensors.setNoise_Acc(0.05f);
    sensors.setNoise_Gyo(0.01f);
    sensors.setNoise_Mag(0.005f);
    sensors.setNoise_Prs(0.1f);
    vehicle.setSensors(sensors, getSimMillis());
    //v.setDragRotate(0.1);

    return vehicle;
}

The build of the code is successful, however, my drone does not take off. I believe the error might lies in AbstractMulticopter.java . Can you help me? Or is there resources anywhere to help me build my own airframe configurations?

@zondafeng
Copy link

do you solve it? i have a similar question. i want to modify the relationship between thrust/moment and rotation speed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants