23 #include "openrave_thread.h" 25 #include "environment.h" 27 #include "manipulator.h" 29 #include <openrave-core.h> 30 #include <core/exceptions/software.h> 45 :
Thread(
"OpenRaveThread",
Thread::OPMODE_WAITFORWAKEUP),
48 __or_aspectIniFin( this ),
66 OpenRAVE::RaveInitialize(
true);
67 }
catch(
const OpenRAVE::openrave_exception &e) {
74 __OR_env->enable_debug();
76 __OR_env->set_name(
"viewer");
107 manip = robot->get_manipulator();
109 env->load_IK_solver(robot);
161 robot->set_manipulator(manip);
163 {robot->calibrate(trans_x, trans_y, trans_z);}
165 {robot->set_offset(trans_x, trans_y, trans_z);}
180 set_manipulator(__OR_robot, manip, trans_x, trans_y, trans_z, calibrate);
188 __OR_env->start_viewer();
198 __OR_env->run_planner(robot, sampling);
217 __OR_env->run_graspplanning(target_name, robot);
238 robot->load(filename_robot, __OR_env);
239 __OR_env->add_robot(robot);
242 if( autogenerate_IK )
243 __OR_env->load_IK_solver(robot);
258 return __OR_env->add_object(name, filename); }
264 return __OR_env->delete_object(name); }
269 return __OR_env->delete_all_objects(); }
276 return __OR_env->rename_object(name, new_name); }
286 return __OR_env->move_object(name, trans_x, trans_y, trans_z); }
297 return __OR_env->move_object(name, trans_x, trans_y, trans_z, robot); }
307 return __OR_env->rotate_object(name, quat_x, quat_y, quat_z, quat_w); }
317 return __OR_env->rotate_object(name, rot_x, rot_y, rot_z); }
332 OpenRAVE::Transform transform = __OR_env->get_env_ptr()->GetKinBody(name)->GetTransform();
334 return robot->set_target_object_position(transform.trans[0], transform.trans[1], transform.trans[2], rot_x);
346 return robot->attach_object(name, __OR_env, manip_name);
368 return robot->release_object(name, __OR_env);
388 return robot->release_all_objects();
virtual void set_manipulator(fawkes::OpenRaveManipulatorPtr &manip, float trans_x=0.f, float trans_y=0.f, float trans_z=0.f, bool calibrate=0)
Set OpenRaveManipulator object for robot, and calculate coordinate-system offsets or set them directl...
OpenRaveThread()
Constructor.
virtual void set_active_robot(fawkes::OpenRaveRobotPtr robot)
Set robot to be used.
Fawkes library namespace.
virtual void init()
Initialize the thread.
virtual bool attach_object(const char *name, fawkes::OpenRaveRobotPtr &robot, const char *manip_name=NULL)
Attach a kinbody to the robot.
Thread class encapsulation of pthreads.
virtual bool delete_all_objects()
Remove all objects from environment.
virtual void finalize()
Finalize the thread.
Logger * logger
This is the Logger member used to access the logger.
virtual ~OpenRaveThread()
Destructor.
virtual bool release_object(const std::string &name, fawkes::OpenRaveRobotPtr &robot)
Release a kinbody from the robot.
virtual bool move_object(const std::string &name, float trans_x, float trans_y, float trans_z, fawkes::OpenRaveRobotPtr &robot)
Move object in the environment, relatively to robot.
Thread aspect to use blocked timing.
virtual bool delete_object(const std::string &name)
Remove object from environment.
virtual void clone(fawkes::OpenRaveEnvironmentPtr &env, fawkes::OpenRaveRobotPtr &robot, fawkes::OpenRaveManipulatorPtr &manip) const
Clone basically everything We pass pointers to pointer as parameters, so the pointers we create befor...
virtual bool release_all_objects()
Release all grabbed kinbodys from the robot.
virtual fawkes::OpenRaveRobotPtr get_active_robot() const
Get RefPtr to currently used OpenRaveRobot object.
OpenRaveEnvironment class.
virtual bool set_target_object(const std::string &name, fawkes::OpenRaveRobotPtr &robot, float rot_x=0)
Set an object as the target.
virtual void run_planner(fawkes::OpenRaveRobotPtr &robot, float sampling=0.01f)
Run planner on previously set target.
virtual bool rotate_object(const std::string &name, float quat_x, float quat_y, float quat_z, float quat_w)
Rotate object by a quaternion.
const char * name() const
Get name of thread.
virtual void log_error(const char *component, const char *format,...)=0
Log error message.
Thread aspect provide a new aspect.
virtual void run_graspplanning(const std::string &target_name, fawkes::OpenRaveRobotPtr &robot)
Run graspplanning script for a given target.
RefPtr<> is a reference-counting shared smartpointer.
virtual void loop()
Code to execute in the thread.
virtual void start_viewer() const
Start Viewer.
virtual bool rename_object(const std::string &name, const std::string &new_name)
Rename object.
virtual fawkes::OpenRaveEnvironmentPtr get_environment() const
Get pointer to OpenRaveEnvironment object.
virtual bool add_object(const std::string &name, const std::string &filename)
Add an object to the environment.
virtual fawkes::OpenRaveRobotPtr add_robot(const std::string &filename_robot, bool autogenerate_IK)
Add a new robot to the environment, and set it as the currently active one.