James Goppert's Posts (25)

Sort by
Developer

QGroundControl Integration for ArduPilotMega

I've just about wrapped up QGroundControl Integration for the ArduPilotMega. The code currently implements the majority of the common protocol for QGroundControl. You can successfully read raw sensor gps/imu/gyro data, read radio packets, check the system status, check the system heartbeat, get/set pid gains and other control parameters (note they have yet to replace the current values for the controllers). Tomorrow I hope to have waypoint send/receive complete and to do a ground test with an RC car and a flight test if that is successful. Thanks PixHawk team for making a great ground station!
Read more…
Developer
The ardupilotmegacomm library is successfully sending/ receiving HIL communication and is sending/receiving the standard ardupilotmega binary protocol. yagcs and dronegcs (several ardupilotmega ground stations) both currently use the library. I updated the apmcomm library to fix some bugs and also added hardware in the loop support. I renamed the project from apmcomm to avoid a bunch of misc. hits on google. I have packaged a linux version using cpack -G DEB, but could use a developer on windows to package the windows version with the nullsoft installer. If you have boost >= 1.40 and cmake >= 2.60 it should only require you to checkout the repository and run cpack -G NSIS
Here is the svn repository checkout line: svn checkout http://ardupilotmegacomm.googlecode.com/svn/trunk/ ardupilotmegacomm-read-only

I have written a semi-detailed wiki page on how to get going with the library. I've included short demos on how to test out the HIL and binary protocol communications with the included test programs. Here is the link to the project on google code: http://code.google.com/p/ardupilotmegacomm/

To fix some upstream problems in the Arducotper APM_BinComm library that haven't been accepted yet, I built a patch system into the CMakeLists.txt file. First svn pulls APM_BinComm from arducopter. Then CMake notices that there is no patch stamp and applies the patch to the APM_BinComm tree. Then the build system creates the patch stamp so no errors are produced during successive builds.

Read more…
Developer
I spent today figuring out how to piece together an interface to the APM_BinComm library for talking back and forth to a ground station. My idea was to wrap a serial class around the Stream interface for the arduino. By doing this there is no need to recode the APM_BinComm library. Just compile against it and go. This should make our lives easier trying to interface with the protocol for ground control software. Hopefully if all goes well I can get this added into the Arducopter svn for APM_BinComm. If not, I'll keep it maintained on my git site: http://hsl.dynalias.com/git/?p=apmcomm;a=summary

Here is a zip of the library:

Here is the main code:

#include "AsyncSerial.hpp"
#include "strlcpy.h"
#include <boost/date_time/posix_time/posix_time.hpp>
#include <iostream>

using namespace boost::posix_time;
ptime start = microsec_clock::universal_time();

class Stream
{
public:
Stream(BufferedAsyncSerial * serial) : _serial(serial)
{
}
uint8_t read() {
_serial->read(&data,1);
//std::cout << "avail: " << available() << std::endl;
return data;
}
void write(char c)
{
_serial->write(&c,1);
}
int available() {
return _serial->available();
}
private:
BufferedAsyncSerial * _serial;
char data;
};


long int millis()
{
time_duration diff = microsec_clock::universal_time() - start;
long int elapsed = diff.total_milliseconds();
return elapsed;
}

And now here is what you can do with it!



What is great about the APM_BinComm library is this is how you add a new message definiton

Add the new message:
#
# System heartbeat
#
message 0x01 MSG_HEARTBEAT
uint8_t flightMode
uint16_t timeStamp
uint16_t batteryVoltage
uint16_t commandIndex

And then process it:
awk -f protogen.awk protocol.def > protocol.h

Thanks go out to Michael Smith for this one.
Nice job!

Here is the code for the above program.

#include "AsyncSerial.hpp"
#include "APM_BinComm/APM_BinComm.h"
#include <iostream>
#include <boost/bind.hpp>

These call back functions make life so much easier.

void h_attitude(void * arg, uint8_t messageId, uint8_t messageVersion, void * messageData)
{
int16_t roll=0,pitch=0,yaw=0;
BinComm * comm = (BinComm*)arg;
comm->unpack_msg_attitude(roll,pitch,yaw);
std::cout << "roll, pitch, yaw:\t" << roll << "\t" << pitch << "\t" << yaw << std::endl;
}

void h_location(void * arg, uint8_t messageId, uint8_t messageVersion, void * messageData)
{
BinComm * comm = (BinComm*)arg;
int32_t latitude = 0, longitude = 0;
int16_t altitude = 0, groundSpeed = 0, groundCourse = 0;
uint16_t timeOfWeek = 0;
comm->unpack_msg_location(latitude,longitude,altitude,groundSpeed,groundCourse,timeOfWeek);
std::cout << "latitude, longitude, altitude:\t" << latitude << "\t"
<< longitude << "\t" << altitude << std::endl;
std::cout << "ground speed, ground course, time of week:\t" << groundSpeed << "\t"
<< groundCourse << "\t" << timeOfWeek << std::endl;
}

class CommTest
{
private:
BufferedAsyncSerial serial;
BinComm::MessageHandler handlerTable[10];
Stream stream;
BinComm comm;

public:
CommTest(const std::string & device, long int baud) :
serial(device,baud),
stream(&serial),
comm(handlerTable,&stream)
{
int i=0;

handlerTable[i].messageID = BinComm::MSG_ATTITUDE;
handlerTable[i].handler = h_attitude;
handlerTable[i].arg = &comm;
i++;

handlerTable[i].messageID = BinComm::MSG_LOCATION;
handlerTable[i].handler = h_location;
handlerTable[i].arg = &comm;
i++;

// signals end of handle table
handlerTable[i].messageID = BinComm::MSG_NULL;
}
void update()
{
comm.update();
}
};

int main (int argc, char const* argv[])
{
if (argc != 3)
{
std::cout << "usage: " << argv[0] << " device baud" << std::endl;
return 0;
}
std::string device = argv[1];
long int baud = atol(argv[2]);
std::cout << "device: " << device << std::endl;
std::cout << "baud: " << baud << std::endl;
CommTest test(device,baud);
while(1)
{
test.update();
usleep(1000);
}
return 0;
}



Read more…
Developer


This ardupilotmega hardware in the loop block for scicoslab marks the completion of an open source, completely free autopilot design and testing tool chain. The jsbsimcomm block communicates with the ardupilotmega hil block to simulate an actual flight. Servos move in response to the autopilot and may also be manually controlled with the radio receiver. This isn't polished yet, but it's working and I'll be cleaning it up this week. I've used the boost asio library for serial communication so the scicoslab blocks should also compile on windows if your lucky. Will probably take some work if anyone wants to volunteer. :-). Source code is on http://hsl.dynalias.com/git/?p=JSBSim;a=summary
Read more…