Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 1689 → Rev 1690

/dongfang_FC_rewrite_tool/.project
20,4 → 20,15
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
<filteredResources>
<filter>
<id>1339659083645</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-.svn</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
/dongfang_FC_rewrite_tool/configsets/ENC-03/configset.xml
New file
0,0 → 1,138
<parameterset eepromVersion="3" length="73">
<parameter name="bitConfig">
<bit name="CFG_SIMPLE_HEIGHT_CONTROL" value="0"/>
<bit name="CFG_SIMPLE_HC_HOLD_SWITCH" value="0"/>
<bit name="CFG_HEADING_HOLD" value="1"/>
<bit name="CFG_COMPASS_ACTIVE" value="0"/>
<bit name="CFG_UNUSED" value="0"/>
<bit name="CFG_GPS_ACTIVE" value="0"/>
<bit name="CFG_AXIS_COUPLING_ACTIVE" value="0"/>
<bit name="CFG_GYRO_SATURATION_PREVENTION" value="1"/>
</parameter>
<parameter name="levelCorrectionPitch" value="128"/>
<parameter name="levelCorrectionRoll" value="128"/>
<parameter name="gyroP" value="160"/>
<parameter name="gyroI" value="80"/>
<parameter name="gyroD" value="4"/>
<parameter name="attitudeControl" value="0"/>
<parameter name="stickP" value="4"/>
<parameter name="stickD" value="4"/>
<parameter name="stickYawP" value="8"/>
<parameter name="stickThrottleD" value="4"/>
<parameter name="minThrottle" value="8"/>
<parameter name="maxThrottle" value="230"/>
<parameter name="externalControl" value="0"/>
<parameter name="motorSmoothing" value="0"/>
<parameter name="dynamicStability" value="50"/>
<parameter name="IFactor" value="52"/>
<parameter name="yawIFactor" value="200"/>
<parameter name="compassMode" value="0"/>
<parameter name="compassYawCorrection" value="64"/>
<parameter name="compassBendingReturnSpeed" value="255"/>
<parameter name="compassP" value="50"/>
<parameter name="batteryVoltageWarning" value="105"/>
<parameter name="emergencyThrottle" value="35"/>
<parameter name="emergencyFlightDuration" value="30"/>
<parameter name="airpressureFilterConstant" value="8"/>
<parameter name="airpressureWindowLength" value="0"/>
<parameter name="airpressureDWindowLength" value="24"/>
<parameter name="airpressureAccZCorrection" value="184"/>
<parameter name="heightP" value="10"/>
<parameter name="heightI" value="var7"/>
<parameter name="heightD" value="30"/>
<parameter name="heightSetting" value="var3"/>
<parameter name="heightControlMaxIntegralIn" value="125"/>
<parameter name="heightControlMaxIntegralOut" value="75"/>
<parameter name="heightMaxThrottleChange" value="75"/>
<parameter name="heightControlTestOscPeriod" value="0"/>
<parameter name="heightControlTestOscAmplitude" value="0"/>
<parameter name="servoCount" value="7"/>
<parameter name="servoManualMaxSpeed" value="2"/>
<parameter name="pitchServoControl" value="var1"/>
<parameter name="pitchServoStabilization" value="45"/>
<parameter name="pitchServoMinValue" value="32"/>
<parameter name="pitchServoMaxValue" value="224"/>
<parameter name="pitchServoFlags">
<bit name="reverseStabilization" value="0"/>
<bit name="Unused" value="0"/>
<bit name="Unused" value="0"/>
<bit name="Unused" value="0"/>
<bit name="Unused" value="0"/>
<bit name="Unused" value="0"/>
<bit name="Unused" value="0"/>
<bit name="Unused" value="0"/>
</parameter>
<parameter name="rollServoControl" value="var2"/>
<parameter name="rollServoStabilization" value="80"/>
<parameter name="rollServoMinValue" value="32"/>
<parameter name="rollServoMaxValue" value="224"/>
<parameter name="rollServoFlags">
<bit name="reverseStabilization" value="1"/>
<bit name="Unused" value="0"/>
<bit name="Unused" value="0"/>
<bit name="Unused" value="0"/>
<bit name="Unused" value="0"/>
<bit name="Unused" value="0"/>
<bit name="Unused" value="0"/>
<bit name="Unused" value="0"/>
</parameter>
<parameter name="output0BitMask">
<bit name="t0" value="1"/>
<bit name="t1" value="0"/>
<bit name="t2" value="0"/>
<bit name="t3" value="0"/>
<bit name="t4" value="0"/>
<bit name="t5" value="0"/>
<bit name="t6" value="0"/>
<bit name="t7" value="0"/>
</parameter>
<parameter name="output0Timing" value="15"/>
<parameter name="output1BitMask">
<bit name="t0" value="1"/>
<bit name="t1" value="1"/>
<bit name="t2" value="0"/>
<bit name="t3" value="0"/>
<bit name="t4" value="0"/>
<bit name="t5" value="0"/>
<bit name="t6" value="0"/>
<bit name="t7" value="0"/>
</parameter>
<parameter name="output1Timing" value="15"/>
<parameter name="outputDebugMask">
<bit name="DEBUG_MAINLOOP_TIMER" value="0"/>
<bit name="DEBUG_HEIGHT_DIFF" value="0"/>
<bit name="DEBUG_HOVERTHROTTLE" value="0"/>
<bit name="DEBUG_ACC0THORDER" value="1"/>
<bit name="DEBUG_SIGNAL" value="0"/>
<bit name="DEBUG_PRESSURERANGE" value="0"/>
<bit name="DEBUG_CLIP" value="0"/>
<bit name="DEBUG_SENSORLIMIT" value="0"/>
</parameter>
<parameter name="outputFlags">
<bit name="INVERT_OUTPUT0" value="0"/>
<bit name="INVERT_OUTPUT1" value="0"/>
<bit name="FLASH_OUTPUT0_BEEPING" value="1"/>
<bit name="FLASH_OUTPUT1_BEEPING" value="1"/>
<bit name="USE_ONBOARD_LEDS" value="1"/>
<bit name="TEST_OFF" value="0"/>
<bit name="TEST_ON" value="0"/>
<bit name="UNUSED" value="0"/>
</parameter>
<parameter name="naviMode" value="0"/>
<parameter name="naviStickThreshold" value="255"/>
<parameter name="naviStickLimit" value="255"/>
<parameter name="GPSMinimumSatellites" value="255"/>
<parameter name="naviP" value="255"/>
<parameter name="naviI" value="255"/>
<parameter name="naviD" value="255"/>
<parameter name="naviTestOscPeriod" value="255"/>
<parameter name=" naviTestOscAmplitude" value="255"/>
<parameter name="userparam0" value="0"/>
<parameter name="userparam1" value="1"/>
<parameter name="userparam2" value="2"/>
<parameter name="userparam3" value="3"/>
<parameter name="userparam4" value="4"/>
<parameter name="userparam5" value="5"/>
<parameter name="userparam6" value="6"/>
<parameter name="userparam7" value="7"/>
</parameterset>
/dongfang_FC_rewrite_tool/configsets/ENC-03/imu_45degrotation.xml
New file
0,0 → 1,25
<imuconfiguration eepromVersion="0" length="11" name="ENC-03/FC1.3">
<parameter name="gyroQuadrant" value="7" />
<parameter name="accQuadrant" value="3" />
<parameter name="imuReversedFlags">
<bit name="IMU_REVERSE_GYRO_PR" value="0" />
<bit name="IMU_REVERSE_GYRO_YAW" value="1" />
<bit name="IMU_REVERSE_ACC_XY" value="1" />
<bit name="IMU_REVERSE_ACC_Z" value="0" />
<bit name="Unused" value="0" />
<bit name="Unused" value="0" />
<bit name="Unused" value="0" />
<bit name="Unused" value="0" />
</parameter>
 
