KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
psi_model.h
Go to the documentation of this file.
1 /* $Id: psi_model.h 12743 2012-07-25 23:52:02Z jguan1 $ */
2 /* {{{=========================================================================== *
3  |
4  | Copyright (c) 1994-2011 by Kobus Barnard (author)
5  |
6  | Personal and educational use of this code is granted, provided that this
7  | header is kept intact, and that the authorship is not misrepresented, that
8  | its use is acknowledged in publications, and relevant papers are cited.
9  |
10  | For other use contact the author (kobus AT cs DOT arizona DOT edu).
11  |
12  | Please note that the code in this file has not necessarily been adequately
13  | tested. Naturally, there is no guarantee of performance, support, or fitness
14  | for any particular task. Nonetheless, I am interested in hearing about
15  | problems that you encounter.
16  |
17  | Author: Kyle Simek
18  * =========================================================================== }}}*/
19 
20 // vim: tabstop=4 shiftwidth=4 foldmethod=marker
21 
22 #ifndef PSI_VERSION_1_MODEL_H
23 #define PSI_VERSION_1_MODEL_H
24 
25 #include <l_cpp/l_exception.h>
26 #include <m_cpp/m_vector.h>
27 
28 #include <boost/shared_ptr.hpp>
29 #include <boost/bimap.hpp>
30 #include <boost/bimap/list_of.hpp>
31 #include <boost/assign.hpp>
32 #include <vector>
33 #include <typeinfo>
34 
35 #include <psi_cpp/psi_action.h>
39 
40 #ifdef KJB_HAVE_UA_CARTWHEEL
41 #include <Control/SimulationInterface.h>
42 #include <Control/ExtendedAction.h>
43 #include <Control/WrapperAction.h>
44 #include <Control/StartState.h>
45 #include <Control/BoxState.h>
46 #endif
47 
48 
49 namespace kjb
50 {
51 namespace psi
52 {
53 
54 
55 #ifdef KJB_HAVE_UA_CARTWHEEL
56 typedef boost::shared_ptr<CartWheel::ExtendedAction> Ex_action_ptr;
57 
58 // this probably doesn't belong in model.h...
59 typedef boost::shared_ptr<CartWheel::SimulationInterface> InterfacePtr;
60 #endif
61 
62 struct Model
63 {
64  Model() :
67  { }
68 
69  std::vector<std::vector<Start_state> > start_state;
70  std::vector<std::vector<std::vector<Action> > > entities_actions;
71 
72  size_t size() const;
73 
74  double get(size_t dimension) const;
75 
76  void set(size_t dimension, double value);
77 
78  Unit_type get_units(size_t dimension) const;
79 
80 
81 // std::vector<std::vector<int> > correspondences;
82 };
83 
84 
85 #ifdef KJB_HAVE_UA_CARTWHEEL
86 // extract start state in a format compatible with
87 // the Cartwheel SimulationInterface class.
88 std::vector<CartWheel::StartStatePtr> to_cw_start_state(const Model& m);
89 
90 // extract box list in a format compatible with
91 // the Cartwheel SimulationInterface class.
92 //std::vector<CartWheel::BoxStatePtr> to_cw_boxes(const Model& m);
93 
94 // extract action list in a format compatible with
95 // the Cartwheel SimulationInterface class.
96 std::vector<std::vector<CartWheel::ExtendedActionPtr> > to_cw_actions(const Model& m);
97 #endif
98 
99 const std::vector<std::vector<Start_state> >& to_start_state(const Model& m);
100 const std::vector<Weighted_box> to_boxes(const Model& m);
101 const std::vector<std::vector<std::vector<Action> > >& to_actions(const Model& m);
102 
103 std::ostream& operator<<(std::ostream& ost, const Model& m);
104 std::istream& operator>>(std::istream& ist, Model& m);
109 double model_prior (const Model& m);
110 
111 //class Frustum_prior
112 //{
113 //public:
114 // Frustum_prior(const kjb::Perspective_camera& cam, double width, double height)
115 // {
116 // // find out horizon line
117 // kjb::Matrix M = build_camera_matrix();
118 //
119 // // get three vanishing points
120 // kjb::Vector p1 = M * kjb::Vector(1, 0, 0, 0);
121 // kjb::Vector p2 = M * kjb::Vector(0, 0, 1, 0);
122 // kjb::Vector p3 = M * kjb::Vector(1, 0, 1, 0);
123 //
124 // // pick the two most numerically stable points
125 //
126 // // order by decreasing 'w' parameter
127 // if(p1[1] < p2[1])
128 // swap(p1, p2);
129 // if(p2[1] < p3[2])
130 // swap(p2, p3);
131 //
132 // // only use two points with highest 'w' parameter
133 // // (hopefully the most numerically stable)
134 //
135 // kjb::Vector dir = (p2 - p1);
136 // dir.normalize();
137 //
138 // // find intersection with left side of screen
139 // double t_left = (-width/2 - p1[0]) / dir[0];
140 // kjb::Vector left_horizon = p1 + t_left * dir;
141 // // find intersection with right side of screen
142 // double t_right = (width/2 - p1[0]) / dir[0];
143 // kjb::Vector right_horizon = p1 + t_right * dir;
144 //
145 // // TODO: Plot these points to test it
146 //
147 // // convert 2d points to 3d direction vector
148 //
149 //
150 // // find bounding area on ground plane
151 // // intersect view vector with bottom-left and bottom-right of screen
152 // kjb::Vector view_bottom_left
153 //
154 //
155 //
156 //
157 //
158 // }
159 //};
160 
161 } // namespace psi
162 } // namespace kjb
163 #endif
Model()
Definition: psi_model.h:64
const std::vector< Weighted_box > to_boxes(const Model &m)
std::ostream & operator<<(std::ostream &ost, const Action &action)
serialize an action
Definition: psi_action.cpp:333
std::istream & operator>>(std::istream &ist, Action &action)
unserialize an action
Definition: psi_action.cpp:346
Unit_type
Definition: psi_units.h:30
const std::vector< std::vector< std::vector< Action > > > & to_actions(const Model &m)
Construct cartwheel actions from.
Definition: psi_model.cpp:693
Unit_type get_units(size_t dimension) const
Definition: psi_model.cpp:80
size_t size() const
Definition: psi_model.cpp:211
std::vector< std::vector< std::vector< Action > > > entities_actions
Definition: psi_model.h:70
void set(size_t dimension, double value)
Definition: psi_model.cpp:165
double model_prior(const Model &m)
Definition: psi_model.cpp:699
std::vector< std::vector< Start_state > > start_state
Definition: psi_model.h:69
Definition: tracking_entity.h:43
const std::vector< std::vector< Start_state > > & to_start_state(const Model &m)
Definition: psi_model.cpp:610
for m
Definition: APPgetLargeConnectedEdges.m:64
Support for error handling exception classes in libKJB.
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...
Definition: psi_model.h:62