27 #include "tracker_impl.h" 30 #define DOUBLE_VECTOR_LENGTH 6 32 #define NOTE_KEY_1 "X" 33 #define NOTE_KEY_2 "Y" 34 #define NOTE_KEY_3 "Z" 35 #define NOTE_KEY_4 "RX" 36 #define NOTE_KEY_5 "RY" 37 #define NOTE_KEY_6 "RZ" 40 typedef boost::array< ::geometry_msgs::Point_<std::allocator<void> > , 8>
BoundingBox;
44 threadRunning =
false;
46 generalPublisher = node.advertise<asr_msgs::AsrObject>(
"fob_objects", 1000);
60 printf(
"static WorkerThread method called!\n");
63 printf(
"Worker thread exit.\n");
70 #define PAUSE_SET 30000 71 #define PAUSE_WRITE 30000 75 return vAcc[0][index];
77 std::vector<double>
data;
78 for (
unsigned int i=0; i<
MAX_SETS; i++)
79 data.push_back(vAcc[i][index]);
80 std::sort(data.begin(), data.end());
82 if (MAX_SETS % 2 == 0)
83 return ((data[MAX_SETS / 2 - 1] + data[MAX_SETS / 2]) / 2);
85 return data[(MAX_SETS - 1) / 2];
98 for (
unsigned int i=0; i<
MAX_SETS; i++)
107 for (
unsigned int i=0; i<6; i++)
117 printf(
"Couldn't write Notification to NotificationManager. Error!\n");
134 printf(
"Starting myBird\n");
143 printf(
"Thread started, but was already running.\n");
144 printf(
"Thread running.\n");
149 printf(
"Stopping myBird\n");
167 int fcountLeft, fcountRight;
168 fulcrum fulcrumarrayLeft[255], fulcrumarrayRight[255];
170 res = ((f=fopen(srcFileName,
"r"))!=NULL);
171 std::size_t readSize = 0;
174 readSize = fread(&fcountLeft,
sizeof(fcountLeft),1,f);
175 readSize = fread(&fcountRight,
sizeof(fcountRight),1,f);
178 printf(
"loadCalibFile %s\n",srcFileName);
179 printf(
"fcountLeft:%i, fcountRight:%i\n",fcountLeft,fcountRight);
181 readSize = fread(&fulcrumarrayLeft,
sizeof(fulcrumarrayLeft[0]),fcountLeft,f);
182 readSize = fread(&fulcrumarrayRight,
sizeof(fulcrumarrayRight[0]),fcountRight,f);
185 printf(
"fulcrumyArrayLeft(%i):\n",fcountLeft);
186 for(
int i=0;i < fcountLeft;i++) {
187 printf(
"\nentry %i:\n",i);
190 printf(
"fulcrumyArrayRight(%i):\n",fcountRight);
191 for(
int i=0;i < fcountRight;i++) {
192 printf(
"\nentry %i:\n",i);
197 s <<
"Loaded " << (fcountLeft+fcountRight) <<
" fulcrums\n";
201 printf(
"error loading calibration data: 2%s:%u\n",__FILE__,__LINE__);
207 printf(
"loading Calibration into rightTracker\n");
211 printf(
"loading Calibration into leftTracker\n");
215 printf(
"Success! Calibration data loaded\n");
217 printf(
"error loading calibration data: %s:%u\n",__FILE__,__LINE__);
224 printf(
"sensorVal: %3.3f, %3.3f, %3.3f\n",fulc.sensorVal[0] ,fulc.sensorVal[1], fulc.sensorVal[2]);
225 printf(
"sensorAngle: %3.3f, %3.3f, %3.3f\n",fulc.sensorAngle[0] ,fulc.sensorAngle[1], fulc.sensorAngle[2]);
226 printf(
"worldVal: %3.3f, %3.3f, %3.3f\n",fulc.worldVal[0] ,fulc.worldVal[1], fulc.worldVal[2]);
227 printf(
"worldAngle: %3.3f, %3.3f, %3.3f\n",fulc.worldAngle[0] ,fulc.worldAngle[1], fulc.worldAngle[2]);
233 double world[6],sensor[6];
235 for (
unsigned int i=0; i < length; i++)
237 for (
int j=0;j<3;j++)
239 sensor[j]=cal[i].sensorVal[j];
240 sensor[j+3]=cal[i].sensorAngle[j];
241 world[j]=cal[i].worldVal[j];
242 world[j+3]=cal[i].worldAngle[j];
253 object.header.frame_id =
"";
254 object.header.seq =
seqId;
258 object.providedBy =
"asr_flock_of_birds";
262 geometry_msgs::Pose help_pose;
263 help_pose.position.x = data[0] / 1000.0;
264 help_pose.position.y = data[1] / 1000.0;
265 help_pose.position.z = data[2] / 1000.0;
268 help_pose.orientation.x = orientation.x();
269 help_pose.orientation.y = orientation.y();
270 help_pose.orientation.z = orientation.z();
271 help_pose.orientation.w = orientation.w();
273 geometry_msgs::PoseWithCovariance help_pose_with_c;
274 help_pose_with_c.pose = help_pose;
275 if (
object.sampledPoses.size() > 0)
277 object.sampledPoses.pop_back();
279 object.sampledPoses.push_back(help_pose_with_c);
282 for (
unsigned int i=0; i<8; i++)
283 object.boundingBox[i] = help_pose.position;
284 object.sizeConfidence = 1.0;
287 object.type =
"tracker";
288 object.typeConfidence = 1.0;
290 object.identifier = name;
292 object.meshResourcePath =
"";
309 std::string name =
id ==
leftTracker ?
"tracker_left" :
"tracker_right";
312 printf(
"%s_raw %3.3f %3.3f %3.3f %3.3f° %3.3f° %3.3f° ", name.c_str(),
313 raw[0], raw[1], raw[2], raw[3], raw[4], raw[5]);
315 printf(
"%s %3.3f %3.3f %3.3f %3.3f° %3.3f° %3.3f° ", name.c_str(),
316 calibrated[0], calibrated[1], calibrated[2], calibrated[3], calibrated[4], calibrated[5]);
321 asr_msgs::AsrObject object;
347 #if tracker_impl_test 348 int main(
int argc,
char **argv)
350 bgcorba::init(argc, argv);
static tf::Quaternion createQuaternionFromRPY(double roll, double pitch, double yaw)
void getPbdObject(std::string name, double *data, asr_msgs::AsrObject &object)
void publish(const boost::shared_ptr< M > &message) const
int main(int argc, char **argv)
bool threadRunning
flag switching on/off thread
double getMedian(double(&vAcc)[MAX_SETS][6], unsigned int index)
void getTransform(double *data, tf::Transform &transform)
void workerThread()
this method is called by static method s_workerthread
static void * s_workerThread(void *arg)
Thread is bound to this method.
bool loadCalibration(const fulcrum cal[255], unsigned int length)
tf::TransformBroadcaster transformPublisher
bool loadCalibFile(const char *srcFileName)
tracker_impl(trackerID t, BirdTrack_impl *b, std::string trackerName)
void printFulcrum(fulcrum fulc)
pthread_t workerThreadHandle
Thread for delivering tracker data to nCenter.
bool writeNotification(trackerID id, double *raw, double *calibrated)
boost::array< ::geometry_msgs::Point_< std::allocator< void > >, 8 > BoundingBox
int get_posangles(int whichtracker, double *v)
ros::Publisher generalPublisher
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
transformCoords * myTransformer