<parameter name="gyroPIDFilterConstant" value="1" />
<parameter name="gyroDWindowLength" value="8" />
<parameter name="accFilterConstant" value="15" />
 
<parameter name="zerothOrderCorrection" value="200" />
<parameter name="rateTolerance" value="200" />
<parameter name="gyroActivityDamping" value="64" />
 
<parameter name="driftCompDivider" value="2" />
<parameter name="driftCompLimit" value="50" />
</imuconfiguration>
/dongfang_FC_rewrite_tool/configsets/ENC-03/imu.xml
1,4 → 1,4
<imuconfiguration eepromVersion="0" length="11" name="ENC-03/FC1.3">
<imuconfiguration eepromVersion="1" length="12" name="ENC-03/FC1.3">
<parameter name="gyroQuadrant" value="0" />
<parameter name="accQuadrant" value="4" />
<parameter name="imuReversedFlags">
13,7 → 13,8
</parameter>
 
<parameter name="gyroPIDFilterConstant" value="1" />
<parameter name="gyroDFilterConstant" value="1" />
<parameter name="gyroDWindowLength" value="8" />
<parameter name="gyroDFilterConstant" value="0" />
<parameter name="accFilterConstant" value="15" />
 
<parameter name="zerothOrderCorrection" value="10" />
21,5 → 22,5
<parameter name="gyroActivityDamping" value="64" />
 
