test_primitives.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002  * \file
00003  *
00004  * $Id: test_primitives.cpp 828 2012-05-23 15:38:00Z spanel $
00005  *
00006  * Copyright (C) Brno University of Technology
00007  *
00008  * This file is part of software developed by Robo@FIT group.
00009  *
00010  * Author: Tomas Lokaj (xlokaj03@stud.fit.vutbr.cz)
00011  * Supervised by: Michal Spanel (spanel@fit.vutbr.cz)
00012  * Date: 05/12/2011
00013  * 
00014  * This file is free software: you can redistribute it and/or modify
00015  * it under the terms of the GNU Lesser General Public License as published by
00016  * the Free Software Foundation, either version 3 of the License, or
00017  * (at your option) any later version.
00018  * 
00019  * This file is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  * GNU Lesser General Public License for more details.
00023  * 
00024  * You should have received a copy of the GNU Lesser General Public License
00025  * along with this file.  If not, see <http://www.gnu.org/licenses/>.
00026  */
00027 
00028 #include <srs_interaction_primitives/bounding_box.h>
00029 #include <srs_interaction_primitives/billboard.h>
00030 #include <srs_interaction_primitives/plane.h>
00031 #include <srs_interaction_primitives/plane_polygon.h>
00032 #include <srs_interaction_primitives/unknown_object.h>
00033 #include <srs_interaction_primitives/object.h>
00034 #include <srs_interaction_primitives/PoseType.h>
00035 
00036 #include <geometry_msgs/Point32.h>
00037 #include "math.h"
00038 
00039 using namespace srs_interaction_primitives;
00040 using namespace std_msgs;
00041 using namespace visualization_msgs;
00042 using namespace geometry_msgs;
00043 using namespace interactive_markers;
00044 
00051 int main(int argc, char** argv)
00052 {
00053   ros::init(argc, argv, "test_primitives");
00054 
00055   InteractiveMarkerServerPtr server;
00056   server.reset(new InteractiveMarkerServer("test_primitives", "", false));
00057 
00058   UnknownObject * unknowObject = new UnknownObject(server, "/world", "unknown_object_srs");
00059   unknowObject->setFrameID("/world");
00060   Pose pp;
00061   pp.position.x = 0;
00062   pp.position.y = 0;
00063   pp.position.z = 0.5;
00064   pp.orientation.x = 0.5;
00065   pp.orientation.w = 0.2;
00066   pp.orientation.y = 1.3;
00067   unknowObject->setPose(pp);
00068   Vector3 ss;
00069   ss.x = 1;
00070   ss.y = 1;
00071   ss.z = 1;
00072   unknowObject->setScale(ss);
00073   unknowObject->setDescription("Unknown object - SRS");
00074   unknowObject->insert();
00075 
00076   UnknownObject * unknowObject2 = new UnknownObject(server, "/world", "unknown_object_ipa");
00077   unknowObject2->setFrameID("/world");
00078   unknowObject2->setPoseType(srs_interaction_primitives::PoseType::POSE_BASE);
00079   pp.position.x = 0;
00080   pp.position.y = 0;
00081   pp.position.z = 0;
00082   unknowObject2->setPose(pp);
00083   ss.x = 1;
00084   ss.y = 1;
00085   ss.z = 1;
00086   unknowObject2->setScale(ss);
00087   unknowObject2->setDescription("Unknown object - IPA");
00088   unknowObject2->insert();
00089 
00090   /*
00091    ColorRGBA c;
00092 
00093    c.a = 0.2;
00094    c.r = 1.0;
00095    c.g = 0.0;
00096    c.b = 0.0;
00097    Pose p;
00098    p.position.x = 5;
00099    p.position.y = 2;
00100    p.position.z = 1;
00101    p.orientation.x = M_PI_4;
00102    p.orientation.y = 0;
00103    p.orientation.z = M_PI_4;
00104    Vector3 s;
00105    s.x = 1.0;
00106    s.y = 1.0;
00107    s.z = 1.0;
00108 
00109    // Object
00110    Billboard *chairBillboard = new Billboard(server, "/world", "person");
00111    chairBillboard->setType(srs_interaction_primitives::BillboardType::CHAIR);
00112    chairBillboard->setPose(p);
00113    chairBillboard->setScale(s);
00114    chairBillboard->setFrameID("/world");
00115    chairBillboard->insert();
00116    // Bounding box
00117    BoundingBox * chairBoundingBox = new BoundingBox(server, "/world", chairBillboard->getName() + "_bbox");
00118    chairBoundingBox->setAttachedObjectName(chairBillboard->getName());
00119    chairBoundingBox->setPose(p);
00120    chairBoundingBox->setScale(s);
00121    chairBoundingBox->setColor(c);
00122    chairBoundingBox->setDescription("Person bounding box");
00123    chairBoundingBox->insert();
00124 
00125    p.position.x = 1;
00126    p.position.y = 2;
00127    p.position.z = 2;
00128    s.x = 1;
00129    s.y = 1;
00130    s.z = 1;
00131    // Object
00132    Billboard *milkBillboard = new Billboard(server, "/world", "milk_billboard");
00133    Quaternion direction;
00134    direction.x = 2.0;
00135    direction.y = 1.0;
00136    direction.z = 3.0;
00137    direction.w = 1.0;
00138    milkBillboard->setType(srs_interaction_primitives::BillboardType::MILK);
00139    milkBillboard->setPose(p);
00140    milkBillboard->setScale(s);
00141    milkBillboard->setDirection(direction);
00142    milkBillboard->setVelocity(3.4);
00143    milkBillboard->setDescription("MLEEEEKO");
00144    milkBillboard->insert();
00145 
00146    UnknownObject * unknowObject = new UnknownObject(server, "/world", "unknown_object");
00147    unknowObject->setFrameID("/world");
00148    Pose pp;
00149    pp.position.x = 0;
00150    pp.position.y = 0;
00151    pp.position.z = 0;
00152    unknowObject->setPose(pp);
00153    Vector3 ss;
00154    ss.x = 1;
00155    ss.y = 1;
00156    ss.z = 1;
00157    unknowObject->setScale(ss);
00158    unknowObject->setDescription("Uknown object");
00159    unknowObject->insert();
00160 
00161    Plane *plane = new Plane(server, "/world", "plane1");
00162    c.a = 1.0;
00163    p.position.x = 0;
00164    p.position.y = 0;
00165    p.position.z = 0;
00166    s.x = 5;
00167    s.y = 2;
00168    plane->setColor(c);
00169    plane->setFrameID("/world");
00170    plane->setPose(p);
00171    plane->setScale(s);
00172    plane->insert();
00173    c.g = 1.0;
00174    plane->changeColor(c);
00175 
00176    PlanePolygon *planePolygon = new PlanePolygon(server, "/world", "plane_polygon");
00177    Polygon pol;
00178    geometry_msgs::Point32 point;
00179    c.r = 1;
00180    c.g = 0;
00181    c.b = 0;
00182    c.a = 1.0;
00183 
00184    point.x = 0.99171;
00185    point.y = 0.93265;
00186    point.z = -0.16251;
00187    pol.points.push_back(point);
00188    point.x = 0.47751;
00189    point.y = -0.93946;
00190    point.z = -0.64291;
00191    pol.points.push_back(point);
00192    point.x = -1.28507;
00193    point.y = -0.68923;
00194    point.z = 0.26852;
00195    pol.points.push_back(point);
00196    point.x = -0.77087;
00197    point.y = 1.18289;
00198    point.z = 0.74892;
00199    pol.points.push_back(point);
00200    planePolygon->setPolygon(pol);
00201 
00202    Vector3 normal;
00203    normal.x = 0.39652;
00204    normal.y = -0.32885;
00205    normal.z = 0.85710;
00206    //planePolygon->setNormal(normal);
00207 
00208 
00209    point.x = 0.22078;
00210    point.y = 0.86032;
00211    point.z = -0.40858;
00212    pol.points.push_back(point);
00213    point.x = 0.95152;
00214    point.y = -1.00344;
00215    point.z = 0.31976;
00216    pol.points.push_back(point);
00217    point.x = -0.92901;
00218    point.y = 0.18325;
00219    point.z = 0.50957;
00220    pol.points.push_back(point);
00221    point.x = -0.97683;
00222    point.y = 1.84874;
00223    point.z = -0.42075;
00224    pol.points.push_back(point);
00225    planePolygon->setPolygon(pol);
00226 
00227    normal.x = 0.37210;
00228    normal.y = 0.46077;
00229    normal.z = 0.80575;
00230    planePolygon->setNormal(normal);
00231 
00232    planePolygon->setColor(c);
00233    planePolygon->insert();
00234 
00235    //Object
00236    s.x = 6;
00237    s.y = 3.2;
00238    s.z = 4;
00239    InteractiveMarker object;
00240    Marker sphere;
00241    sphere.type = Marker::SPHERE;
00242    sphere.color.r = c.g;
00243    sphere.color.g = c.r;
00244    sphere.color.b = c.b;
00245    sphere.color.a = c.a;
00246    sphere.scale = s;
00247    object.header.frame_id = "/world";
00248    object.name = "sphere";
00249    object.description = "Sphere";
00250    p.position.x = 20;
00251    object.pose = p;
00252    InteractiveMarkerControl control;
00253    control.name = "sphere_control";
00254    control.interaction_mode = InteractiveMarkerControl::NONE;
00255    control.always_visible = true;
00256    control.markers.push_back(sphere);
00257    object.controls.push_back(control);
00258    server->insert(object);
00259    // Bounding box
00260    c.r = 1;
00261    c.g = 0;
00262    c.b = 0;
00263    BoundingBox * sphereBoundingBox = new BoundingBox(server, "/world", "sphere_bbox");
00264    sphereBoundingBox->setAttachedObjectName("sphere");
00265    sphereBoundingBox->setPose(p);
00266    sphereBoundingBox->setScale(s);
00267    sphereBoundingBox->setColor(c);
00268    sphereBoundingBox->setDescription("Sphere bounding box");
00269    sphereBoundingBox->insert();
00270 
00271    Object * obj = new Object(server, "/world", "table_object");
00272    obj->setFrameID("/world");
00273    Pose ppp;
00274    ppp.position.x = 6;
00275    ppp.position.y = 5;
00276    ppp.position.z = 0;
00277    obj->setPose(ppp);
00278    Vector3 sss;
00279    sss.x = 1;
00280    sss.y = 1;
00281    sss.z = 1;
00282    c.a = 1.0;
00283    obj->setScale(sss);
00284    obj->setDescription("Table");
00285    obj->setColor(c);
00286    obj->setResource("package://gazebo_worlds/Media/models/table.dae");
00287    obj->setUseMaterial(false);
00288    obj->insert();
00289 
00290    ObjectWithBoundingBox * objbb = new ObjectWithBoundingBox(server, "/world", "table_with_bb");
00291    ppp.position.x = 2;
00292    ppp.position.y = 2;
00293    ppp.position.z = 2;
00294    objbb->setPose(ppp);
00295    c.a = 1.0;
00296    Vector3 gp;
00297    gp.x = 0.7;
00298    gp.y = 1.2;
00299    gp.z = 0;
00300    objbb->setGraspingPosition(GRASP_1, gp);
00301    gp.x = 0;
00302    gp.y = 1.2;
00303    gp.z = 0.9;
00304    objbb->setGraspingPosition(GRASP_2, gp);
00305    gp.x = 0.1;
00306    gp.y = 0.1;
00307    gp.z = 0.1;
00308    objbb->setGraspingPosition(GRASP_3, gp);
00309    Scale sbb;
00310    sbb.x = 0.2;
00311    sbb.y = 0.2;
00312    sbb.z = 0.2;
00313    Point bbm;
00314    bbm = Point();
00315    bbm.x = 1;
00316    bbm.y = 1;
00317    bbm.z = 1;
00318    objbb->setBoundingBoxLWH(bbm);
00319    objbb->setDescription("Table with Bounding Box");
00320    objbb->setColor(c);
00321    objbb->setResource("package://gazebo_worlds/Media/models/table.dae");
00322    objbb->setUseMaterial(true);
00323 
00324    arm_navigation_msgs::Shape shape;
00325    Point sp;
00326    sp.x = 0;
00327    sp.y = 0;
00328    sp.z = 0;
00329    shape.vertices.push_back(sp);
00330    sp.x = 1;
00331    shape.vertices.push_back(sp);
00332    sp.y = 2;
00333    shape.vertices.push_back(sp);
00334    shape.triangles.push_back(0);
00335    shape.triangles.push_back(1);
00336    shape.triangles.push_back(2);
00337    objbb->setShape(shape);
00338 
00339    objbb->insert();*/
00340 
00341   server->applyChanges();
00342   ros::spin();
00343 }
00344 


srs_interaction_primitives
Author(s): Tomas Lokaj, Michal Spanel (spanel@fit.vutbr.cz)
autogenerated on Mon Oct 6 2014 07:55:11