BowlerKernel
WheelCSGPhysicsManager.java
Go to the documentation of this file.
1 package com.neuronrobotics.bowlerstudio.physics;
2 
3 import java.util.ArrayList;
4 
5 import com.bulletphysics.dynamics.vehicle.RaycastVehicle;
6 import com.bulletphysics.dynamics.vehicle.WheelInfo;
7 import com.bulletphysics.linearmath.Transform;
8 //import com.neuronrobotics.bowlerstudio.BowlerStudio;
9 import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR;
10 import com.neuronrobotics.sdk.common.IClosedLoopController;
11 import com.neuronrobotics.sdk.util.ThreadUtil;
12 
13 import eu.mihosoft.vrl.v3d.CSG;
14 
16 
18  private double target = 0;
19  private static float muscleStrength = (float) 1000;
20  boolean flagBroken = false;
21  private double velocity;
22  private RaycastVehicle vehicle;
23  private final int wheelIndex;
24 
25  public WheelCSGPhysicsManager(ArrayList<CSG> baseCSG, Transform pose, double mass, PhysicsCore c,
26  RaycastVehicle v, int wheelIndex) {
27  super(baseCSG, pose, mass, false, c);
28  this.vehicle = v;
29  this.wheelIndex = wheelIndex;
30  }
31 
32  @Override
33  public void update(float timeStep) {
34  //cut out the falling body update
35  if (getUpdateManager() != null) {
36  try {
37  getUpdateManager().update(timeStep);
38  } catch (Exception e) {
39  //BowlerStudio.printStackTrace(e);
40  throw e;
41  }
42  }
43  if (getController() != null) {
44  velocity = getController().compute(getWheelInfo().rotation, getTarget(), timeStep);
45 
46  }
47  vehicle.updateWheelTransform(getWheelIndex(), true);
49  .bulletToNr(vehicle.getWheelInfo(getWheelIndex()).worldTransform);
50  //copy in the current wheel location
52  }
53 
54  public double getTarget() {
55  return target;
56  }
57 
58  public void setTarget(double target) {
59  this.target = target;
60  }
61 
62  public static float getMotorStrength() {
63  return muscleStrength;
64  }
65 
66  public static void setMuscleStrength(float ms) {
67  muscleStrength = ms;
68  }
69 
70  public void setMuscleStrength(double muscleStrength) {
72  }
73 
75  return controller;
76  }
77 
79  this.controller = controller;
80  }
81 
82  public WheelInfo getWheelInfo() {
83  return vehicle.getWheelInfo(getWheelIndex());
84  }
85 
86  public int getWheelIndex() {
87  return wheelIndex;
88  }
89 
90 
91 }
static void nrToBullet(TransformNR nr, com.bulletphysics.linearmath.Transform bullet)
static TransformNR bulletToNr(com.bulletphysics.linearmath.Transform bullet)
WheelCSGPhysicsManager(ArrayList< CSG > baseCSG, Transform pose, double mass, PhysicsCore c, RaycastVehicle v, int wheelIndex)
double compute(double currentState, double target, double seconds)