<parameter name="driftCompDivider" value="2" />
<parameter name="driftCompLimit" value="0" />
<parameter name="driftCompLimit" value="50" />
</imuconfiguration>
/dongfang_FC_rewrite_tool/configsets/templates/imuconfiguration_v0.xml
1,4 → 1,4
<imuconfigurationtemplate eepromVersion="0" length="12" >
<imuconfigurationtemplate eepromVersion="0" length="11" >
<parameter name="gyroQuadrant" />
<parameter name="accQuadrant" />
<parameter name="imuReversedFlags" type="bitset">
14,7 → 14,6
 
<parameter name="gyroPIDFilterConstant" />
<parameter name="gyroDWindowLength" />
<parameter name="gyroDFilterConstant" />
<parameter name="accFilterConstant" />
<parameter name="zerothOrderCorrection" />
/dongfang_FC_rewrite_tool/configsets/templates/imuconfiguration_v1.xml
1,4 → 1,4
<imuconfigurationtemplate eepromVersion="1" length="12" >
<imuconfigurationtemplate eepromVersion="1" length="11" >
<parameter name="gyroQuadrant" />
<parameter name="accQuadrant" />
<parameter name="imuReversedFlags" type="bitset">
14,7 → 14,6
 
<parameter name="gyroPIDFilterConstant" />
<parameter name="gyroDWindowLength" />
<parameter name="gyroDFilterConstant" />
<parameter name="accFilterConstant" />
<parameter name="zerothOrderCorrection" />
/dongfang_FC_rewrite_tool/src/dongfang/mkt/comm/MKInputStream.java
18,14 → 18,15
import dongfang.mkt.frames.ReadExternalControlResponseFrame;
import dongfang.mkt.frames.ReadIMUConfigurationResponseFrame;
import dongfang.mkt.frames.ReadMotorMixerResponseFrame;
import dongfang.mkt.frames.ReadParamSetResponseFrame;
import dongfang.mkt.frames.ReadRCChannelsResponseFrame;
import dongfang.mkt.frames.ReadVariablesResponseFrame;
import dongfang.mkt.frames.ResponseFrame;
import dongfang.mkt.frames.SetCompassHeadingResponseFrame;
import dongfang.mkt.frames.ReadParamSetResponseFrame;
import dongfang.mkt.frames.VersionResponseFrame;
import dongfang.mkt.frames.WriteIMUConfigurationResponseFrame;
import dongfang.mkt.frames.WriteMotorMixerResponseFrame;
import dongfang.mkt.frames.WriteParamSetResponseFrame;
import dongfang.mkt.frames.ReadVariablesResponseFrame;
import dongfang.mkt.frames.VersionResponseFrame;
 
