| 
									
										
										
										
											2014-12-11 05:50:41 +08:00
										 |  |  | /* ----------------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-11 22:39:48 +08:00
										 |  |  |  * GTSAM Copyright 2010, Georgia Tech Research Corporation, | 
					
						
							| 
									
										
										
										
											2014-12-11 05:50:41 +08:00
										 |  |  |  * Atlanta, Georgia 30332-0415 | 
					
						
							|  |  |  |  * All Rights Reserved | 
					
						
							|  |  |  |  * Authors: Frank Dellaert, et al. (see THANKS for the full author list) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * See LICENSE for the license information | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * -------------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  *  @file  TOAFactor.h | 
					
						
							|  |  |  |  *  @brief "Time of Arrival" factor | 
					
						
							|  |  |  |  *  @author Frank Dellaert | 
					
						
							|  |  |  |  *  @author Jay Chakravarty | 
					
						
							|  |  |  |  *  @date December 2014 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-18 02:34:11 +08:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 10:01:14 +08:00
										 |  |  | #include <gtsam/nonlinear/ExpressionFactor.h>
 | 
					
						
							| 
									
										
										
										
											2014-12-11 05:50:41 +08:00
										 |  |  | #include <gtsam_unstable/geometry/Event.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace gtsam { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /// A "Time of Arrival" factor - so little code seems hardly worth it :-)
 | 
					
						
							| 
									
										
										
										
											2020-03-18 02:34:11 +08:00
										 |  |  | class TOAFactor : public ExpressionFactor<double> { | 
					
						
							| 
									
										
										
										
											2016-04-11 10:01:14 +08:00
										 |  |  |   typedef Expression<double> Double_; | 
					
						
							| 
									
										
										
										
											2014-12-11 05:50:41 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-18 02:34:11 +08:00
										 |  |  |  public: | 
					
						
							| 
									
										
										
										
											2014-12-11 05:50:41 +08:00
										 |  |  |   /**
 | 
					
						
							| 
									
										
										
										
											2020-03-19 03:44:33 +08:00
										 |  |  |    * Most general constructor with two expressions | 
					
						
							| 
									
										
										
										
											2020-03-18 02:34:11 +08:00
										 |  |  |    * @param eventExpression expression yielding an event | 
					
						
							|  |  |  |    * @param sensorExpression expression yielding a sensor location | 
					
						
							|  |  |  |    * @param toaMeasurement time of arrival at sensor | 
					
						
							| 
									
										
										
										
											2014-12-11 05:50:41 +08:00
										 |  |  |    * @param model noise model | 
					
						
							| 
									
										
										
										
											2020-03-19 03:44:33 +08:00
										 |  |  |    * @param speed optional speed of signal, in m/sec | 
					
						
							| 
									
										
										
										
											2014-12-11 05:50:41 +08:00
										 |  |  |    */ | 
					
						
							|  |  |  |   TOAFactor(const Expression<Event>& eventExpression, | 
					
						
							| 
									
										
										
										
											2020-03-18 02:34:11 +08:00
										 |  |  |             const Expression<Point3>& sensorExpression, double toaMeasurement, | 
					
						
							| 
									
										
										
										
											2020-03-19 03:44:33 +08:00
										 |  |  |             const SharedNoiseModel& model, double speed = 330) | 
					
						
							| 
									
										
										
										
											2020-03-18 02:34:11 +08:00
										 |  |  |       : ExpressionFactor<double>( | 
					
						
							|  |  |  |             model, toaMeasurement, | 
					
						
							| 
									
										
										
										
											2020-03-19 03:44:33 +08:00
										 |  |  |             Double_(TimeOfArrival(speed), eventExpression, sensorExpression)) {} | 
					
						
							| 
									
										
										
										
											2014-12-11 05:50:41 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-18 02:34:11 +08:00
										 |  |  |   /**
 | 
					
						
							|  |  |  |    * Constructor with fixed sensor | 
					
						
							|  |  |  |    * @param eventExpression expression yielding an event | 
					
						
							|  |  |  |    * @param sensor a known sensor location | 
					
						
							|  |  |  |    * @param toaMeasurement time of arrival at sensor | 
					
						
							|  |  |  |    * @param model noise model | 
					
						
							|  |  |  |    * @param toa optional time of arrival functor | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   TOAFactor(const Expression<Event>& eventExpression, const Point3& sensor, | 
					
						
							|  |  |  |             double toaMeasurement, const SharedNoiseModel& model, | 
					
						
							| 
									
										
										
										
											2020-03-19 03:44:33 +08:00
										 |  |  |             double speed = 330) | 
					
						
							| 
									
										
										
										
											2020-03-18 02:34:11 +08:00
										 |  |  |       : TOAFactor(eventExpression, Expression<Point3>(sensor), toaMeasurement, | 
					
						
							| 
									
										
										
										
											2020-03-19 03:44:33 +08:00
										 |  |  |                   model, speed) {} | 
					
						
							| 
									
										
										
										
											2020-03-19 05:28:40 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   static void InsertEvent(Key key, const Event& event, | 
					
						
							| 
									
										
										
										
											2023-01-18 06:05:12 +08:00
										 |  |  |                           std::shared_ptr<Values> values) { | 
					
						
							| 
									
										
										
										
											2020-03-19 05:28:40 +08:00
										 |  |  |     values->insert(key, event); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2014-12-11 05:50:41 +08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-18 02:34:11 +08:00
										 |  |  | }  // namespace gtsam
 |