public class MKInputStream extends InputStream {
int readByteCnt;
368,7 → 369,15
f.setCapacityUsed(base64InputStream.readWord());
result = f;
break;
}
}
case 'P': {
ReadRCChannelsResponseFrame f = new ReadRCChannelsResponseFrame(address);
int numberOfChannels = base64InputStream.readByte();
f.setNumberOfChannels(numberOfChannels);
f.setChannels(base64InputStream.readSignedWords(numberOfChannels));
result = f;
break;
}
case 'S': {
WriteParamSetResponseFrame f = new WriteParamSetResponseFrame(address);
f.setParameterSetNumber(base64InputStream.readByte());
/dongfang_FC_rewrite_tool/src/dongfang/mkt/comm/MKOutputStream.java
18,6 → 18,7
import dongfang.mkt.frames.ReadIMUConfigurationRequestFrame;
import dongfang.mkt.frames.ReadMotorMixerRequestFrame;
import dongfang.mkt.frames.ReadParamSetRequestFrame;
import dongfang.mkt.frames.ReadRCChannelsRequestFrame;
import dongfang.mkt.frames.ReadVariablesRequestFrame;
import dongfang.mkt.frames.RequestFrame;
import dongfang.mkt.frames.ResetRequestFrame;
261,4 → 262,8
base64OutputStream.writeByte(f.getDataLength());
base64OutputStream.writeBytes(f.getData());
}
public void visit(ReadRCChannelsRequestFrame f) throws IOException {
writeByte('p');
}
}
/dongfang_FC_rewrite_tool/src/dongfang/mkt/frames/ReadRCChannelsRequestFrame.java
New file
0,0 → 1,17
package dongfang.mkt.frames;
 
import java.io.IOException;
 
import dongfang.mkt.RequestFrameVisitor;
 
public class ReadRCChannelsRequestFrame extends RequestFrame {
 
public ReadRCChannelsRequestFrame() {
super(FC_ADDRESS);
}
 
@Override
public void accept(RequestFrameVisitor o) throws IOException {
o.visit(this);
}
}
/dongfang_FC_rewrite_tool/src/dongfang/mkt/frames/ReadRCChannelsResponseFrame.java
New file
0,0 → 1,41
package dongfang.mkt.frames;
 
public class ReadRCChannelsResponseFrame extends ResponseFrame {
private int numberOfChannels;
private int[] channels;
public ReadRCChannelsResponseFrame(int address) {
super(address);
// TODO Auto-generated constructor stub
}
 
public int getNumberOfChannels() {
return numberOfChannels;
}
 
public void setNumberOfChannels(int numberOfChannels) {
this.numberOfChannels = numberOfChannels;
}
 
public int[] getChannels() {
return channels;
}
 
public void setChannels(int[] channels) {
this.channels = channels;
}
 
@Override
public boolean isResponseTo(RequestFrame r) {
return r instanceof ReadRCChannelsRequestFrame;
}
public String toString() {
StringBuilder sb = new StringBuilder();
for (int i=0; i<getNumberOfChannels(); i++) {
if (i!=0) sb.append(", ");
sb.append(i + ":" + channels[i]);
}
return sb.toString();
}
}
/dongfang_FC_rewrite_tool/src/dongfang/mkt/RequestFrameVisitor.java
16,6 → 16,7
import dongfang.mkt.frames.ReadIMUConfigurationRequestFrame;
import dongfang.mkt.frames.ReadMotorMixerRequestFrame;
import dongfang.mkt.frames.ReadParamSetRequestFrame;
import dongfang.mkt.frames.ReadRCChannelsRequestFrame;
import dongfang.mkt.frames.ReadVariablesRequestFrame;
import dongfang.mkt.frames.ResetRequestFrame;
import dongfang.mkt.frames.SetCompassHeadingRequestFrame;
49,4 → 50,5
void visit(CompassHeadingRequestFrame f) throws IOException;
void visit(WriteMotorMixerRequestFrame f) throws IOException;
void visit(WriteIMUConfigurationRequestFrame f) throws IOException;
void visit(ReadRCChannelsRequestFrame f) throws IOException;
}
/dongfang_FC_rewrite_tool/src/dongfang/mkt/main/RCDump.java
New file
0,0 → 1,81
package dongfang.mkt.main;
 
import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Date;
 
import dongfang.mkt.comm.FrameQueue;
import dongfang.mkt.comm.MKConnection;
import dongfang.mkt.comm.serial.RXTXSerialPort;
import dongfang.mkt.frames.ReadRCChannelsRequestFrame;
import dongfang.mkt.frames.ReadRCChannelsResponseFrame;
 
public class RCDump {
private static final PrintStream STDERR = System.out;
 
interface Logger {
void start(String timestamp) throws IOException;
void log(ReadRCChannelsResponseFrame f, long timestamp) throws IOException;
void end() throws IOException;
}
 
static class ConsoleRCLogger implements Logger {
public void start(String logId) {}
 
public void log(ReadRCChannelsResponseFrame f, long timestamp) {
if (f == null) {
System.out.println("Oops, null response frame.");
return;
}
System.out.println(f);
}
 
public void end() {}
}
 
private static Logger createLogger() throws IOException {
Logger consoleLogger = new ConsoleRCLogger();
return consoleLogger;
}
 
private void rcDump(final FrameQueue q, final Logger logger) throws IOException {
long timer = 0;
ReadRCChannelsRequestFrame f = new ReadRCChannelsRequestFrame();
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
Long firsttimestamp = null;
while (!in.ready())
try {
long now = System.currentTimeMillis();
if (now - timer > 500) {
timer = now;
q.sendRequest(f);
ReadRCChannelsResponseFrame rf = (ReadRCChannelsResponseFrame) q.getResponseFor(f, 500);
long timestamp = System.currentTimeMillis();
if (firsttimestamp == null) {
firsttimestamp = timestamp;
timestamp = 0;
} else {
timestamp -= firsttimestamp;
}
logger.log(rf, timestamp);
}
} catch (IOException ex) {
STDERR.println(ex);
}
}
 
public static void main(String[] args) throws IOException {
RCDump test = new RCDump();
RXTXSerialPort _port = new RXTXSerialPort();
_port.init(null);
FrameQueue q = new FrameQueue(_port);
Logger logger = createLogger();
logger.start(new Date().toGMTString());
test.rcDump(q, logger);
logger.end();
}
}
/dongfang_FC_rewrite_tool/src/dongfang/mkt/main/IMUConfigurator.java
79,10 → 79,13
private static void readConfiguration(String portIdentifier, String fileName) throws IOException {
IMUConfiguration cs = readConfiguration(portIdentifier);
if (cs != null) {
FileWriter fw = new FileWriter(fileName);
fw.write(cs.toXML());
fw.close();
if (fileName != null) {
FileWriter fw = new FileWriter(fileName);
fw.write(cs.toXML());
fw.close();
}
}
System.out.println(cs.toXML());
}
 
private static WriteIMUConfigurationRequestFrame parseXMLIMUConfiguration(InputStream input) throws IOException {
187,12 → 190,12
public static void main(String[] args) throws IOException {
if (!"r".equals(args[0]) && !"w".equals(args[0])) help();
if ("w".equals(args[0]) && (args.length!=2)) help();
if ("r".equals(args[0]) && (args.length!=2)) help();
if ("r".equals(args[0]) && (args.length>2)) help();
 
String portIdentifier = null;
if ("r".equals(args[0])) {
readConfiguration(portIdentifier, args[1]);
readConfiguration(portIdentifier, args.length<2 ? null : args[1]);
} else {
writeConfiguration(portIdentifier, args[1]);
}
/dongfang_FC_rewrite_tool/src/dongfang/mkt/io/MKCommPort.java
1,5 → 1,6
package dongfang.mkt.io;
 
/*
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
9,3 → 10,5
InputStream getInputStream() throws IOException ;
OutputStream getOutputStream() throws IOException ;
}
 
*/
/dongfang_FC_rewrite_tool/src/dongfang/mkt/io/RXTXSerialPort.java
9,6 → 9,7
import java.io.InputStream;
import java.io.OutputStream;
 
/*
public class RXTXSerialPort implements MKCommPort {
private SerialPort serialPort;
 
60,3 → 61,4
return serialPort.getOutputStream();
}
}
*/