| environment.h | | environment.h | |
| // -*- coding: utf-8 -*- | | // -*- coding: utf-8 -*- | |
|
| // Copyright (C) 2006-2010 Rosen Diankov (rosen.diankov@gmail.com) | | // Copyright (C) 2006-2011 Rosen Diankov <rosen.diankov@gmail.com> | |
| // | | // | |
| // This file is part of OpenRAVE. | | // This file is part of OpenRAVE. | |
| // OpenRAVE is free software: you can redistribute it and/or modify | | // OpenRAVE is free software: you can redistribute it and/or modify | |
| // it under the terms of the GNU Lesser General Public License as published
by | | // it under the terms of the GNU Lesser General Public License as published
by | |
| // the Free Software Foundation, either version 3 of the License, or | | // the Free Software Foundation, either version 3 of the License, or | |
| // at your option) any later version. | | // at your option) any later version. | |
| // | | // | |
| // This program is distributed in the hope that it will be useful, | | // This program is distributed in the hope that it will be useful, | |
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| | | | |
| skipping to change at line 28 | | skipping to change at line 28 | |
| \brief Definition of the EnvironmentBase interface used for managing al
l objects in an environment. | | \brief Definition of the EnvironmentBase interface used for managing al
l objects in an environment. | |
| */ | | */ | |
| #ifndef OPENRAVE_ENVIRONMENTBASE_H | | #ifndef OPENRAVE_ENVIRONMENTBASE_H | |
| #define OPENRAVE_ENVIRONMENTBASE_H | | #define OPENRAVE_ENVIRONMENTBASE_H | |
| | | | |
| namespace OpenRAVE { | | namespace OpenRAVE { | |
| | | | |
| typedef boost::recursive_try_mutex EnvironmentMutex; | | typedef boost::recursive_try_mutex EnvironmentMutex; | |
| | | | |
| /** \brief Maintains a world state, which serves as the gateway to all func
tions offered through %OpenRAVE. See \ref arch_environment. | | /** \brief Maintains a world state, which serves as the gateway to all func
tions offered through %OpenRAVE. See \ref arch_environment. | |
|
| */ | | */ | |
| class OPENRAVE_API EnvironmentBase : public boost::enable_shared_from_this<
EnvironmentBase> | | class OPENRAVE_API EnvironmentBase : public boost::enable_shared_from_this<
EnvironmentBase> | |
| { | | { | |
| public: | | public: | |
| EnvironmentBase(); | | EnvironmentBase(); | |
| virtual ~EnvironmentBase(); | | virtual ~EnvironmentBase(); | |
| | | | |
| /// \brief Releases all environment resources, should be always called
when environment stops being used. | | /// \brief Releases all environment resources, should be always called
when environment stops being used. | |
| /// | | /// | |
| /// Removing all environment pointer might not be enough to destroy the
environment resources. | | /// Removing all environment pointer might not be enough to destroy the
environment resources. | |
| virtual void Destroy()=0; | | virtual void Destroy()=0; | |
| | | | |
| /// \brief Resets all objects of the scene (preserves all problems, pla
nners). <b>[multi-thread safe]</b> | | /// \brief Resets all objects of the scene (preserves all problems, pla
nners). <b>[multi-thread safe]</b> | |
| /// | | /// | |
| /// Do not call inside a SimulationStep call | | /// Do not call inside a SimulationStep call | |
| virtual void Reset()=0; | | virtual void Reset()=0; | |
| | | | |
| /// \brief set user data | | /// \brief set user data | |
|
| virtual void SetUserData(UserDataPtr data) { __pUserData = data; } | | virtual void SetUserData(UserDataPtr data) { | |
| | | __pUserData = data; | |
| | | } | |
| /// \brief return the user custom data | | /// \brief return the user custom data | |
|
| virtual UserDataPtr GetUserData() const { return __pUserData; } | | virtual UserDataPtr GetUserData() const { | |
| | | return __pUserData; | |
| | | } | |
| | | | |
| /// \brief Returns the OpenRAVE global state, used for initializing plu
gins | | /// \brief Returns the OpenRAVE global state, used for initializing plu
gins | |
| virtual UserDataPtr GlobalState() = 0; | | virtual UserDataPtr GlobalState() = 0; | |
| | | | |
| /// \deprecated (10/09/23) see \ref RaveCreateInterface | | /// \deprecated (10/09/23) see \ref RaveCreateInterface | |
| virtual InterfaceBasePtr CreateInterface(InterfaceType type,const std::
string& interfacename) RAVE_DEPRECATED =0; | | virtual InterfaceBasePtr CreateInterface(InterfaceType type,const std::
string& interfacename) RAVE_DEPRECATED =0; | |
| /// \deprecated (10/09/23) see \ref RaveCreateRobot | | /// \deprecated (10/09/23) see \ref RaveCreateRobot | |
| virtual RobotBasePtr CreateRobot(const std::string& name="") RAVE_DEPRE
CATED =0; | | virtual RobotBasePtr CreateRobot(const std::string& name="") RAVE_DEPRE
CATED =0; | |
| /// \deprecated (10/09/23) see \ref RaveCreatePlanner | | /// \deprecated (10/09/23) see \ref RaveCreatePlanner | |
| virtual PlannerBasePtr CreatePlanner(const std::string& name) RAVE_DEPR
ECATED =0; | | virtual PlannerBasePtr CreatePlanner(const std::string& name) RAVE_DEPR
ECATED =0; | |
| | | | |
| skipping to change at line 180 | | skipping to change at line 184 | |
| /// | | /// | |
| /// Can be called manually by the user inside planners. Keep in mind th
at the internal simulation thread also calls this function periodically. Se
e \ref arch_simulation for more about the simulation thread. | | /// Can be called manually by the user inside planners. Keep in mind th
at the internal simulation thread also calls this function periodically. Se
e \ref arch_simulation for more about the simulation thread. | |
| virtual void StepSimulation(dReal timeStep) = 0; | | virtual void StepSimulation(dReal timeStep) = 0; | |
| | | | |
| /** \brief Start the internal simulation thread. <b>[multi-thread safe]
</b> | | /** \brief Start the internal simulation thread. <b>[multi-thread safe]
</b> | |
| | | | |
| Resets simulation time to 0. See \ref arch_simulation for more abou
t the simulation thread. | | Resets simulation time to 0. See \ref arch_simulation for more abou
t the simulation thread. | |
| | | | |
| \param fDeltaTime the delta step to take in simulation | | \param fDeltaTime the delta step to take in simulation | |
| \param bRealTime if false will call SimulateStep as fast as possibl
e, otherwise will time the simulate step calls so that simulation progresse
s with real system time. | | \param bRealTime if false will call SimulateStep as fast as possibl
e, otherwise will time the simulate step calls so that simulation progresse
s with real system time. | |
|
| */ | | */ | |
| virtual void StartSimulation(dReal fDeltaTime, bool bRealTime=true) = 0
; | | virtual void StartSimulation(dReal fDeltaTime, bool bRealTime=true) = 0
; | |
| | | | |
| /// \brief Stops the internal physics loop, stops calling SimulateStep
for all modules. <b>[multi-thread safe]</b> | | /// \brief Stops the internal physics loop, stops calling SimulateStep
for all modules. <b>[multi-thread safe]</b> | |
| /// | | /// | |
| /// See \ref arch_simulation for more about the simulation thread. | | /// See \ref arch_simulation for more about the simulation thread. | |
| virtual void StopSimulation() = 0; | | virtual void StopSimulation() = 0; | |
| | | | |
| /// \brief Return true if inner simulation loop is executing. <b>[multi
-thread safe]</b> | | /// \brief Return true if inner simulation loop is executing. <b>[multi
-thread safe]</b> | |
| /// | | /// | |
| /// See \ref arch_simulation for more about the simulation thread. | | /// See \ref arch_simulation for more about the simulation thread. | |
| | | | |
| skipping to change at line 206 | | skipping to change at line 210 | |
| virtual uint64_t GetSimulationTime() = 0; | | virtual uint64_t GetSimulationTime() = 0; | |
| //@} | | //@} | |
| | | | |
| /// \name File Loading and Parsing | | /// \name File Loading and Parsing | |
| /// \anchor env_loading | | /// \anchor env_loading | |
| //@{ | | //@{ | |
| | | | |
| /// \brief A set of options used to select particular parts of the scen
e | | /// \brief A set of options used to select particular parts of the scen
e | |
| enum SelectionOptions | | enum SelectionOptions | |
| { | | { | |
|
| SO_NoRobots = 1, ///< everything but robots | | SO_NoRobots = 1, ///< everything but robots | |
| TO_Obstacles = 1, ///< everything but robots | | TO_Obstacles = 1, ///< everything but robots | |
| SO_Robots = 2, ///< all robots | | SO_Robots = 2, ///< all robots | |
| TO_Robots = 2, ///< all robots | | TO_Robots = 2, ///< all robots | |
| SO_Everything = 3, ///< all bodies and robots everything | | SO_Everything = 3, ///< all bodies and robots everythi | |
| TO_Everything = 3, ///< all bodies and robots everything | | ng | |
| SO_Body = 4, ///< only triangulate robot/kinbody | | TO_Everything = 3, ///< all bodies and robots everythi | |
| TO_Body = 4, ///< only triangulate robot/kinbody | | ng | |
| SO_AllExceptBody = 5, ///< select everything but the robot/kinbody | | SO_Body = 4, ///< only triangulate robot/kinbody | |
| TO_AllExceptBody = 5, ///< select everything but the robot/kinbody | | TO_Body = 4, ///< only triangulate robot/kinbody | |
| SO_BodyList = 6, ///< provide a list of body names | | SO_AllExceptBody = 5, ///< select everything but the ro | |
| | | bot/kinbody | |
| | | TO_AllExceptBody = 5, ///< select everything but the ro | |
| | | bot/kinbody | |
| | | SO_BodyList = 6, ///< provide a list of body names | |
| }; | | }; | |
| typedef SelectionOptions TriangulateOptions; | | typedef SelectionOptions TriangulateOptions; | |
| | | | |
| /// \brief Loads a scene from a file and adds all objects in the enviro
nment. <b>[multi-thread safe]</b> | | /// \brief Loads a scene from a file and adds all objects in the enviro
nment. <b>[multi-thread safe]</b> | |
| virtual bool Load(const std::string& filename, const AttributesList& at
ts = AttributesList()) = 0; | | virtual bool Load(const std::string& filename, const AttributesList& at
ts = AttributesList()) = 0; | |
| | | | |
| /// \brief Loads a scene from in-memory data and adds all objects in th
e environment. <b>[multi-thread safe]</b> | | /// \brief Loads a scene from in-memory data and adds all objects in th
e environment. <b>[multi-thread safe]</b> | |
| virtual bool LoadData(const std::string& data, const AttributesList& at
ts = AttributesList()) = 0; | | virtual bool LoadData(const std::string& data, const AttributesList& at
ts = AttributesList()) = 0; | |
| | | | |
|
| virtual bool LoadXMLData(const std::string& data, const AttributesList& | | virtual bool LoadXMLData(const std::string& data, const AttributesList& | |
| atts = AttributesList()) { return LoadData(data,atts); } | | atts = AttributesList()) { | |
| | | return LoadData(data,atts); | |
| | | } | |
| | | | |
| /// \brief Saves a scene depending on the filename extension. Default i
s in COLLADA format | | /// \brief Saves a scene depending on the filename extension. Default i
s in COLLADA format | |
| /// | | /// | |
| /// \param filename the filename to save the results at | | /// \param filename the filename to save the results at | |
| /// \param options controls what to save | | /// \param options controls what to save | |
| /// \param selectname | | /// \param selectname | |
| /// \throw openrave_exception Throw if failed to save anything | | /// \throw openrave_exception Throw if failed to save anything | |
| virtual void Save(const std::string& filename, SelectionOptions options
=SO_Everything, const std::string& selectname="") = 0; | | virtual void Save(const std::string& filename, SelectionOptions options
=SO_Everything, const std::string& selectname="") = 0; | |
| | | | |
| /** \brief Initializes a robot from a resource file. The robot is not a
dded to the environment when calling this function. <b>[multi-thread safe]<
/b> | | /** \brief Initializes a robot from a resource file. The robot is not a
dded to the environment when calling this function. <b>[multi-thread safe]<
/b> | |
| | | | |
| \param robot If a null pointer is passed, a new robot will be creat
ed, otherwise an existing robot will be filled | | \param robot If a null pointer is passed, a new robot will be creat
ed, otherwise an existing robot will be filled | |
| \param filename the name of the resource file, its extension determ
ines the format of the file. See \ref supported_formats. | | \param filename the name of the resource file, its extension determ
ines the format of the file. See \ref supported_formats. | |
| \param atts The attribute/value pair specifying loading options. De
fined in \ref arch_robot. | | \param atts The attribute/value pair specifying loading options. De
fined in \ref arch_robot. | |
|
| */ | | */ | |
| virtual RobotBasePtr ReadRobotURI(RobotBasePtr robot, const std::string
& filename, const AttributesList& atts = AttributesList()) = 0; | | virtual RobotBasePtr ReadRobotURI(RobotBasePtr robot, const std::string
& filename, const AttributesList& atts = AttributesList()) = 0; | |
|
| virtual RobotBasePtr ReadRobotXMLFile(RobotBasePtr robot, const std::st | | virtual RobotBasePtr ReadRobotXMLFile(RobotBasePtr robot, const std::st | |
| ring& filename, const AttributesList& atts = AttributesList()) { return Rea | | ring& filename, const AttributesList& atts = AttributesList()) { | |
| dRobotURI(robot,filename,atts); } | | return ReadRobotURI(robot,filename,atts); | |
| | | } | |
| | | | |
| /// \brief Creates a new robot from a file with no extra load options s
pecified. <b>[multi-thread safe]</b> | | /// \brief Creates a new robot from a file with no extra load options s
pecified. <b>[multi-thread safe]</b> | |
|
| virtual RobotBasePtr ReadRobotURI(const std::string& filename) { return | | virtual RobotBasePtr ReadRobotURI(const std::string& filename) { | |
| ReadRobotURI(RobotBasePtr(),filename,AttributesList()); } | | return ReadRobotURI(RobotBasePtr(),filename,AttributesList()); | |
| virtual RobotBasePtr ReadRobotXMLFile(const std::string& filename) { re | | } | |
| turn ReadRobotURI(filename); } | | virtual RobotBasePtr ReadRobotXMLFile(const std::string& filename) { | |
| | | return ReadRobotURI(filename); | |
| | | } | |
| | | | |
| /** \brief Initialize a robot from in-memory data. <b>[multi-thread saf
e]</b> | | /** \brief Initialize a robot from in-memory data. <b>[multi-thread saf
e]</b> | |
| | | | |
| The robot should not be added the environment when calling this fun
ction. | | The robot should not be added the environment when calling this fun
ction. | |
| \param robot If a null pointer is passed, a new robot will be creat
ed, otherwise an existing robot will be filled | | \param robot If a null pointer is passed, a new robot will be creat
ed, otherwise an existing robot will be filled | |
| \param atts The attribute/value pair specifying loading options. De
fined in \ref arch_robot. | | \param atts The attribute/value pair specifying loading options. De
fined in \ref arch_robot. | |
|
| */ | | */ | |
| virtual RobotBasePtr ReadRobotData(RobotBasePtr robot, const std::strin
g& data, const AttributesList& atts = AttributesList()) = 0; | | virtual RobotBasePtr ReadRobotData(RobotBasePtr robot, const std::strin
g& data, const AttributesList& atts = AttributesList()) = 0; | |
|
| virtual RobotBasePtr ReadRobotXMLData(RobotBasePtr robot, const std::st | | virtual RobotBasePtr ReadRobotXMLData(RobotBasePtr robot, const std::st | |
| ring& data, const AttributesList& atts = AttributesList()) { return ReadRob | | ring& data, const AttributesList& atts = AttributesList()) { | |
| otData(robot,data,atts); } | | return ReadRobotData(robot,data,atts); | |
| | | } | |
| | | | |
| /** \brief Initializes a kinematic body from a resource file. The body
is not added to the environment when calling this function. <b>[multi-threa
d safe]</b> | | /** \brief Initializes a kinematic body from a resource file. The body
is not added to the environment when calling this function. <b>[multi-threa
d safe]</b> | |
| | | | |
| \param filename the name of the resource file, its extension determ
ines the format of the file. See \ref supported_formats. | | \param filename the name of the resource file, its extension determ
ines the format of the file. See \ref supported_formats. | |
| \param body If a null pointer is passed, a new body will be created
, otherwise an existing robot will be filled | | \param body If a null pointer is passed, a new body will be created
, otherwise an existing robot will be filled | |
| \param atts The attribute/value pair specifying loading options. De
fined in \ref arch_kinbody. | | \param atts The attribute/value pair specifying loading options. De
fined in \ref arch_kinbody. | |
|
| */ | | */ | |
| virtual KinBodyPtr ReadKinBodyURI(KinBodyPtr body, const std::string& f
ilename, const AttributesList& atts = AttributesList()) = 0; | | virtual KinBodyPtr ReadKinBodyURI(KinBodyPtr body, const std::string& f
ilename, const AttributesList& atts = AttributesList()) = 0; | |
|
| virtual KinBodyPtr ReadKinBodyXMLFile(KinBodyPtr body, const std::strin | | virtual KinBodyPtr ReadKinBodyXMLFile(KinBodyPtr body, const std::strin | |
| g& filename, const AttributesList& atts = AttributesList()) { return ReadKi | | g& filename, const AttributesList& atts = AttributesList()) { | |
| nBodyURI(body,filename,atts); } | | return ReadKinBodyURI(body,filename,atts); | |
| | | } | |
| | | | |
| /// \brief Creates a new kinbody from an XML file with no extra load op
tions specified. <b>[multi-thread safe]</b> | | /// \brief Creates a new kinbody from an XML file with no extra load op
tions specified. <b>[multi-thread safe]</b> | |
|
| virtual KinBodyPtr ReadKinBodyURI(const std::string& filename) { return | | virtual KinBodyPtr ReadKinBodyURI(const std::string& filename) { | |
| ReadKinBodyURI(KinBodyPtr(),filename,AttributesList()); } | | return ReadKinBodyURI(KinBodyPtr(),filename,AttributesList()); | |
| virtual KinBodyPtr ReadKinBodyXMLFile(const std::string& filename) { re | | } | |
| turn ReadKinBodyURI(filename); } | | virtual KinBodyPtr ReadKinBodyXMLFile(const std::string& filename) { | |
| | | return ReadKinBodyURI(filename); | |
| | | } | |
| | | | |
| /** \brief Initializes a kinematic body from in-memory data. <b>[multi-
thread safe]</b> | | /** \brief Initializes a kinematic body from in-memory data. <b>[multi-
thread safe]</b> | |
| | | | |
| The body should not be added to the environment when calling this f
unction. | | The body should not be added to the environment when calling this f
unction. | |
| \param body If a null pointer is passed, a new body will be created
, otherwise an existing robot will be filled | | \param body If a null pointer is passed, a new body will be created
, otherwise an existing robot will be filled | |
| \param atts The attribute/value pair specifying loading options. De
fined in \ref arch_kinbody. | | \param atts The attribute/value pair specifying loading options. De
fined in \ref arch_kinbody. | |
|
| */ | | */ | |
| virtual KinBodyPtr ReadKinBodyData(KinBodyPtr body, const std::string&
data, const AttributesList& atts = AttributesList()) = 0; | | virtual KinBodyPtr ReadKinBodyData(KinBodyPtr body, const std::string&
data, const AttributesList& atts = AttributesList()) = 0; | |
|
| virtual KinBodyPtr ReadKinBodyXMLData(KinBodyPtr body, const std::strin | | virtual KinBodyPtr ReadKinBodyXMLData(KinBodyPtr body, const std::strin | |
| g& data, const AttributesList& atts = AttributesList()) { return ReadKinBod | | g& data, const AttributesList& atts = AttributesList()) { | |
| yData(body,data,atts); } | | return ReadKinBodyData(body,data,atts); | |
| | | } | |
| | | | |
| /** \brief Initializes an interface from a resource file. <b>[multi-thr
ead safe]</b> | | /** \brief Initializes an interface from a resource file. <b>[multi-thr
ead safe]</b> | |
| | | | |
| \param pinterface If a null pointer is passed, a new interface will
be created, otherwise an existing interface will be filled | | \param pinterface If a null pointer is passed, a new interface will
be created, otherwise an existing interface will be filled | |
| \param filename the name of the resource file, its extension determ
ines the format of the file. See \ref supported_formats. | | \param filename the name of the resource file, its extension determ
ines the format of the file. See \ref supported_formats. | |
| \param atts The attribute/value pair specifying loading options. Se
e the individual interface descriptions at \ref interface_concepts. | | \param atts The attribute/value pair specifying loading options. Se
e the individual interface descriptions at \ref interface_concepts. | |
|
| */ | | */ | |
| virtual InterfaceBasePtr ReadInterfaceURI(InterfaceBasePtr pinterface,
InterfaceType type, const std::string& filename, const AttributesList& atts
= AttributesList()) = 0; | | virtual InterfaceBasePtr ReadInterfaceURI(InterfaceBasePtr pinterface,
InterfaceType type, const std::string& filename, const AttributesList& atts
= AttributesList()) = 0; | |
|
| virtual InterfaceBasePtr ReadInterfaceXMLFile(InterfaceBasePtr pinterfa | | virtual InterfaceBasePtr ReadInterfaceXMLFile(InterfaceBasePtr pinterfa | |
| ce, InterfaceType type, const std::string& filename, const AttributesList& | | ce, InterfaceType type, const std::string& filename, const AttributesList& | |
| atts = AttributesList()) { return ReadInterfaceURI(pinterface,type,filename | | atts = AttributesList()) { | |
| ,atts); } | | return ReadInterfaceURI(pinterface,type,filename,atts); | |
| | | } | |
| | | | |
| virtual InterfaceBasePtr ReadInterfaceURI(const std::string& filename,
const AttributesList& atts = AttributesList()) = 0; | | virtual InterfaceBasePtr ReadInterfaceURI(const std::string& filename,
const AttributesList& atts = AttributesList()) = 0; | |
|
| virtual InterfaceBasePtr ReadInterfaceXMLFile(const std::string& filena | | virtual InterfaceBasePtr ReadInterfaceXMLFile(const std::string& filena | |
| me, const AttributesList& atts = AttributesList()) { return ReadInterfaceUR | | me, const AttributesList& atts = AttributesList()) { | |
| I(filename,atts); } | | return ReadInterfaceURI(filename,atts); | |
| | | } | |
| | | | |
| /** \brief Initializes an interface from in-memory data. <b>[multi-thre
ad safe]</b> | | /** \brief Initializes an interface from in-memory data. <b>[multi-thre
ad safe]</b> | |
| | | | |
| \param pinterface If a null pointer is passed, a new interface will
be created, otherwise an existing interface will be filled | | \param pinterface If a null pointer is passed, a new interface will
be created, otherwise an existing interface will be filled | |
| \param data string containing data | | \param data string containing data | |
| \param atts The attribute/value pair specifying loading options. Se
e the individual interface descriptions at \ref interface_concepts. | | \param atts The attribute/value pair specifying loading options. Se
e the individual interface descriptions at \ref interface_concepts. | |
|
| */ | | */ | |
| virtual InterfaceBasePtr ReadInterfaceData(InterfaceBasePtr pinterface,
InterfaceType type, const std::string& data, const AttributesList& atts =
AttributesList()) = 0; | | virtual InterfaceBasePtr ReadInterfaceData(InterfaceBasePtr pinterface,
InterfaceType type, const std::string& data, const AttributesList& atts =
AttributesList()) = 0; | |
|
| virtual InterfaceBasePtr ReadInterfaceXMLData(InterfaceBasePtr pinterfa | | virtual InterfaceBasePtr ReadInterfaceXMLData(InterfaceBasePtr pinterfa | |
| ce, InterfaceType type, const std::string& data, const AttributesList& atts | | ce, InterfaceType type, const std::string& data, const AttributesList& atts | |
| = AttributesList()) { return ReadInterfaceData(pinterface,type,data,atts); | | = AttributesList()) { | |
| } | | return ReadInterfaceData(pinterface,type,data,atts); | |
| | | } | |
| | | | |
| /** \brief reads in the rigid geometry of a resource file into a TRIMES
H structure | | /** \brief reads in the rigid geometry of a resource file into a TRIMES
H structure | |
| | | | |
| \param filename the name of the resource file, its extension determ
ines the format of the file. Complex meshes and articulated meshes are all
triangulated appropriately. See \ref supported_formats. | | \param filename the name of the resource file, its extension determ
ines the format of the file. Complex meshes and articulated meshes are all
triangulated appropriately. See \ref supported_formats. | |
| \param options Options to control the parsing process. | | \param options Options to control the parsing process. | |
|
| */ | | */ | |
| virtual boost::shared_ptr<KinBody::Link::TRIMESH> ReadTrimeshURI(boost:
:shared_ptr<KinBody::Link::TRIMESH> ptrimesh, const std::string& filename,
const AttributesList& atts = AttributesList()) = 0; | | virtual boost::shared_ptr<KinBody::Link::TRIMESH> ReadTrimeshURI(boost:
:shared_ptr<KinBody::Link::TRIMESH> ptrimesh, const std::string& filename,
const AttributesList& atts = AttributesList()) = 0; | |
|
| virtual boost::shared_ptr<KinBody::Link::TRIMESH> ReadTrimeshFile(boost | | virtual boost::shared_ptr<KinBody::Link::TRIMESH> ReadTrimeshFile(boost | |
| ::shared_ptr<KinBody::Link::TRIMESH> ptrimesh, const std::string& filename, | | ::shared_ptr<KinBody::Link::TRIMESH> ptrimesh, const std::string& filename, | |
| const AttributesList& atts = AttributesList()) { return ReadTrimeshURI(ptr | | const AttributesList& atts = AttributesList()) { | |
| imesh,filename,atts); } | | return ReadTrimeshURI(ptrimesh,filename,atts); | |
| | | } | |
| | | | |
| /// \deprecated (10/09/30) see \ref RaveRegisterXMLReader | | /// \deprecated (10/09/30) see \ref RaveRegisterXMLReader | |
| virtual boost::shared_ptr<void> RegisterXMLReader(InterfaceType type, c
onst std::string& xmltag, const CreateXMLReaderFn& fn) RAVE_DEPRECATED = 0; | | virtual boost::shared_ptr<void> RegisterXMLReader(InterfaceType type, c
onst std::string& xmltag, const CreateXMLReaderFn& fn) RAVE_DEPRECATED = 0; | |
| | | | |
| /// \brief Parses a file for OpenRAVE XML formatted data. | | /// \brief Parses a file for OpenRAVE XML formatted data. | |
| virtual bool ParseXMLFile(BaseXMLReaderPtr preader, const std::string&
filename) RAVE_DEPRECATED = 0; | | virtual bool ParseXMLFile(BaseXMLReaderPtr preader, const std::string&
filename) RAVE_DEPRECATED = 0; | |
| | | | |
| /** \brief Parses a data file for XML data. | | /** \brief Parses a data file for XML data. | |
| | | | |
| \param pdata The data of the buffer | | \param pdata The data of the buffer | |
| \param len the number of bytes valid in pdata | | \param len the number of bytes valid in pdata | |
|
| */ | | */ | |
| virtual bool ParseXMLData(BaseXMLReaderPtr preader, const std::string&
data) RAVE_DEPRECATED = 0; | | virtual bool ParseXMLData(BaseXMLReaderPtr preader, const std::string&
data) RAVE_DEPRECATED = 0; | |
| //@} | | //@} | |
| | | | |
| /// \name Object Setting and Querying | | /// \name Object Setting and Querying | |
| /// \anchor env_objects | | /// \anchor env_objects | |
| //@{ | | //@{ | |
| | | | |
| /// \brief Add a body to the environment | | /// \brief Add a body to the environment | |
| /// | | /// | |
| /// \param[in] body the pointer to an initialized body | | /// \param[in] body the pointer to an initialized body | |
| | | | |
| skipping to change at line 391 | | skipping to change at line 421 | |
| | | | |
| /// \brief Fill an array with all robots loaded in the environment. <b>
[multi-thread safe]</b> | | /// \brief Fill an array with all robots loaded in the environment. <b>
[multi-thread safe]</b> | |
| virtual void GetRobots(std::vector<RobotBasePtr>& robots) const = 0; | | virtual void GetRobots(std::vector<RobotBasePtr>& robots) const = 0; | |
| | | | |
| /// \brief adds a viewer to the environment | | /// \brief adds a viewer to the environment | |
| /// | | /// | |
| /// \throw openrave_exception Throw if body is invalid or already added | | /// \throw openrave_exception Throw if body is invalid or already added | |
| virtual void AddViewer(ViewerBasePtr pviewer) = 0; | | virtual void AddViewer(ViewerBasePtr pviewer) = 0; | |
| | | | |
| /// \deprecated (11/06/13) see AddViewer | | /// \deprecated (11/06/13) see AddViewer | |
|
| virtual bool AttachViewer(ViewerBasePtr pnewviewer) RAVE_DEPRECATED { A | | virtual bool AttachViewer(ViewerBasePtr pnewviewer) RAVE_DEPRECATED { | |
| ddViewer(pnewviewer); return true; } | | AddViewer(pnewviewer); return true; | |
| | | } | |
| | | | |
| /// \brief Return a viewer with a particular name. | | /// \brief Return a viewer with a particular name. | |
| /// | | /// | |
| /// When no name is specified, the first loaded viewer is returned. | | /// When no name is specified, the first loaded viewer is returned. | |
| virtual ViewerBasePtr GetViewer(const std::string& name="") const = 0; | | virtual ViewerBasePtr GetViewer(const std::string& name="") const = 0; | |
| | | | |
| /// \brief Returns a list of loaded viewers with a pointer to a lock pr
eventing the list from being modified. | | /// \brief Returns a list of loaded viewers with a pointer to a lock pr
eventing the list from being modified. | |
| /// | | /// | |
| /// As long as the lock is held, the problems are guaranteed to stay lo
aded in the environment. | | /// As long as the lock is held, the problems are guaranteed to stay lo
aded in the environment. | |
| /// \return returns a pointer to a Lock. Destroying the shared_ptr will
release the lock | | /// \return returns a pointer to a Lock. Destroying the shared_ptr will
release the lock | |
| | | | |
| skipping to change at line 437 | | skipping to change at line 469 | |
| /// \param[out] trimesh - The output triangle mesh. The new triangles a
re appended to the existing triangles! | | /// \param[out] trimesh - The output triangle mesh. The new triangles a
re appended to the existing triangles! | |
| /// \param[in] options - Controlls what to triangulate. | | /// \param[in] options - Controlls what to triangulate. | |
| /// \param[in] selectname - name of the body used in options | | /// \param[in] selectname - name of the body used in options | |
| /// \throw openrave_exception Throw if failed to add anything | | /// \throw openrave_exception Throw if failed to add anything | |
| virtual void TriangulateScene(KinBody::Link::TRIMESH& trimesh, Selectio
nOptions options, const std::string& selectname) = 0; | | virtual void TriangulateScene(KinBody::Link::TRIMESH& trimesh, Selectio
nOptions options, const std::string& selectname) = 0; | |
| //@} | | //@} | |
| | | | |
| /// \brief Load a new module, need to Lock if calling outside simulatio
n thread | | /// \brief Load a new module, need to Lock if calling outside simulatio
n thread | |
| virtual int AddModule(ModuleBasePtr module, const std::string& cmdargs)
= 0; | | virtual int AddModule(ModuleBasePtr module, const std::string& cmdargs)
= 0; | |
| | | | |
|
| virtual int LoadProblem(ModuleBasePtr module, const std::string& cmdarg | | virtual int LoadProblem(ModuleBasePtr module, const std::string& cmdarg | |
| s) { return AddModule(module,cmdargs); } | | s) { | |
| | | return AddModule(module,cmdargs); | |
| | | } | |
| | | | |
| /// \deprecated (10/09/15) see \ref EnvironmentBase::Remove | | /// \deprecated (10/09/15) see \ref EnvironmentBase::Remove | |
| virtual bool RemoveProblem(ModuleBasePtr prob) RAVE_DEPRECATED = 0; | | virtual bool RemoveProblem(ModuleBasePtr prob) RAVE_DEPRECATED = 0; | |
| | | | |
| /// \brief Returns a list of loaded problems with a pointer to a lock p
reventing the list from being modified. | | /// \brief Returns a list of loaded problems with a pointer to a lock p
reventing the list from being modified. | |
| /// | | /// | |
| /// As long as the lock is held, the problems are guaranteed to stay lo
aded in the environment. | | /// As long as the lock is held, the problems are guaranteed to stay lo
aded in the environment. | |
| /// \return returns a pointer to a Lock. Destroying the shared_ptr will
release the lock | | /// \return returns a pointer to a Lock. Destroying the shared_ptr will
release the lock | |
| virtual boost::shared_ptr<void> GetModules(std::list<ModuleBasePtr>& li
stModules) const = 0; | | virtual boost::shared_ptr<void> GetModules(std::list<ModuleBasePtr>& li
stModules) const = 0; | |
| | | | |
|
| virtual boost::shared_ptr<void> GetLoadedProblems(std::list<ModuleBaseP | | virtual boost::shared_ptr<void> GetLoadedProblems(std::list<ModuleBaseP | |
| tr>& listModules) const { return GetModules(listModules); } | | tr>& listModules) const { | |
| | | return GetModules(listModules); | |
| | | } | |
| | | | |
| /// \brief Return the global environment mutex used to protect environm
ent information access in multi-threaded environments. | | /// \brief Return the global environment mutex used to protect environm
ent information access in multi-threaded environments. | |
| /// | | /// | |
| /// Accessing environment body information and adding/removing bodies | | /// Accessing environment body information and adding/removing bodies | |
| /// or changing any type of scene property should have the environment
lock acquired. Once the environment | | /// or changing any type of scene property should have the environment
lock acquired. Once the environment | |
| /// is locked, the user is guaranteed that nnothing will change in the
environment. | | /// is locked, the user is guaranteed that nnothing will change in the
environment. | |
| virtual EnvironmentMutex& GetMutex() const = 0; | | virtual EnvironmentMutex& GetMutex() const = 0; | |
| | | | |
| /// \name 3D plotting methods. | | /// \name 3D plotting methods. | |
| /// \anchor env_plotting | | /// \anchor env_plotting | |
| | | | |
| skipping to change at line 560 | | skipping to change at line 596 | |
| | | | |
| /// sets the debug level | | /// sets the debug level | |
| /// \param level 0 for no debug, 1 - to print all debug messeges. Defau
lt | | /// \param level 0 for no debug, 1 - to print all debug messeges. Defau
lt | |
| /// value for release builds is 0, for debug builds it is 1 | | /// value for release builds is 0, for debug builds it is 1 | |
| /// declaring variables with stdcall can be a little complex | | /// declaring variables with stdcall can be a little complex | |
| virtual void SetDebugLevel(uint32_t level) = 0; | | virtual void SetDebugLevel(uint32_t level) = 0; | |
| virtual uint32_t GetDebugLevel() const = 0; | | virtual uint32_t GetDebugLevel() const = 0; | |
| //@} | | //@} | |
| | | | |
| protected: | | protected: | |
|
| virtual const char* GetHash() const { return OPENRAVE_ENVIRONMENT_HASH; | | virtual const char* GetHash() const { | |
| } | | return OPENRAVE_ENVIRONMENT_HASH; | |
| | | } | |
| private: | | private: | |
|
| UserDataPtr __pUserData; ///< \see GetUserData | | UserDataPtr __pUserData; ///< \see GetUserData | |
| int __nUniqueId; ///< \see GetId | | int __nUniqueId; ///< \see GetId | |
| }; | | }; | |
| | | | |
| } // end namespace OpenRAVE | | } // end namespace OpenRAVE | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 30 change blocks. |
| 71 lines changed or deleted | | 99 lines changed or added | |
|
| geometry.h | | geometry.h | |
| // -*- coding: utf-8 -*- | | // -*- coding: utf-8 -*- | |
|
| // Copyright (C) 2006-2011 Rosen Diankov (rosen.diankov@gmail.com) | | // Copyright (C) 2006-2011 Rosen Diankov <rosen.diankov@gmail.com> | |
| // | | // | |
| // This file is part of OpenRAVE. | | // This file is part of OpenRAVE. | |
| // OpenRAVE is free software: you can redistribute it and/or modify | | // OpenRAVE is free software: you can redistribute it and/or modify | |
| // it under the terms of the GNU Lesser General Public License as published
by | | // it under the terms of the GNU Lesser General Public License as published
by | |
| // the Free Software Foundation, either version 3 of the License, or | | // the Free Software Foundation, either version 3 of the License, or | |
| // at your option) any later version. | | // at your option) any later version. | |
| // | | // | |
| // This program is distributed in the hope that it will be useful, | | // This program is distributed in the hope that it will be useful, | |
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| | | | |
| skipping to change at line 49 | | skipping to change at line 49 | |
| | | | |
| namespace OpenRAVE { | | namespace OpenRAVE { | |
| | | | |
| /// Templated math and geometric functions | | /// Templated math and geometric functions | |
| namespace geometry { | | namespace geometry { | |
| | | | |
| template <typename T> class RaveTransform; | | template <typename T> class RaveTransform; | |
| template <typename T> class RaveTransformMatrix; | | template <typename T> class RaveTransformMatrix; | |
| | | | |
| #ifndef MATH_SQRT | | #ifndef MATH_SQRT | |
|
| inline float MATH_SQRT(float f) { return sqrtf(f); } | | inline float MATH_SQRT(float f) { | |
| inline double MATH_SQRT(double f) { return sqrt(f); } | | return sqrtf(f); | |
| | | } | |
| | | inline double MATH_SQRT(double f) { | |
| | | return sqrt(f); | |
| | | } | |
| #endif | | #endif | |
| #ifndef MATH_SIN | | #ifndef MATH_SIN | |
|
| inline float MATH_SIN(float f) { return sinf(f); } | | inline float MATH_SIN(float f) { | |
| inline double MATH_SIN(double f) { return sin(f); } | | return sinf(f); | |
| | | } | |
| | | inline double MATH_SIN(double f) { | |
| | | return sin(f); | |
| | | } | |
| #endif | | #endif | |
| #ifndef MATH_COS | | #ifndef MATH_COS | |
|
| inline float MATH_COS(float f) { return cosf(f); } | | inline float MATH_COS(float f) { | |
| inline double MATH_COS(double f) { return cos(f); } | | return cosf(f); | |
| | | } | |
| | | inline double MATH_COS(double f) { | |
| | | return cos(f); | |
| | | } | |
| #endif | | #endif | |
| #ifndef MATH_FABS | | #ifndef MATH_FABS | |
|
| inline float MATH_FABS(float f) { return fabsf(f); } | | inline float MATH_FABS(float f) { | |
| inline double MATH_FABS(double f) { return fabs(f); } | | return fabsf(f); | |
| | | } | |
| | | inline double MATH_FABS(double f) { | |
| | | return fabs(f); | |
| | | } | |
| #endif | | #endif | |
| #ifndef MATH_ACOS | | #ifndef MATH_ACOS | |
|
| inline float MATH_ACOS(float f) { return acosf(f); } | | inline float MATH_ACOS(float f) { | |
| inline double MATH_ACOS(double f) { return acos(f); } | | return acosf(f); | |
| | | } | |
| | | inline double MATH_ACOS(double f) { | |
| | | return acos(f); | |
| | | } | |
| #endif | | #endif | |
| #ifndef MATH_ASIN | | #ifndef MATH_ASIN | |
|
| inline float MATH_ASIN(float f) { return asinf(f); } | | inline float MATH_ASIN(float f) { | |
| inline double MATH_ASIN(double f) { return asin(f); } | | return asinf(f); | |
| | | } | |
| | | inline double MATH_ASIN(double f) { | |
| | | return asin(f); | |
| | | } | |
| #endif | | #endif | |
| #ifndef MATH_ATAN2 | | #ifndef MATH_ATAN2 | |
|
| inline float MATH_ATAN2(float fy, float fx) { return atan2f(fy,fx); } | | inline float MATH_ATAN2(float fy, float fx) { | |
| inline double MATH_ATAN2(double fy, double fx) { return atan2(fy,fx); } | | return atan2f(fy,fx); | |
| | | } | |
| | | inline double MATH_ATAN2(double fy, double fx) { | |
| | | return atan2(fy,fx); | |
| | | } | |
| #endif | | #endif | |
| | | | |
| /** \brief Vector class containing 4 dimensions. | | /** \brief Vector class containing 4 dimensions. | |
| | | | |
| \ingroup affine_math | | \ingroup affine_math | |
| It is better to use this for a 3 dim vector because it is 16byte align
ed and SIMD instructions can be used | | It is better to use this for a 3 dim vector because it is 16byte align
ed and SIMD instructions can be used | |
|
| */ | | */ | |
| template <typename T> | | template <typename T> | |
| class RaveVector | | class RaveVector | |
| { | | { | |
| public: | | public: | |
| T x, y, z, w; | | T x, y, z, w; | |
| | | | |
|
| RaveVector() : x(0), y(0), z(0), w(0) {} | | RaveVector() : x(0), y(0), z(0), w(0) { | |
| | | } | |
| | | | |
|
| RaveVector(T x, T y, T z) : x(x), y(y), z(z), w(0) {} | | RaveVector(T x, T y, T z) : x(x), y(y), z(z), w(0) { | |
| RaveVector(T x, T y, T z, T w) : x(x), y(y), z(z), w(w) {} | | } | |
| template<typename U> RaveVector(const RaveVector<U> &vec) : x((T)vec.x) | | RaveVector(T x, T y, T z, T w) : x(x), y(y), z(z), w(w) { | |
| , y((T)vec.y), z((T)vec.z), w((T)vec.w) {} | | } | |
| | | template<typename U> RaveVector(const RaveVector<U> &vec) : x((T)vec.x) | |
| | | , y((T)vec.y), z((T)vec.z), w((T)vec.w) { | |
| | | } | |
| | | | |
| /// note, it only copes 3 values! | | /// note, it only copes 3 values! | |
|
| template<typename U> RaveVector(const U* pf) { MATH_ASSERT(pf != NULL); | | template<typename U> RaveVector(const U* pf) { | |
| x = (T)pf[0]; y = (T)pf[1]; z = (T)pf[2]; w = 0; } | | MATH_ASSERT(pf != NULL); x = (T)pf[0]; y = (T)pf[1]; z = (T)pf[2]; | |
| | | w = 0; | |
| | | } | |
| | | | |
|
| T operator[](int i) const { return (&x)[i]; } | | T operator[] (int i) const { | |
| T& operator[](int i) { return (&x)[i]; } | | return (&x)[i]; | |
| | | } | |
| | | T& operator[] (int i) { | |
| | | return (&x)[i]; | |
| | | } | |
| | | | |
| // casting operators | | // casting operators | |
|
| operator T* () { return &x; } | | operator T* () { | |
| | | return &x; | |
| | | } | |
| operator const T* () const { return (const T*)&x; } | | operator const T* () const { return (const T*)&x; } | |
| | | | |
| template <typename U> | | template <typename U> | |
|
| RaveVector<T>& operator=(const RaveVector<U>& r) { x = (T)r.x; y = (T)r | | RaveVector<T>& operator=(const RaveVector<U>&r) { | |
| .y; z = (T)r.z; w = (T)r.w; return *this; } | | x = (T)r.x; y = (T)r.y; z = (T)r.z; w = (T)r.w; return *this; | |
| | | } | |
| | | | |
| // SCALAR FUNCTIONS | | // SCALAR FUNCTIONS | |
|
| template <typename U> inline T dot(const RaveVector<U> &v) const { retu | | template <typename U> inline T dot(const RaveVector<U> &v) const { | |
| rn x*v.x + y*v.y + z*v.z + w*v.w; } | | return x*v.x + y*v.y + z*v.z + w*v.w; | |
| template <typename U> inline T dot3(const RaveVector<U> &v) const { ret | | } | |
| urn x*v.x + y*v.y + z*v.z; } | | template <typename U> inline T dot3(const RaveVector<U> &v) const { | |
| inline RaveVector<T>& normalize() { return normalize4(); } | | return x*v.x + y*v.y + z*v.z; | |
| | | } | |
| | | inline RaveVector<T>& normalize() { | |
| | | return normalize4(); | |
| | | } | |
| inline RaveVector<T>& normalize4() { | | inline RaveVector<T>& normalize4() { | |
| T f = x*x+y*y+z*z+w*w; | | T f = x*x+y*y+z*z+w*w; | |
|
| if( f < T(1)-std::numeric_limits<dReal>::epsilon() || f > T(1)+std:
:numeric_limits<dReal>::epsilon() ) { | | if(( f < T(1)-std::numeric_limits<dReal>::epsilon()) ||( f > T(1)+s
td::numeric_limits<dReal>::epsilon()) ) { | |
| MATH_ASSERT( f > 0 ); | | MATH_ASSERT( f > 0 ); | |
| // yes it is faster to multiply by (1/f), but with 4 divides we
gain precision (which is more important in robotics) | | // yes it is faster to multiply by (1/f), but with 4 divides we
gain precision (which is more important in robotics) | |
| f = MATH_SQRT(f); | | f = MATH_SQRT(f); | |
| x /= f; y /= f; z /= f; w /= f; | | x /= f; y /= f; z /= f; w /= f; | |
| } | | } | |
| return *this; | | return *this; | |
| } | | } | |
| inline RaveVector<T>& normalize3() { | | inline RaveVector<T>& normalize3() { | |
| T f = x*x+y*y+z*z; | | T f = x*x+y*y+z*z; | |
|
| if( f < T(1)-std::numeric_limits<dReal>::epsilon() || f > T(1)+std:
:numeric_limits<dReal>::epsilon() ) { | | if(( f < T(1)-std::numeric_limits<dReal>::epsilon()) ||( f > T(1)+s
td::numeric_limits<dReal>::epsilon()) ) { | |
| MATH_ASSERT( f > 0 ); | | MATH_ASSERT( f > 0 ); | |
| f = MATH_SQRT(f); | | f = MATH_SQRT(f); | |
| x /= f; y /= f; z /= f; | | x /= f; y /= f; z /= f; | |
| } | | } | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
|
| inline T lengthsqr2() const { return x*x + y*y; } | | inline T lengthsqr2() const { | |
| inline T lengthsqr3() const { return x*x + y*y + z*z; } | | return x*x + y*y; | |
| inline T lengthsqr4() const { return x*x + y*y + z*z + w*w; } | | } | |
| | | inline T lengthsqr3() const { | |
| | | return x*x + y*y + z*z; | |
| | | } | |
| | | inline T lengthsqr4() const { | |
| | | return x*x + y*y + z*z + w*w; | |
| | | } | |
| | | | |
|
| inline void Set3(const T* pvals) { x = pvals[0]; y = pvals[1]; z = pval | | inline void Set3(const T* pvals) { | |
| s[2]; } | | x = pvals[0]; y = pvals[1]; z = pvals[2]; | |
| inline void Set3(T val1, T val2, T val3) { x = val1; y = val2; z = val3 | | } | |
| ; } | | inline void Set3(T val1, T val2, T val3) { | |
| inline void Set4(const T* pvals) { x = pvals[0]; y = pvals[1]; z = pval | | x = val1; y = val2; z = val3; | |
| s[2]; w = pvals[3]; } | | } | |
| inline void Set4(T val1, T val2, T val3, T val4) { x = val1; y = val2; | | inline void Set4(const T* pvals) { | |
| z = val3; w = val4;} | | x = pvals[0]; y = pvals[1]; z = pvals[2]; w = pvals[3]; | |
| | | } | |
| | | inline void Set4(T val1, T val2, T val3, T val4) { | |
| | | x = val1; y = val2; z = val3; w = val4; | |
| | | } | |
| /// 3 dim cross product, w is not touched | | /// 3 dim cross product, w is not touched | |
| inline RaveVector<T> cross(const RaveVector<T> &v) const { | | inline RaveVector<T> cross(const RaveVector<T> &v) const { | |
| RaveVector<T> ucrossv; | | RaveVector<T> ucrossv; | |
| ucrossv[0] = y * v[2] - z * v[1]; | | ucrossv[0] = y * v[2] - z * v[1]; | |
| ucrossv[1] = z * v[0] - x * v[2]; | | ucrossv[1] = z * v[0] - x * v[2]; | |
| ucrossv[2] = x * v[1] - y * v[0]; | | ucrossv[2] = x * v[1] - y * v[0]; | |
| return ucrossv; | | return ucrossv; | |
| } | | } | |
| | | | |
|
| inline RaveVector<T>& Cross(const RaveVector<T> &v) RAVE_DEPRECATED { C | | inline RaveVector<T>& Cross(const RaveVector<T> &v) RAVE_DEPRECATED { | |
| ross(*this, v); return *this; } | | Cross(*this, v); return *this; | |
| | | } | |
| inline RaveVector<T>& Cross(const RaveVector<T> &u, const RaveVector<T>
&v) RAVE_DEPRECATED | | inline RaveVector<T>& Cross(const RaveVector<T> &u, const RaveVector<T>
&v) RAVE_DEPRECATED | |
| { | | { | |
| RaveVector<T> ucrossv; | | RaveVector<T> ucrossv; | |
| ucrossv[0] = u[1] * v[2] - u[2] * v[1]; | | ucrossv[0] = u[1] * v[2] - u[2] * v[1]; | |
| ucrossv[1] = u[2] * v[0] - u[0] * v[2]; | | ucrossv[1] = u[2] * v[0] - u[0] * v[2]; | |
| ucrossv[2] = u[0] * v[1] - u[1] * v[0]; | | ucrossv[2] = u[0] * v[1] - u[1] * v[0]; | |
| *this = ucrossv; | | *this = ucrossv; | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
|
| inline RaveVector<T> operator-() const { RaveVector<T> v; v.x = -x; v.y | | inline RaveVector<T> operator-() const { | |
| = -y; v.z = -z; v.w = -w; return v; } | | RaveVector<T> v; v.x = -x; v.y = -y; v.z = -z; v.w = -w; return v; | |
| template <typename U> inline RaveVector<T> operator+(const RaveVector<U | | } | |
| > &r) const { RaveVector<T> v; v.x = x+r.x; v.y = y+r.y; v.z = z+r.z; v.w = | | template <typename U> inline RaveVector<T> operator+(const RaveVector<U | |
| w+r.w; return v; } | | > &r) const { | |
| template <typename U> inline RaveVector<T> operator-(const RaveVector<U | | RaveVector<T> v; v.x = x+r.x; v.y = y+r.y; v.z = z+r.z; v.w = w+r.w | |
| > &r) const { RaveVector<T> v; v.x = x-r.x; v.y = y-r.y; v.z = z-r.z; v.w = | | ; return v; | |
| w-r.w; return v; } | | } | |
| template <typename U> inline RaveVector<T> operator*(const RaveVector<U | | template <typename U> inline RaveVector<T> operator-(const RaveVector<U | |
| > &r) const { RaveVector<T> v; v.x = r.x*x; v.y = r.y*y; v.z = r.z*z; v.w = | | > &r) const { | |
| r.w*w; return v; } | | RaveVector<T> v; v.x = x-r.x; v.y = y-r.y; v.z = z-r.z; v.w = w-r.w | |
| inline RaveVector<T> operator*(T k) const { RaveVector<T> v; v.x = k*x; | | ; return v; | |
| v.y = k*y; v.z = k*z; v.w = k*w; return v; } | | } | |
| | | template <typename U> inline RaveVector<T> operator*(const RaveVector<U | |
| | | > &r) const { | |
| | | RaveVector<T> v; v.x = r.x*x; v.y = r.y*y; v.z = r.z*z; v.w = r.w*w | |
| | | ; return v; | |
| | | } | |
| | | inline RaveVector<T> operator*(T k) const { | |
| | | RaveVector<T> v; v.x = k*x; v.y = k*y; v.z = k*z; v.w = k*w; return | |
| | | v; | |
| | | } | |
| | | | |
|
| template <typename U> inline RaveVector<T>& operator += (const RaveVect | | template <typename U> inline RaveVector<T>& operator += (const RaveVect | |
| or<U>& r) { x += r.x; y += r.y; z += r.z; w += r.w; return *this; } | | or<U>&r) { | |
| template <typename U> inline RaveVector<T>& operator -= (const RaveVect | | x += r.x; y += r.y; z += r.z; w += r.w; return *this; | |
| or<U>& r) { x -= r.x; y -= r.y; z -= r.z; w -= r.w; return *this; } | | } | |
| template <typename U> inline RaveVector<T>& operator *= (const RaveVect | | template <typename U> inline RaveVector<T>& operator -= (const RaveVect | |
| or<U>& r) { x *= r.x; y *= r.y; z *= r.z; w *= r.w; return *this; } | | or<U>&r) { | |
| | | x -= r.x; y -= r.y; z -= r.z; w -= r.w; return *this; | |
| | | } | |
| | | template <typename U> inline RaveVector<T>& operator *= (const RaveVect | |
| | | or<U>&r) { | |
| | | x *= r.x; y *= r.y; z *= r.z; w *= r.w; return *this; | |
| | | } | |
| | | | |
|
| inline RaveVector<T>& operator *= (const T k) { x *= k; y *= k; z *= k; | | inline RaveVector<T>& operator *= (const T k) { | |
| w *= k; return *this; } | | x *= k; y *= k; z *= k; w *= k; return *this; | |
| inline RaveVector<T>& operator /= (const T _k) { T k=1/_k; x *= k; y *= | | } | |
| k; z *= k; w *= k; return *this; } | | inline RaveVector<T>& operator /= (const T _k) { | |
| | | T k=1/_k; x *= k; y *= k; z *= k; w *= k; return *this; | |
| | | } | |
| | | | |
|
| template <typename U> friend RaveVector<U> operator* (float f, const Ra | | template <typename U> friend RaveVector<U> operator* (float f, const Ra | |
| veVector<U>& v); | | veVector<U>&v); | |
| template <typename U> friend RaveVector<U> operator* (double f, const R | | template <typename U> friend RaveVector<U> operator* (double f, const R | |
| aveVector<U>& v); | | aveVector<U>&v); | |
| | | | |
|
| template <typename U> friend std::ostream& operator<<(std::ostream& O, | | template <typename U> friend std::ostream& operator<<(std::ostream& O, | |
| const RaveVector<U>& v); | | const RaveVector<U>&v); | |
| template <typename U> friend std::istream& operator>>(std::istream& I, | | template <typename U> friend std::istream& operator>>(std::istream& I, | |
| RaveVector<U>& v); | | RaveVector<U>&v); | |
| | | | |
| /// cross product operator | | /// cross product operator | |
| template <typename U> inline RaveVector<T> operator^(const RaveVector<U
> &v) const { | | template <typename U> inline RaveVector<T> operator^(const RaveVector<U
> &v) const { | |
| RaveVector<T> ucrossv; | | RaveVector<T> ucrossv; | |
| ucrossv[0] = y * v[2] - z * v[1]; | | ucrossv[0] = y * v[2] - z * v[1]; | |
| ucrossv[1] = z * v[0] - x * v[2]; | | ucrossv[1] = z * v[0] - x * v[2]; | |
| ucrossv[2] = x * v[1] - y * v[0]; | | ucrossv[2] = x * v[1] - y * v[0]; | |
| return ucrossv; | | return ucrossv; | |
| } | | } | |
| }; | | }; | |
| | | | |
| template <typename T> | | template <typename T> | |
|
| inline RaveVector<T> operator* (float f, const RaveVector<T>& left) | | inline RaveVector<T> operator* (float f, const RaveVector<T>&left) | |
| { | | { | |
| RaveVector<T> v; | | RaveVector<T> v; | |
| v.x = (T)f * left.x; | | v.x = (T)f * left.x; | |
| v.y = (T)f * left.y; | | v.y = (T)f * left.y; | |
| v.z = (T)f * left.z; | | v.z = (T)f * left.z; | |
| v.w = (T)f * left.w; | | v.w = (T)f * left.w; | |
| return v; | | return v; | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
|
| inline RaveVector<T> operator* (double f, const RaveVector<T>& left) | | inline RaveVector<T> operator* (double f, const RaveVector<T>&left) | |
| { | | { | |
| RaveVector<T> v; | | RaveVector<T> v; | |
| v.x = (T)f * left.x; | | v.x = (T)f * left.x; | |
| v.y = (T)f * left.y; | | v.y = (T)f * left.y; | |
| v.z = (T)f * left.z; | | v.z = (T)f * left.z; | |
| v.w = (T)f * left.w; | | v.w = (T)f * left.w; | |
| return v; | | return v; | |
| } | | } | |
| | | | |
| /** \brief Affine transformation parameterized with quaterions. | | /** \brief Affine transformation parameterized with quaterions. | |
| | | | |
| \ingroup affine_math | | \ingroup affine_math | |
|
| */ | | */ | |
| template <typename T> | | template <typename T> | |
| class RaveTransform | | class RaveTransform | |
| { | | { | |
| public: | | public: | |
|
| RaveTransform() { rot.x = 1; } | | RaveTransform() { | |
| | | rot.x = 1; | |
| | | } | |
| template <typename U> RaveTransform(const RaveTransform<U>& t) { | | template <typename U> RaveTransform(const RaveTransform<U>& t) { | |
| rot = t.rot; | | rot = t.rot; | |
| trans = t.trans; | | trans = t.trans; | |
| T fnorm = rot.lengthsqr4(); | | T fnorm = rot.lengthsqr4(); | |
| MATH_ASSERT( fnorm > 0.99f && fnorm < 1.01f ); | | MATH_ASSERT( fnorm > 0.99f && fnorm < 1.01f ); | |
| } | | } | |
| template <typename U> RaveTransform(const RaveVector<U>& rot, const Rav
eVector<U>& trans) : rot(rot), trans(trans) { | | template <typename U> RaveTransform(const RaveVector<U>& rot, const Rav
eVector<U>& trans) : rot(rot), trans(trans) { | |
| T fnorm = rot.lengthsqr4(); | | T fnorm = rot.lengthsqr4(); | |
| MATH_ASSERT( fnorm > 0.99f && fnorm < 1.01f ); | | MATH_ASSERT( fnorm > 0.99f && fnorm < 1.01f ); | |
| } | | } | |
|
| inline RaveTransform(const RaveTransformMatrix<T>& t); | | inline RaveTransform(const RaveTransformMatrix<T>&t); | |
| | | | |
| void identity() { | | void identity() { | |
| rot.x = 1; rot.y = rot.z = rot.w = 0; | | rot.x = 1; rot.y = rot.z = rot.w = 0; | |
| trans.x = trans.y = trans.z = 0; | | trans.x = trans.y = trans.z = 0; | |
| } | | } | |
| | | | |
| /// transform a 3 dim vector | | /// transform a 3 dim vector | |
|
| inline RaveVector<T> operator* (const RaveVector<T>& r) const { | | inline RaveVector<T> operator* (const RaveVector<T>&r) const { | |
| return trans + rotate(r); | | return trans + rotate(r); | |
| } | | } | |
| | | | |
| /// transform a vector by the rotation component only | | /// transform a vector by the rotation component only | |
| inline RaveVector<T> rotate(const RaveVector<T>& r) const { | | inline RaveVector<T> rotate(const RaveVector<T>& r) const { | |
| T xx = 2 * rot.y * rot.y; | | T xx = 2 * rot.y * rot.y; | |
| T xy = 2 * rot.y * rot.z; | | T xy = 2 * rot.y * rot.z; | |
| T xz = 2 * rot.y * rot.w; | | T xz = 2 * rot.y * rot.w; | |
| T xw = 2 * rot.y * rot.x; | | T xw = 2 * rot.y * rot.x; | |
| T yy = 2 * rot.z * rot.z; | | T yy = 2 * rot.z * rot.z; | |
| | | | |
| skipping to change at line 276 | | skipping to change at line 362 | |
| t.rot.z = rot.x*r.rot.z + rot.z*r.rot.x + rot.w*r.rot.y - rot.y*r.r
ot.w; | | t.rot.z = rot.x*r.rot.z + rot.z*r.rot.x + rot.w*r.rot.y - rot.y*r.r
ot.w; | |
| t.rot.w = rot.x*r.rot.w + rot.w*r.rot.x + rot.y*r.rot.z - rot.z*r.r
ot.y; | | t.rot.w = rot.x*r.rot.w + rot.w*r.rot.x + rot.y*r.rot.z - rot.z*r.r
ot.y; | |
| // normalize the transformation | | // normalize the transformation | |
| T fnorm = t.rot.lengthsqr4(); | | T fnorm = t.rot.lengthsqr4(); | |
| MATH_ASSERT( fnorm > 0.99f && fnorm < 1.01f ); | | MATH_ASSERT( fnorm > 0.99f && fnorm < 1.01f ); | |
| t.rot.normalize4(); | | t.rot.normalize4(); | |
| return t; | | return t; | |
| } | | } | |
| | | | |
| /// t = this * r | | /// t = this * r | |
|
| inline RaveTransform<T> operator* (const RaveTransform<T>& r) const { | | inline RaveTransform<T> operator* (const RaveTransform<T>&r) const { | |
| RaveTransform<T> t; | | RaveTransform<T> t; | |
| t.trans = operator*(r.trans); | | t.trans = operator*(r.trans); | |
| t.rot.x = rot.x*r.rot.x - rot.y*r.rot.y - rot.z*r.rot.z - rot.w*r.r
ot.w; | | t.rot.x = rot.x*r.rot.x - rot.y*r.rot.y - rot.z*r.rot.z - rot.w*r.r
ot.w; | |
| t.rot.y = rot.x*r.rot.y + rot.y*r.rot.x + rot.z*r.rot.w - rot.w*r.r
ot.z; | | t.rot.y = rot.x*r.rot.y + rot.y*r.rot.x + rot.z*r.rot.w - rot.w*r.r
ot.z; | |
| t.rot.z = rot.x*r.rot.z + rot.z*r.rot.x + rot.w*r.rot.y - rot.y*r.r
ot.w; | | t.rot.z = rot.x*r.rot.z + rot.z*r.rot.x + rot.w*r.rot.y - rot.y*r.r
ot.w; | |
| t.rot.w = rot.x*r.rot.w + rot.w*r.rot.x + rot.y*r.rot.z - rot.z*r.r
ot.y; | | t.rot.w = rot.x*r.rot.w + rot.w*r.rot.x + rot.y*r.rot.z - rot.z*r.r
ot.y; | |
| // normalize the transformation | | // normalize the transformation | |
| T fnorm = t.rot.lengthsqr4(); | | T fnorm = t.rot.lengthsqr4(); | |
| MATH_ASSERT( fnorm > 0.99f && fnorm < 1.01f ); | | MATH_ASSERT( fnorm > 0.99f && fnorm < 1.01f ); | |
| t.rot.normalize4(); | | t.rot.normalize4(); | |
| return t; | | return t; | |
| } | | } | |
| | | | |
|
| inline RaveTransform<T>& operator*= (const RaveTransform<T>& right) { | | inline RaveTransform<T>& operator*= (const RaveTransform<T>&right) { | |
| *this = operator*(right); | | *this = operator*(right); | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| inline RaveTransform<T> inverse() const { | | inline RaveTransform<T> inverse() const { | |
| RaveTransform<T> inv; | | RaveTransform<T> inv; | |
| inv.rot.x = rot.x; | | inv.rot.x = rot.x; | |
| inv.rot.y = -rot.y; | | inv.rot.y = -rot.y; | |
| inv.rot.z = -rot.z; | | inv.rot.z = -rot.z; | |
| inv.rot.w = -rot.w; | | inv.rot.w = -rot.w; | |
| | | | |
| inv.trans = -inv.rotate(trans); | | inv.trans = -inv.rotate(trans); | |
| return inv; | | return inv; | |
| } | | } | |
| | | | |
|
| template <typename U> inline RaveTransform<T>& operator= (const RaveTra
nsform<U>& r) { | | template <typename U> inline RaveTransform<T>& operator= (const RaveTra
nsform<U>&r) { | |
| trans = r.trans; | | trans = r.trans; | |
| rot = r.rot; | | rot = r.rot; | |
| T fnorm = rot.lengthsqr4(); | | T fnorm = rot.lengthsqr4(); | |
| MATH_ASSERT( fnorm > 0.99f && fnorm < 1.01f ); | | MATH_ASSERT( fnorm > 0.99f && fnorm < 1.01f ); | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
|
| template <typename U> friend std::ostream& operator<<(std::ostream& O, | | template <typename U> friend std::ostream& operator<<(std::ostream& O, | |
| const RaveTransform<U>& v); | | const RaveTransform<U>&v); | |
| template <typename U> friend std::istream& operator>>(std::istream& I, | | template <typename U> friend std::istream& operator>>(std::istream& I, | |
| RaveTransform<U>& v); | | RaveTransform<U>&v); | |
| | | | |
|
| RaveVector<T> rot, trans; ///< rot is a quaternion=(cos(ang/2),axisx*si
n(ang/2),axisy*sin(ang/2),axisz*sin(ang/2)) | | RaveVector<T> rot, trans; ///< rot is a quaternion=(cos(ang/2),axis
x*sin(ang/2),axisy*sin(ang/2),axisz*sin(ang/2)) | |
| }; | | }; | |
| | | | |
| /** \brief Affine transformation parameterized with rotation matrices. Scal
es and shears are not supported. | | /** \brief Affine transformation parameterized with rotation matrices. Scal
es and shears are not supported. | |
| | | | |
| \ingroup affine_math | | \ingroup affine_math | |
|
| */ | | */ | |
| template <typename T> | | template <typename T> | |
| class RaveTransformMatrix | | class RaveTransformMatrix | |
| { | | { | |
| public: | | public: | |
|
| inline RaveTransformMatrix() { identity(); m[3] = m[7] = m[11] = 0; } | | inline RaveTransformMatrix() { | |
| | | identity(); m[3] = m[7] = m[11] = 0; | |
| | | } | |
| template <typename U> RaveTransformMatrix(const RaveTransformMatrix<U>&
t) { | | template <typename U> RaveTransformMatrix(const RaveTransformMatrix<U>&
t) { | |
| // don't memcpy! | | // don't memcpy! | |
| m[0] = t.m[0]; m[1] = t.m[1]; m[2] = t.m[2]; m[3] = t.m[3]; | | m[0] = t.m[0]; m[1] = t.m[1]; m[2] = t.m[2]; m[3] = t.m[3]; | |
| m[4] = t.m[4]; m[5] = t.m[5]; m[6] = t.m[6]; m[7] = t.m[7]; | | m[4] = t.m[4]; m[5] = t.m[5]; m[6] = t.m[6]; m[7] = t.m[7]; | |
| m[8] = t.m[8]; m[9] = t.m[9]; m[10] = t.m[10]; m[11] = t.m[11]; | | m[8] = t.m[8]; m[9] = t.m[9]; m[10] = t.m[10]; m[11] = t.m[11]; | |
| trans = t.trans; | | trans = t.trans; | |
| } | | } | |
|
| inline RaveTransformMatrix(const RaveTransform<T>& t); | | inline RaveTransformMatrix(const RaveTransform<T>&t); | |
| | | | |
| inline void identity() { | | inline void identity() { | |
| m[0] = 1; m[1] = 0; m[2] = 0; | | m[0] = 1; m[1] = 0; m[2] = 0; | |
| m[4] = 0; m[5] = 1; m[6] = 0; | | m[4] = 0; m[5] = 1; m[6] = 0; | |
| m[8] = 0; m[9] = 0; m[10] = 1; | | m[8] = 0; m[9] = 0; m[10] = 1; | |
| trans.x = trans.y = trans.z = 0; | | trans.x = trans.y = trans.z = 0; | |
| } | | } | |
| | | | |
| inline void rotfrommat(T m_00, T m_01, T m_02, T m_10, T m_11, T m_12,
T m_20, T m_21, T m_22) { | | inline void rotfrommat(T m_00, T m_01, T m_02, T m_10, T m_11, T m_12,
T m_20, T m_21, T m_22) { | |
| m[0] = m_00; m[1] = m_01; m[2] = m_02; m[3] = 0; | | m[0] = m_00; m[1] = m_01; m[2] = m_02; m[3] = 0; | |
| | | | |
| skipping to change at line 361 | | skipping to change at line 449 | |
| inline T rot(int i, int j) const { | | inline T rot(int i, int j) const { | |
| MATH_ASSERT( i >= 0 && i < 3 && j >= 0 && j < 3); | | MATH_ASSERT( i >= 0 && i < 3 && j >= 0 && j < 3); | |
| return m[4*i+j]; | | return m[4*i+j]; | |
| } | | } | |
| inline T& rot(int i, int j) { | | inline T& rot(int i, int j) { | |
| MATH_ASSERT( i >= 0 && i < 3 && j >= 0 && j < 3); | | MATH_ASSERT( i >= 0 && i < 3 && j >= 0 && j < 3); | |
| return m[4*i+j]; | | return m[4*i+j]; | |
| } | | } | |
| | | | |
| template <typename U> | | template <typename U> | |
|
| inline RaveVector<T> operator* (const RaveVector<U>& r) const { | | inline RaveVector<T> operator* (const RaveVector<U>&r) const { | |
| RaveVector<T> v; | | RaveVector<T> v; | |
| v[0] = r[0] * m[0] + r[1] * m[1] + r[2] * m[2] + trans.x; | | v[0] = r[0] * m[0] + r[1] * m[1] + r[2] * m[2] + trans.x; | |
| v[1] = r[0] * m[4] + r[1] * m[5] + r[2] * m[6] + trans.y; | | v[1] = r[0] * m[4] + r[1] * m[5] + r[2] * m[6] + trans.y; | |
| v[2] = r[0] * m[8] + r[1] * m[9] + r[2] * m[10] + trans.z; | | v[2] = r[0] * m[8] + r[1] * m[9] + r[2] * m[10] + trans.z; | |
| return v; | | return v; | |
| } | | } | |
| | | | |
| /// t = this * r | | /// t = this * r | |
|
| inline RaveTransformMatrix<T> operator* (const RaveTransformMatrix<T>&
r) const { | | inline RaveTransformMatrix<T> operator* (const RaveTransformMatrix<T>&r
) const { | |
| RaveTransformMatrix<T> t; | | RaveTransformMatrix<T> t; | |
| t.m[0*4+0] = m[0*4+0]*r.m[0*4+0]+m[0*4+1]*r.m[1*4+0]+m[0*4+2]*r.m[2
*4+0]; | | t.m[0*4+0] = m[0*4+0]*r.m[0*4+0]+m[0*4+1]*r.m[1*4+0]+m[0*4+2]*r.m[2
*4+0]; | |
| t.m[0*4+1] = m[0*4+0]*r.m[0*4+1]+m[0*4+1]*r.m[1*4+1]+m[0*4+2]*r.m[2
*4+1]; | | t.m[0*4+1] = m[0*4+0]*r.m[0*4+1]+m[0*4+1]*r.m[1*4+1]+m[0*4+2]*r.m[2
*4+1]; | |
| t.m[0*4+2] = m[0*4+0]*r.m[0*4+2]+m[0*4+1]*r.m[1*4+2]+m[0*4+2]*r.m[2
*4+2]; | | t.m[0*4+2] = m[0*4+0]*r.m[0*4+2]+m[0*4+1]*r.m[1*4+2]+m[0*4+2]*r.m[2
*4+2]; | |
| t.m[1*4+0] = m[1*4+0]*r.m[0*4+0]+m[1*4+1]*r.m[1*4+0]+m[1*4+2]*r.m[2
*4+0]; | | t.m[1*4+0] = m[1*4+0]*r.m[0*4+0]+m[1*4+1]*r.m[1*4+0]+m[1*4+2]*r.m[2
*4+0]; | |
| t.m[1*4+1] = m[1*4+0]*r.m[0*4+1]+m[1*4+1]*r.m[1*4+1]+m[1*4+2]*r.m[2
*4+1]; | | t.m[1*4+1] = m[1*4+0]*r.m[0*4+1]+m[1*4+1]*r.m[1*4+1]+m[1*4+2]*r.m[2
*4+1]; | |
| t.m[1*4+2] = m[1*4+0]*r.m[0*4+2]+m[1*4+1]*r.m[1*4+2]+m[1*4+2]*r.m[2
*4+2]; | | t.m[1*4+2] = m[1*4+0]*r.m[0*4+2]+m[1*4+1]*r.m[1*4+2]+m[1*4+2]*r.m[2
*4+2]; | |
| t.m[2*4+0] = m[2*4+0]*r.m[0*4+0]+m[2*4+1]*r.m[1*4+0]+m[2*4+2]*r.m[2
*4+0]; | | t.m[2*4+0] = m[2*4+0]*r.m[0*4+0]+m[2*4+1]*r.m[1*4+0]+m[2*4+2]*r.m[2
*4+0]; | |
| t.m[2*4+1] = m[2*4+0]*r.m[0*4+1]+m[2*4+1]*r.m[1*4+1]+m[2*4+2]*r.m[2
*4+1]; | | t.m[2*4+1] = m[2*4+0]*r.m[0*4+1]+m[2*4+1]*r.m[1*4+1]+m[2*4+2]*r.m[2
*4+1]; | |
| t.m[2*4+2] = m[2*4+0]*r.m[0*4+2]+m[2*4+1]*r.m[1*4+2]+m[2*4+2]*r.m[2
*4+2]; | | t.m[2*4+2] = m[2*4+0]*r.m[0*4+2]+m[2*4+1]*r.m[1*4+2]+m[2*4+2]*r.m[2
*4+2]; | |
| t.trans[0] = r.trans[0] * m[0] + r.trans[1] * m[1] + r.trans[2] * m
[2] + trans.x; | | t.trans[0] = r.trans[0] * m[0] + r.trans[1] * m[1] + r.trans[2] * m
[2] + trans.x; | |
| t.trans[1] = r.trans[0] * m[4] + r.trans[1] * m[5] + r.trans[2] * m
[6] + trans.y; | | t.trans[1] = r.trans[0] * m[4] + r.trans[1] * m[5] + r.trans[2] * m
[6] + trans.y; | |
| t.trans[2] = r.trans[0] * m[8] + r.trans[1] * m[9] + r.trans[2] * m
[10] + trans.z; | | t.trans[2] = r.trans[0] * m[8] + r.trans[1] * m[9] + r.trans[2] * m
[10] + trans.z; | |
| return t; | | return t; | |
| } | | } | |
| | | | |
|
| inline RaveTransformMatrix<T> operator*= (const RaveTransformMatrix<T>&
r) const { | | inline RaveTransformMatrix<T> operator*= (const RaveTransformMatrix<T>&
r) const { | |
| *this = *this * r; | | *this = *this * r; | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| template <typename U> | | template <typename U> | |
| inline RaveVector<U> rotate(const RaveVector<U>& r) const { | | inline RaveVector<U> rotate(const RaveVector<U>& r) const { | |
| RaveVector<U> v; | | RaveVector<U> v; | |
| v.x = r.x * m[0] + r.y * m[1] + r.z * m[2]; | | v.x = r.x * m[0] + r.y * m[1] + r.z * m[2]; | |
| v.y = r.x * m[4] + r.y * m[5] + r.z * m[6]; | | v.y = r.x * m[4] + r.y * m[5] + r.z * m[6]; | |
| v.z = r.x * m[8] + r.y * m[9] + r.z * m[10]; | | v.z = r.x * m[8] + r.y * m[9] + r.z * m[10]; | |
| | | | |
| skipping to change at line 435 | | skipping to change at line 523 | |
| inv.m[0*4+2] = m[0*4 + 1] * m[1*4 + 2] - m[0*4 + 2] * m[1*4 + 1]; | | inv.m[0*4+2] = m[0*4 + 1] * m[1*4 + 2] - m[0*4 + 2] * m[1*4 + 1]; | |
| inv.m[1*4+0] = m[1*4 + 2] * m[2*4 + 0] - m[1*4 + 0] * m[2*4 + 2]; | | inv.m[1*4+0] = m[1*4 + 2] * m[2*4 + 0] - m[1*4 + 0] * m[2*4 + 2]; | |
| inv.m[1*4+1] = m[0*4 + 0] * m[2*4 + 2] - m[0*4 + 2] * m[2*4 + 0]; | | inv.m[1*4+1] = m[0*4 + 0] * m[2*4 + 2] - m[0*4 + 2] * m[2*4 + 0]; | |
| inv.m[1*4+2] = m[0*4 + 2] * m[1*4 + 0] - m[0*4 + 0] * m[1*4 + 2]; | | inv.m[1*4+2] = m[0*4 + 2] * m[1*4 + 0] - m[0*4 + 0] * m[1*4 + 2]; | |
| inv.m[2*4+0] = m[1*4 + 0] * m[2*4 + 1] - m[1*4 + 1] * m[2*4 + 0]; | | inv.m[2*4+0] = m[1*4 + 0] * m[2*4 + 1] - m[1*4 + 1] * m[2*4 + 0]; | |
| inv.m[2*4+1] = m[0*4 + 1] * m[2*4 + 0] - m[0*4 + 0] * m[2*4 + 1]; | | inv.m[2*4+1] = m[0*4 + 1] * m[2*4 + 0] - m[0*4 + 0] * m[2*4 + 1]; | |
| inv.m[2*4+2] = m[0*4 + 0] * m[1*4 + 1] - m[0*4 + 1] * m[1*4 + 0]; | | inv.m[2*4+2] = m[0*4 + 0] * m[1*4 + 1] - m[0*4 + 1] * m[1*4 + 0]; | |
| T fdet = m[0*4 + 2] * inv.m[2*4+0] + m[1*4 + 2] * inv.m[2*4+1] + m[
2*4 + 2] * inv.m[2*4+2]; | | T fdet = m[0*4 + 2] * inv.m[2*4+0] + m[1*4 + 2] * inv.m[2*4+1] + m[
2*4 + 2] * inv.m[2*4+2]; | |
| MATH_ASSERT(fdet>=0); | | MATH_ASSERT(fdet>=0); | |
| fdet = 1 / fdet; | | fdet = 1 / fdet; | |
|
| inv.m[0*4+0] *= fdet; inv.m[0*4+1] *= fdet; | | inv.m[0*4+0] *= fdet; inv.m[0*4+1] *= fdet; inv | |
| inv.m[0*4+2] *= fdet; | | .m[0*4+2] *= fdet; | |
| inv.m[1*4+0] *= fdet; inv.m[1*4+1] *= fdet; | | inv.m[1*4+0] *= fdet; inv.m[1*4+1] *= fdet; inv | |
| inv.m[1*4+2] *= fdet; | | .m[1*4+2] *= fdet; | |
| inv.m[2*4+0] *= fdet; inv.m[2*4+1] *= fdet; | | inv.m[2*4+0] *= fdet; inv.m[2*4+1] *= fdet; inv | |
| inv.m[2*4+2] *= fdet; | | .m[2*4+2] *= fdet; | |
| inv.trans = -inv.rotate(trans); | | inv.trans = -inv.rotate(trans); | |
| return inv; | | return inv; | |
| } | | } | |
| | | | |
| template <typename U> | | template <typename U> | |
| inline void Extract(RaveVector<U>& right, RaveVector<U>& up, RaveVector
<U>& dir, RaveVector<U>& pos) const { | | inline void Extract(RaveVector<U>& right, RaveVector<U>& up, RaveVector
<U>& dir, RaveVector<U>& pos) const { | |
| pos = trans; | | pos = trans; | |
| right.x = m[0]; up.x = m[1]; dir.x = m[2]; | | right.x = m[0]; up.x = m[1]; dir.x = m[2]; | |
| right.y = m[4]; up.y = m[5]; dir.y = m[6]; | | right.y = m[4]; up.y = m[5]; dir.y = m[6]; | |
| right.z = m[8]; up.z = m[9]; dir.z = m[10]; | | right.z = m[8]; up.z = m[9]; dir.z = m[10]; | |
| } | | } | |
| | | | |
|
| template <typename U> friend std::ostream& operator<<(std::ostream& O, | | template <typename U> friend std::ostream& operator<<(std::ostream& O, | |
| const RaveTransformMatrix<U>& v); | | const RaveTransformMatrix<U>&v); | |
| template <typename U> friend std::istream& operator>>(std::istream& I, | | template <typename U> friend std::istream& operator>>(std::istream& I, | |
| RaveTransformMatrix<U>& v); | | RaveTransformMatrix<U>&v); | |
| | | | |
| /// 3x3 rotation matrix. Note that each row is 4 elements long! So row
1 starts at m[4], row 2 at m[8] | | /// 3x3 rotation matrix. Note that each row is 4 elements long! So row
1 starts at m[4], row 2 at m[8] | |
| /// The reason is to maintain 16 byte alignment when sizeof(T) is 4 byt
es | | /// The reason is to maintain 16 byte alignment when sizeof(T) is 4 byt
es | |
| T m[12]; | | T m[12]; | |
|
| RaveVector<T> trans; ///< translation component | | RaveVector<T> trans; ///< translation component | |
| }; | | }; | |
| | | | |
| /// \brief A ray defined by an origin and a direction. | | /// \brief A ray defined by an origin and a direction. | |
| /// \ingroup geometric_primitives | | /// \ingroup geometric_primitives | |
| template <typename T> | | template <typename T> | |
| class ray | | class ray | |
| { | | { | |
| public: | | public: | |
|
| ray() {} | | ray() { | |
| ray(const RaveVector<T>& _pos, const RaveVector<T>& _dir) : pos(_pos), | | } | |
| dir(_dir) {} | | ray(const RaveVector<T>&_pos, const RaveVector<T>&_dir) : pos(_pos), di | |
| | | r(_dir) { | |
| | | } | |
| RaveVector<T> pos, dir; | | RaveVector<T> pos, dir; | |
| }; | | }; | |
| | | | |
| /// \brief An axis aligned bounding box. | | /// \brief An axis aligned bounding box. | |
| /// \ingroup geometric_primitives | | /// \ingroup geometric_primitives | |
| template <typename T> | | template <typename T> | |
| class aabb | | class aabb | |
| { | | { | |
| public: | | public: | |
|
| aabb() {} | | aabb() { | |
| aabb(const RaveVector<T>& vpos, const RaveVector<T>& vextents) : pos(vp | | } | |
| os), extents(vextents) {} | | aabb(const RaveVector<T>&vpos, const RaveVector<T>&vextents) : pos(vpos | |
| | | ), extents(vextents) { | |
| | | } | |
| RaveVector<T> pos, extents; | | RaveVector<T> pos, extents; | |
| }; | | }; | |
| | | | |
| /// \brief An oriented bounding box. | | /// \brief An oriented bounding box. | |
| /// \ingroup geometric_primitives | | /// \ingroup geometric_primitives | |
| template <typename T> | | template <typename T> | |
| class obb | | class obb | |
| { | | { | |
| public: | | public: | |
| RaveVector<T> right, up, dir, pos, extents; | | RaveVector<T> right, up, dir, pos, extents; | |
| }; | | }; | |
| | | | |
| /// \brief A triangle defined by 3 points. | | /// \brief A triangle defined by 3 points. | |
| /// \ingroup geometric_primitives | | /// \ingroup geometric_primitives | |
| template <typename T> | | template <typename T> | |
| class triangle | | class triangle | |
| { | | { | |
| public: | | public: | |
|
| triangle() {} | | triangle() { | |
| triangle(const RaveVector<T>& v1, const RaveVector<T>& v2, const RaveVe | | } | |
| ctor<T>& v3) : v1(v1), v2(v2), v3(v3) {} | | triangle(const RaveVector<T>&v1, const RaveVector<T>&v2, const RaveVect | |
| ~triangle() {} | | or<T>&v3) : v1(v1), v2(v2), v3(v3) { | |
| | | } | |
| | | ~triangle() { | |
| | | } | |
| | | | |
|
| RaveVector<T> v1, v2, v3; //!< the vertices of the triangle | | RaveVector<T> v1, v2, v3; //!< the vertices of the triangle | |
| | | | |
|
| const RaveVector<T>& operator[](int i) const { return (&v1)[i]; } | | const RaveVector<T>& operator[] (int i) const { | |
| RaveVector<T>& operator[](int i) { return (&v1)[i]; } | | return (&v1)[i]; | |
| | | } | |
| | | RaveVector<T>& operator[] (int i) { | |
| | | return (&v1)[i]; | |
| | | } | |
| | | | |
| /// assumes CCW ordering of vertices | | /// assumes CCW ordering of vertices | |
| inline RaveVector<T> normal() { | | inline RaveVector<T> normal() { | |
| return (v2-v1).cross(v3-v1); | | return (v2-v1).cross(v3-v1); | |
| } | | } | |
| }; | | }; | |
| | | | |
| /// \brief A pyramid with its vertex clipped. | | /// \brief A pyramid with its vertex clipped. | |
| /// \ingroup geometric_primitives | | /// \ingroup geometric_primitives | |
| template <typename T> | | template <typename T> | |
| | | | |
| skipping to change at line 528 | | skipping to change at line 627 | |
| T fnear, ffar; | | T fnear, ffar; | |
| T ffovx,ffovy; | | T ffovx,ffovy; | |
| T fcosfovx,fsinfovx,fcosfovy,fsinfovy; | | T fcosfovx,fsinfovx,fcosfovy,fsinfovy; | |
| }; | | }; | |
| | | | |
| /// \brief intrinsic parameters for a camera. | | /// \brief intrinsic parameters for a camera. | |
| template <typename T> | | template <typename T> | |
| class RaveCameraIntrinsics | | class RaveCameraIntrinsics | |
| { | | { | |
| public: | | public: | |
|
| RaveCameraIntrinsics() : fx(0),fy(0),cx(0),cy(0), focal_length(0.01) {} | | RaveCameraIntrinsics() : fx(0),fy(0),cx(0),cy(0), focal_length(0.01) { | |
| RaveCameraIntrinsics(T fx, T fy, T cx, T cy) : fx(fx), fy(fy), cx(cx), | | } | |
| cy(cy), focal_length(0.01) {} | | RaveCameraIntrinsics(T fx, T fy, T cx, T cy) : fx(fx), fy(fy), cx(cx), | |
| | | cy(cy), focal_length(0.01) { | |
| | | } | |
| | | | |
| template <typename U> | | template <typename U> | |
|
| RaveCameraIntrinsics<T>& operator=(const RaveCameraIntrinsics<U>& r) | | RaveCameraIntrinsics<T>& operator=(const RaveCameraIntrinsics<U>&r) | |
| { | | { | |
| distortion_model = r.distortion_model; | | distortion_model = r.distortion_model; | |
| distortion_coeffs.resize(r.distortion_coeffs.size()); | | distortion_coeffs.resize(r.distortion_coeffs.size()); | |
| std::copy(r.distortion_coeffs.begin(),r.distortion_coeffs.end(),dis
tortion_coeffs.begin()); | | std::copy(r.distortion_coeffs.begin(),r.distortion_coeffs.end(),dis
tortion_coeffs.begin()); | |
| focal_length = r.focal_length; | | focal_length = r.focal_length; | |
| fx = r.fx; | | fx = r.fx; | |
| fy = r.fy; | | fy = r.fy; | |
| cx = r.cx; | | cx = r.cx; | |
| cy = r.cy; | | cy = r.cy; | |
| } | | } | |
| | | | |
| T fx,fy, cx,cy; | | T fx,fy, cx,cy; | |
| | | | |
| /** \brief distortion model of the camera. if left empty, no distortion
model is used. | | /** \brief distortion model of the camera. if left empty, no distortion
model is used. | |
| | | | |
| Possible values are: | | Possible values are: | |
| - "plumb_bob" - Brown. "Decentering Distortion of Lenses", Photomet
ric Engineering, pages 444-462, Vol. 32, No. 3, 1966 | | - "plumb_bob" - Brown. "Decentering Distortion of Lenses", Photomet
ric Engineering, pages 444-462, Vol. 32, No. 3, 1966 | |
|
| */ | | */ | |
| std::string distortion_model; | | std::string distortion_model; | |
|
| std::vector<T> distortion_coeffs; ///< coefficients of the distortion m | | std::vector<T> distortion_coeffs; ///< coefficients of the distorti | |
| odel | | on model | |
| T focal_length; ///< physical focal length distance since focal length | | T focal_length; ///< physical focal length distance since focal len | |
| cannot be recovered from the intrinsic matrix, but is necessary for determi | | gth cannot be recovered from the intrinsic matrix, but is necessary for det | |
| ning the lens plane. | | ermining the lens plane. | |
| }; | | }; | |
| | | | |
| /// Don't add new lines to the output << operators. Some applications use i
t to serialize the data | | /// Don't add new lines to the output << operators. Some applications use i
t to serialize the data | |
| /// to send across the network. | | /// to send across the network. | |
| /// \name Primitive Serialization functions. | | /// \name Primitive Serialization functions. | |
| //@{ | | //@{ | |
| template <typename U> | | template <typename U> | |
|
| std::ostream& operator<<(std::ostream& O, const RaveVector<U>& v) | | std::ostream& operator<<(std::ostream& O, const RaveVector<U>&v) | |
| { | | { | |
| return O << v.x << " " << v.y << " " << v.z << " " << v.w << " "; | | return O << v.x << " " << v.y << " " << v.z << " " << v.w << " "; | |
| } | | } | |
| | | | |
| template <typename U> | | template <typename U> | |
|
| std::istream& operator>>(std::istream& I, RaveVector<U>& v) | | std::istream& operator>>(std::istream& I, RaveVector<U>&v) | |
| { | | { | |
| return I >> v.x >> v.y >> v.z >> v.w; | | return I >> v.x >> v.y >> v.z >> v.w; | |
| } | | } | |
| | | | |
| template <typename U> | | template <typename U> | |
|
| std::ostream& operator<<(std::ostream& O, const RaveTransform<U>& v) | | std::ostream& operator<<(std::ostream& O, const RaveTransform<U>&v) | |
| { | | { | |
| return O << v.rot.x << " " << v.rot.y << " " << v.rot.z << " " << v.rot
.w << " " << v.trans.x << " " << v.trans.y << " " << v.trans.z << " "; | | return O << v.rot.x << " " << v.rot.y << " " << v.rot.z << " " << v.rot
.w << " " << v.trans.x << " " << v.trans.y << " " << v.trans.z << " "; | |
| } | | } | |
| | | | |
| template <typename U> | | template <typename U> | |
|
| std::istream& operator>>(std::istream& I, RaveTransform<U>& v) | | std::istream& operator>>(std::istream& I, RaveTransform<U>&v) | |
| { | | { | |
| return I >> v.rot.x >> v.rot.y >> v.rot.z >> v.rot.w >> v.trans.x >> v.
trans.y >> v.trans.z; | | return I >> v.rot.x >> v.rot.y >> v.rot.z >> v.rot.w >> v.trans.x >> v.
trans.y >> v.trans.z; | |
| } | | } | |
| | | | |
| template <typename U> | | template <typename U> | |
|
| std::ostream& operator<<(std::ostream& O, const ray<U>& r) | | std::ostream& operator<<(std::ostream& O, const ray<U>&r) | |
| { | | { | |
| return O << r.pos.x << " " << r.pos.y << " " << r.pos.z << " " << r.dir
.x << " " << r.dir.y << " " << r.dir.z << " "; | | return O << r.pos.x << " " << r.pos.y << " " << r.pos.z << " " << r.dir
.x << " " << r.dir.y << " " << r.dir.z << " "; | |
| } | | } | |
| | | | |
| template <typename U> | | template <typename U> | |
|
| std::istream& operator>>(std::istream& I, ray<U>& r) | | std::istream& operator>>(std::istream& I, ray<U>&r) | |
| { | | { | |
| return I >> r.pos.x >> r.pos.y >> r.pos.z >> r.dir.x >> r.dir.y >> r.di
r.z; | | return I >> r.pos.x >> r.pos.y >> r.pos.z >> r.dir.x >> r.dir.y >> r.di
r.z; | |
| } | | } | |
| | | | |
| /// \brief serialize in column order! This is the format transformations ar
e passed across the network | | /// \brief serialize in column order! This is the format transformations ar
e passed across the network | |
| template <typename U> | | template <typename U> | |
|
| std::ostream& operator<<(std::ostream& O, const RaveTransformMatrix<U>& v) | | std::ostream& operator<<(std::ostream& O, const RaveTransformMatrix<U>&v) | |
| { | | { | |
| return O << v.m[0] << " " << v.m[4] << " " << v.m[8] << " " << v.m[1] <
< " " << v.m[5] << " " << v.m[9] << " " << v.m[2] << " " << v.m[6] << " " <
< v.m[10] << " " << v.trans.x << " " << v.trans.y << " " << v.trans.z << "
"; | | return O << v.m[0] << " " << v.m[4] << " " << v.m[8] << " " << v.m[1] <
< " " << v.m[5] << " " << v.m[9] << " " << v.m[2] << " " << v.m[6] << " " <
< v.m[10] << " " << v.trans.x << " " << v.trans.y << " " << v.trans.z << "
"; | |
| } | | } | |
| | | | |
| /// \brief de-serialize in column order! This is the format transformations
are passed across the network | | /// \brief de-serialize in column order! This is the format transformations
are passed across the network | |
| template <typename U> | | template <typename U> | |
|
| std::istream& operator>>(std::istream& I, RaveTransformMatrix<U>& v) | | std::istream& operator>>(std::istream& I, RaveTransformMatrix<U>&v) | |
| { | | { | |
| return I >> v.m[0] >> v.m[4] >> v.m[8] >> v.m[1] >> v.m[5] >> v.m[9] >>
v.m[2] >> v.m[6] >> v.m[10] >> v.trans.x >> v.trans.y >> v.trans.z; | | return I >> v.m[0] >> v.m[4] >> v.m[8] >> v.m[1] >> v.m[5] >> v.m[9] >>
v.m[2] >> v.m[6] >> v.m[10] >> v.trans.x >> v.trans.y >> v.trans.z; | |
| } | | } | |
| | | | |
| //@} | | //@} | |
| | | | |
| /// \brief Converts an axis-angle rotation into a quaternion. | | /// \brief Converts an axis-angle rotation into a quaternion. | |
| /// | | /// | |
| /// \ingroup affine_math | | /// \ingroup affine_math | |
| /// \param axis unit axis, 3 values | | /// \param axis unit axis, 3 values | |
| | | | |
| skipping to change at line 805 | | skipping to change at line 906 | |
| RaveVector<T> qb, qm; | | RaveVector<T> qb, qm; | |
| if( quat0.dot(quat1) < 0 ) { | | if( quat0.dot(quat1) < 0 ) { | |
| qb = -quat1; | | qb = -quat1; | |
| } | | } | |
| else { | | else { | |
| qb = quat1; | | qb = quat1; | |
| } | | } | |
| // Calculate angle between them. | | // Calculate angle between them. | |
| T cosHalfTheta = quat0.w * qb.w + quat0.x * qb.x + quat0.y * qb.y + qua
t0.z * qb.z; | | T cosHalfTheta = quat0.w * qb.w + quat0.x * qb.x + quat0.y * qb.y + qua
t0.z * qb.z; | |
| // if quat0=qb or quat0=-qb then theta = 0 and we can return quat0 | | // if quat0=qb or quat0=-qb then theta = 0 and we can return quat0 | |
|
| if (MATH_FABS(cosHalfTheta) >= 1.0){ | | if (MATH_FABS(cosHalfTheta) >= 1.0) { | |
| qm.w = quat0.w;qm.x = quat0.x;qm.y = quat0.y;qm.z = quat0.z; | | qm.w = quat0.w; qm.x = quat0.x; qm.y = quat0.y; qm.z = quat0.z; | |
| return qm; | | return qm; | |
| } | | } | |
| // Calculate temporary values. | | // Calculate temporary values. | |
| T halfTheta = MATH_ACOS(cosHalfTheta); | | T halfTheta = MATH_ACOS(cosHalfTheta); | |
| T sinHalfTheta = MATH_SQRT(1 - cosHalfTheta*cosHalfTheta); | | T sinHalfTheta = MATH_SQRT(1 - cosHalfTheta*cosHalfTheta); | |
| // if theta = 180 degrees then result is not fully defined | | // if theta = 180 degrees then result is not fully defined | |
| // we could rotate around any axis normal to quat0 or qb | | // we could rotate around any axis normal to quat0 or qb | |
|
| if (MATH_FABS(sinHalfTheta) < 1e-7f){ // fabs is floating point absolut
e | | if (MATH_FABS(sinHalfTheta) < 1e-7f) { // fabs is floating point absolu
te | |
| qm.w = (quat0.w * 0.5f + qb.w * 0.5f); | | qm.w = (quat0.w * 0.5f + qb.w * 0.5f); | |
| qm.x = (quat0.x * 0.5f + qb.x * 0.5f); | | qm.x = (quat0.x * 0.5f + qb.x * 0.5f); | |
| qm.y = (quat0.y * 0.5f + qb.y * 0.5f); | | qm.y = (quat0.y * 0.5f + qb.y * 0.5f); | |
| qm.z = (quat0.z * 0.5f + qb.z * 0.5f); | | qm.z = (quat0.z * 0.5f + qb.z * 0.5f); | |
| return qm; | | return qm; | |
| } | | } | |
| T ratioA = MATH_SIN((1 - t) * halfTheta) / sinHalfTheta; | | T ratioA = MATH_SIN((1 - t) * halfTheta) / sinHalfTheta; | |
| T ratioB = MATH_SIN(t * halfTheta) / sinHalfTheta; | | T ratioB = MATH_SIN(t * halfTheta) / sinHalfTheta; | |
| //calculate Quaternion. | | //calculate Quaternion. | |
| qm.w = (quat0.w * ratioA + qb.w * ratioB); | | qm.w = (quat0.w * ratioA + qb.w * ratioB); | |
| | | | |
| skipping to change at line 1000 | | skipping to change at line 1101 | |
| } | | } | |
| | | | |
| /// \brief Tests a point inside a 3D quadrilateral. | | /// \brief Tests a point inside a 3D quadrilateral. | |
| /// \ingroup geometric_primitives | | /// \ingroup geometric_primitives | |
| template <typename T> | | template <typename T> | |
| inline int insideQuadrilateral(const RaveVector<T>& v, const RaveVector<T>&
verts) | | inline int insideQuadrilateral(const RaveVector<T>& v, const RaveVector<T>&
verts) | |
| { | | { | |
| RaveVector<T> v4,v5; | | RaveVector<T> v4,v5; | |
| T m1,m2; | | T m1,m2; | |
| T anglesum=0,costheta; | | T anglesum=0,costheta; | |
|
| for (int i=0;i<4;i++) { | | for (int i=0; i<4; i++) { | |
| v4.x = verts[i].x - v->x; | | v4.x = verts[i].x - v->x; | |
| v4.y = verts[i].y - v->y; | | v4.y = verts[i].y - v->y; | |
| v4.z = verts[i].z - v->z; | | v4.z = verts[i].z - v->z; | |
| v5.x = verts[(i+1)%4].x - v->x; | | v5.x = verts[(i+1)%4].x - v->x; | |
| v5.y = verts[(i+1)%4].y - v->y; | | v5.y = verts[(i+1)%4].y - v->y; | |
| v5.z = verts[(i+1)%4].z - v->z; | | v5.z = verts[(i+1)%4].z - v->z; | |
| m1 = v4.lengthsqr3(); | | m1 = v4.lengthsqr3(); | |
| m2 = v5.lengthsqr3(); | | m2 = v5.lengthsqr3(); | |
| if (m1*m2 <= std::numeric_limits<T>::epsilon()*std::numeric_limits<
T>::epsilon()) { | | if (m1*m2 <= std::numeric_limits<T>::epsilon()*std::numeric_limits<
T>::epsilon()) { | |
| return(1); // on a vertex, consider this inside | | return(1); // on a vertex, consider this inside | |
| | | | |
| skipping to change at line 1030 | | skipping to change at line 1131 | |
| | | | |
| /// \brief Tests a point insdie a 3D triangle. | | /// \brief Tests a point insdie a 3D triangle. | |
| /// \ingroup geometric_primitives | | /// \ingroup geometric_primitives | |
| template <typename T> | | template <typename T> | |
| inline int insideTriangle(const RaveVector<T> v, const triangle<T>& tri) | | inline int insideTriangle(const RaveVector<T> v, const triangle<T>& tri) | |
| { | | { | |
| RaveVector<T> v4,v5; | | RaveVector<T> v4,v5; | |
| T m1,m2; | | T m1,m2; | |
| T anglesum=0.0; | | T anglesum=0.0; | |
| T costheta; | | T costheta; | |
|
| for (int i=0;i<3;i++) { | | for (int i=0; i<3; i++) { | |
| v4.x = tri[i].x - v->x; | | v4.x = tri[i].x - v->x; | |
| v4.y = tri[i].y - v->y; | | v4.y = tri[i].y - v->y; | |
| v4.z = tri[i].z - v->z; | | v4.z = tri[i].z - v->z; | |
| v5.x = tri[(i+1)%3].x - v->x; | | v5.x = tri[(i+1)%3].x - v->x; | |
| v5.y = tri[(i+1)%3].y - v->y; | | v5.y = tri[(i+1)%3].y - v->y; | |
| v5.z = tri[(i+1)%3].z - v->z; | | v5.z = tri[(i+1)%3].z - v->z; | |
| m1 = v4.lengthsqr3(); | | m1 = v4.lengthsqr3(); | |
| m2 = v5.lengthsqr3(); | | m2 = v5.lengthsqr3(); | |
| if (m1*m2 <= std::numeric_limits<T>::epsilon()*std::numeric_limits<
T>::epsilon()) { | | if (m1*m2 <= std::numeric_limits<T>::epsilon()*std::numeric_limits<
T>::epsilon()) { | |
|
| return(1); // on a vertex, consider this inside | | return(1); // on a vertex, consider this inside | |
| } | | } | |
| else { | | else { | |
|
| costheta = v4.dot3(v5)/MATH_SQRT(m1*m2); | | costheta = v4.dot3(v5)/MATH_SQRT(m1*m2); | |
| } | | } | |
| anglesum += acos(costheta); | | anglesum += acos(costheta); | |
| } | | } | |
| T diff = anglesum - (T)2.0 * M_PI; | | T diff = anglesum - (T)2.0 * M_PI; | |
| return RaveFabs(diff) <= std::numeric_limits<T>::epsilon(); | | return RaveFabs(diff) <= std::numeric_limits<T>::epsilon(); | |
| } | | } | |
| | | | |
| /// \brief Test collision of a ray with an axis aligned bounding box. | | /// \brief Test collision of a ray with an axis aligned bounding box. | |
| /// \ingroup geometric_primitives | | /// \ingroup geometric_primitives | |
| template <typename T> | | template <typename T> | |
| inline bool RayAABBTest(const ray<T>& r, const aabb<T>& ab) | | inline bool RayAABBTest(const ray<T>& r, const aabb<T>& ab) | |
| { | | { | |
| RaveVector<T> vd, vpos = r.pos - ab.pos; | | RaveVector<T> vd, vpos = r.pos - ab.pos; | |
|
| if( MATH_FABS(vpos.x) > ab.extents.x && r.dir.x* vpos.x > 0.0f) | | if((MATH_FABS(vpos.x) > ab.extents.x)&&(r.dir.x* vpos.x > 0.0f)) | |
| return false; | | return false; | |
|
| if( MATH_FABS(vpos.y) > ab.extents.y && r.dir.y * vpos.y > 0.0f) | | if((MATH_FABS(vpos.y) > ab.extents.y)&&(r.dir.y * vpos.y > 0.0f)) | |
| return false; | | return false; | |
|
| if( MATH_FABS(vpos.z) > ab.extents.z && r.dir.z * vpos.z > 0.0f) | | if((MATH_FABS(vpos.z) > ab.extents.z)&&(r.dir.z * vpos.z > 0.0f)) | |
| return false; | | return false; | |
| vd = r.dir.cross(vpos); | | vd = r.dir.cross(vpos); | |
| if( MATH_FABS(vd.x) > ab.extents.y * MATH_FABS(r.dir.z) + ab.extents.z
* MATH_FABS(r.dir.y) ) | | if( MATH_FABS(vd.x) > ab.extents.y * MATH_FABS(r.dir.z) + ab.extents.z
* MATH_FABS(r.dir.y) ) | |
| return false; | | return false; | |
| if( MATH_FABS(vd.y) > ab.extents.x * MATH_FABS(r.dir.z) + ab.extents.z
* MATH_FABS(r.dir.x) ) | | if( MATH_FABS(vd.y) > ab.extents.x * MATH_FABS(r.dir.z) + ab.extents.z
* MATH_FABS(r.dir.x) ) | |
| return false; | | return false; | |
| if( MATH_FABS(vd.z) > ab.extents.x * MATH_FABS(r.dir.y) + ab.extents.y
* MATH_FABS(r.dir.x) ) | | if( MATH_FABS(vd.z) > ab.extents.x * MATH_FABS(r.dir.y) + ab.extents.y
* MATH_FABS(r.dir.x) ) | |
| return false; | | return false; | |
| return true; | | return true; | |
| } | | } | |
| | | | |
| /// \brief Test collision of a ray and an oriented bounding box. | | /// \brief Test collision of a ray and an oriented bounding box. | |
| /// \ingroup geometric_primitives | | /// \ingroup geometric_primitives | |
| template <typename T> | | template <typename T> | |
| inline bool RayOBBTest(const ray<T>& r, const obb<T>& o) | | inline bool RayOBBTest(const ray<T>& r, const obb<T>& o) | |
| { | | { | |
| RaveVector<T> vpos, vdir, vd; | | RaveVector<T> vpos, vdir, vd; | |
| vd = r.pos - o.pos; | | vd = r.pos - o.pos; | |
| vpos.x = vd.dot3(o.right); | | vpos.x = vd.dot3(o.right); | |
| vdir.x = r.dir.dot3(o.right); | | vdir.x = r.dir.dot3(o.right); | |
|
| if( MATH_FABS(vpos.x) > o.extents.x && vdir.x* vpos.x > 0.0f) { | | if((MATH_FABS(vpos.x) > o.extents.x)&&(vdir.x* vpos.x > 0.0f)) { | |
| return false; | | return false; | |
| } | | } | |
| vpos.y = vd.dot3(o.up); | | vpos.y = vd.dot3(o.up); | |
| vdir.y = r.dir.dot3(o.up); | | vdir.y = r.dir.dot3(o.up); | |
|
| if( MATH_FABS(vpos.y) > o.extents.y && vdir.y * vpos.y > 0.0f) { | | if((MATH_FABS(vpos.y) > o.extents.y)&&(vdir.y * vpos.y > 0.0f)) { | |
| return false; | | return false; | |
| } | | } | |
| vpos.z = vd.dot3(o.dir); | | vpos.z = vd.dot3(o.dir); | |
| vdir.z = r.dir.dot3(o.dir); | | vdir.z = r.dir.dot3(o.dir); | |
|
| if( MATH_FABS(vpos.z) > o.extents.z && vdir.z * vpos.z > 0.0f) { | | if((MATH_FABS(vpos.z) > o.extents.z)&&(vdir.z * vpos.z > 0.0f)) { | |
| return false; | | return false; | |
| } | | } | |
| cross3(vd, vdir, vpos); | | cross3(vd, vdir, vpos); | |
|
| if( MATH_FABS(vd.x) > o.extents.y * MATH_FABS(vdir.z) + o.extents.z * M | | if((MATH_FABS(vd.x) > o.extents.y * MATH_FABS(vdir.z) + o.extents.z * M | |
| ATH_FABS(vdir.y) || | | ATH_FABS(vdir.y))|| | |
| MATH_FABS(vd.y) > o.extents.x * MATH_FABS(vdir.z) + o.extents.z * M | | ( MATH_FABS(vd.y) > o.extents.x * MATH_FABS(vdir.z) + o.extents.z * | |
| ATH_FABS(vdir.x) || | | MATH_FABS(vdir.x)) || | |
| MATH_FABS(vd.z) > o.extents.x * MATH_FABS(vdir.y) + o.extents.y * M | | ( MATH_FABS(vd.z) > o.extents.x * MATH_FABS(vdir.y) + o.extents.y * | |
| ATH_FABS(vdir.x) ) { | | MATH_FABS(vdir.x)) ) { | |
| return false; | | return false; | |
| } | | } | |
| return true; | | return true; | |
| } | | } | |
| | | | |
| //bool RayFaceTest(const RAY& r, const FACE& f) | | //bool RayFaceTest(const RAY& r, const FACE& f) | |
| //{ | | //{ | |
| // float t = D3DXVec3Dot(&f.plane.vNorm, &(f.v1 - r.vPos) ) / D3DXVec3D
ot(&f.plane.vNorm, &r.vDir); | | // float t = D3DXVec3Dot(&f.plane.vNorm, &(f.v1 - r.vPos) ) / D3DXVec3D
ot(&f.plane.vNorm, &r.vDir); | |
| // | | // | |
| // if(t <= 0.0f) return false; | | // if(t <= 0.0f) return false; | |
| | | | |
| skipping to change at line 1430 | | skipping to change at line 1531 | |
| inline bool TriTriCollision(const RaveVector<T>& u1, const RaveVector<T>& u
2, const RaveVector<T>& u3, const RaveVector<T>& v1, const RaveVector<T>& v
2, const RaveVector<T>& v3, RaveVector<T>& contactpos, RaveVector<T>& conta
ctnorm) | | inline bool TriTriCollision(const RaveVector<T>& u1, const RaveVector<T>& u
2, const RaveVector<T>& u3, const RaveVector<T>& v1, const RaveVector<T>& v
2, const RaveVector<T>& v3, RaveVector<T>& contactpos, RaveVector<T>& conta
ctnorm) | |
| { | | { | |
| // triangle triangle collision test - by Rosen Diankov | | // triangle triangle collision test - by Rosen Diankov | |
| | | | |
| // first see if the faces intersect the planes | | // first see if the faces intersect the planes | |
| // for the face to be intersecting the plane, one of its | | // for the face to be intersecting the plane, one of its | |
| // vertices must be on the opposite side of the plane | | // vertices must be on the opposite side of the plane | |
| char b = 0; | | char b = 0; | |
| RaveVector<T> u12 = u2 - u1, u23 = u3 - u2, u31 = u1 - u3; | | RaveVector<T> u12 = u2 - u1, u23 = u3 - u2, u31 = u1 - u3; | |
| RaveVector<T> v12 = v2 - v1, v23 = v3 - v2, v31 = v1 - v3; | | RaveVector<T> v12 = v2 - v1, v23 = v3 - v2, v31 = v1 - v3; | |
|
| RaveVector<T> vedges[3] = {v12, v23, v31}; | | RaveVector<T> vedges[3] = { v12, v23, v31}; | |
| RaveVector<T> unorm, vnorm; | | RaveVector<T> unorm, vnorm; | |
| unorm = u31.cross(u12); | | unorm = u31.cross(u12); | |
| unorm.w = -unorm.dot3(u1); | | unorm.w = -unorm.dot3(u1); | |
| vnorm = v31.cross(v12); | | vnorm = v31.cross(v12); | |
| vnorm.w = -vnorm.dot3(v1); | | vnorm.w = -vnorm.dot3(v1); | |
| if( vnorm.dot3(u1) + vnorm.w > 0 ) { | | if( vnorm.dot3(u1) + vnorm.w > 0 ) { | |
| b |= 1; | | b |= 1; | |
| } | | } | |
| if( vnorm.dot3(u2) + vnorm.w > 0 ) { | | if( vnorm.dot3(u2) + vnorm.w > 0 ) { | |
| b |= 2; | | b |= 2; | |
| } | | } | |
| if( vnorm.dot3(u3) + vnorm.w > 0 ) { | | if( vnorm.dot3(u3) + vnorm.w > 0 ) { | |
| b |= 4; | | b |= 4; | |
| } | | } | |
|
| if(b == 7 || b == 0) { | | if((b == 7)||(b == 0)) { | |
| return false; | | return false; | |
| } | | } | |
| // now get segment from f1 when it crosses f2's plane | | // now get segment from f1 when it crosses f2's plane | |
| // note that b gives us information on which edges actually intersected | | // note that b gives us information on which edges actually intersected | |
| // so figure out the point that is alone on one side of the plane | | // so figure out the point that is alone on one side of the plane | |
| // then get the segment | | // then get the segment | |
| RaveVector<T> p1, p2; | | RaveVector<T> p1, p2; | |
| const RaveVector<T>* pu=NULL; | | const RaveVector<T>* pu=NULL; | |
| switch(b) { | | switch(b) { | |
| case 1: | | case 1: | |
| | | | |
| skipping to change at line 1481 | | skipping to change at line 1582 | |
| p2 = u2 - u3; | | p2 = u2 - u3; | |
| break; | | break; | |
| } | | } | |
| | | | |
| T t = vnorm.dot3(*pu)+vnorm.w; | | T t = vnorm.dot3(*pu)+vnorm.w; | |
| p1 = *pu - p1 * (t / vnorm.dot3(p1)); | | p1 = *pu - p1 * (t / vnorm.dot3(p1)); | |
| p2 = *pu - p2 * (t / vnorm.dot3(p2)); | | p2 = *pu - p2 * (t / vnorm.dot3(p2)); | |
| | | | |
| // go through each of the segments in v2 and clip | | // go through each of the segments in v2 and clip | |
| RaveVector<T> vcross; | | RaveVector<T> vcross; | |
|
| const RaveVector<T>* pv[] = {&v1, &v2, &v3, &v1}; | | const RaveVector<T>* pv[] = { &v1, &v2, &v3, &v1}; | |
| | | | |
| for(int i = 0; i < 3; ++i) { | | for(int i = 0; i < 3; ++i) { | |
| const RaveVector<T>* pprev = pv[i]; | | const RaveVector<T>* pprev = pv[i]; | |
| RaveVector<T> q1 = p1 - *pprev; | | RaveVector<T> q1 = p1 - *pprev; | |
| RaveVector<T> q2 = p2 - *pprev; | | RaveVector<T> q2 = p2 - *pprev; | |
| vcross = vedges[i].cross(vnorm); | | vcross = vedges[i].cross(vnorm); | |
| T t1 = q1.dot3(vcross); | | T t1 = q1.dot3(vcross); | |
| T t2 = q2.dot3(vcross); | | T t2 = q2.dot3(vcross); | |
| | | | |
| // line segment is out of face | | // line segment is out of face | |
|
| if( t1 >= 0 && t2 >= 0 ) { | | if((t1 >= 0)&&(t2 >= 0)) { | |
| return false; | | return false; | |
| } | | } | |
|
| if( t1 > 0 && t2 < 0 ) { | | if((t1 > 0)&&(t2 < 0)) { | |
| // keep second point, clip first | | // keep second point, clip first | |
| RaveVector<T> dq = q2-q1; | | RaveVector<T> dq = q2-q1; | |
| p1 -= dq*(t1/dq.dot3(vcross)); | | p1 -= dq*(t1/dq.dot3(vcross)); | |
| } | | } | |
|
| else if( t1 < 0 && t2 > 0 ) { | | else if((t1 < 0)&&(t2 > 0)) { | |
| // keep first point, clip second | | // keep first point, clip second | |
| RaveVector<T> dq = q1-q2; | | RaveVector<T> dq = q1-q2; | |
| p2 -= dq*(t2/dq.dot3(vcross)); | | p2 -= dq*(t2/dq.dot3(vcross)); | |
| } | | } | |
| } | | } | |
| | | | |
| contactpos = 0.5f * (p1 + p2); | | contactpos = 0.5f * (p1 + p2); | |
| contactnorm = vnorm.normalize3(); | | contactnorm = vnorm.normalize3(); | |
| return true; | | return true; | |
| } | | } | |
| | | | |
End of changes. 82 change blocks. |
| 166 lines changed or deleted | | 256 lines changed or added | |
|
| kinbody.h | | kinbody.h | |
| // -*- coding: utf-8 -*- | | // -*- coding: utf-8 -*- | |
|
| // Copyright (C) 2006-2011 Rosen Diankov (rosen.diankov@gmail.com) | | // Copyright (C) 2006-2011 Rosen Diankov <rosen.diankov@gmail.com> | |
| // | | // | |
| // This file is part of OpenRAVE. | | // This file is part of OpenRAVE. | |
| // OpenRAVE is free software: you can redistribute it and/or modify | | // OpenRAVE is free software: you can redistribute it and/or modify | |
| // it under the terms of the GNU Lesser General Public License as published
by | | // it under the terms of the GNU Lesser General Public License as published
by | |
| // the Free Software Foundation, either version 3 of the License, or | | // the Free Software Foundation, either version 3 of the License, or | |
| // at your option) any later version. | | // at your option) any later version. | |
| // | | // | |
| // This program is distributed in the hope that it will be useful, | | // This program is distributed in the hope that it will be useful, | |
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| | | | |
| skipping to change at line 30 | | skipping to change at line 30 | |
| #ifndef OPENRAVE_KINBODY_H | | #ifndef OPENRAVE_KINBODY_H | |
| #define OPENRAVE_KINBODY_H | | #define OPENRAVE_KINBODY_H | |
| | | | |
| /// declare function parser class from fparser library | | /// declare function parser class from fparser library | |
| template<typename Value_t> class FunctionParserBase; | | template<typename Value_t> class FunctionParserBase; | |
| | | | |
| namespace OpenRAVE { | | namespace OpenRAVE { | |
| | | | |
| /** \brief <b>[interface]</b> A kinematic body of links and joints. <b>Meth
ods not multi-thread safe.</b> See \ref arch_kinbody. | | /** \brief <b>[interface]</b> A kinematic body of links and joints. <b>Meth
ods not multi-thread safe.</b> See \ref arch_kinbody. | |
| \ingroup interfaces | | \ingroup interfaces | |
|
| */ | | */ | |
| class OPENRAVE_API KinBody : public InterfaceBase | | class OPENRAVE_API KinBody : public InterfaceBase | |
| { | | { | |
| public: | | public: | |
| /// \brief A set of properties for the kinbody. These properties are us
ed to describe a set of variables used in KinBody. | | /// \brief A set of properties for the kinbody. These properties are us
ed to describe a set of variables used in KinBody. | |
| enum KinBodyProperty { | | enum KinBodyProperty { | |
|
| Prop_Joints=0x1, ///< all properties of all joints | | Prop_Joints=0x1, ///< all properties of all joints | |
| Prop_JointLimits=0x2|Prop_Joints, ///< regular limits | | Prop_JointLimits=0x2|Prop_Joints, ///< regular limits | |
| Prop_JointOffset=0x4|Prop_Joints, | | Prop_JointOffset=0x4|Prop_Joints, | |
|
| Prop_JointProperties=0x8|Prop_Joints, ///< max velocity, max accele | | Prop_JointProperties=0x8|Prop_Joints, ///< max velocity, max ac | |
| ration, resolution, max torque | | celeration, resolution, max torque | |
| Prop_Links=0x10, ///< all properties of all links | | Prop_Links=0x10, ///< all properties of all links | |
| Prop_Name=0x20, ///< name changed | | Prop_Name=0x20, ///< name changed | |
| Prop_LinkDraw=0x40, ///< toggle link geometries rendering | | Prop_LinkDraw=0x40, ///< toggle link geometries rendering | |
| Prop_LinkGeometry=0x80|Prop_Links, ///< the geometry of the link ch | | Prop_LinkGeometry=0x80|Prop_Links, ///< the geometry of the lin | |
| anged | | k changed | |
| Prop_JointMimic=0x100|Prop_Joints, ///< joint mimic equations | | Prop_JointMimic=0x100|Prop_Joints, ///< joint mimic equations | |
| Prop_JointVelocityLimits=0x200|Prop_Joints, ///< velocity limits | | Prop_JointVelocityLimits=0x200|Prop_Joints, ///< velocity limit | |
| Prop_LinkStatic=0x400|Prop_Links, ///< static property of link chan | | s | |
| ged | | Prop_LinkStatic=0x400|Prop_Links, ///< static property of link | |
| | | changed | |
| // robot only | | // robot only | |
|
| Prop_RobotManipulators = 0x00010000, ///< [robot only] all properti
es of all manipulators | | Prop_RobotManipulators = 0x00010000, ///< [robot only] all prop
erties of all manipulators | |
| Prop_Manipulators = 0x00010000, | | Prop_Manipulators = 0x00010000, | |
|
| Prop_RobotSensors = 0x00020000, ///< [robot only] all properties of
all sensors | | Prop_RobotSensors = 0x00020000, ///< [robot only] all propertie
s of all sensors | |
| Prop_Sensors = 0x00020000, | | Prop_Sensors = 0x00020000, | |
|
| Prop_RobotSensorPlacement = 0x00040000, ///< [robot only] relative
sensor placement of sensors | | Prop_RobotSensorPlacement = 0x00040000, ///< [robot only] relat
ive sensor placement of sensors | |
| Prop_SensorPlacement = 0x00040000, | | Prop_SensorPlacement = 0x00040000, | |
|
| Prop_RobotActiveDOFs = 0x00080000, ///< [robot only] active dofs ch
anged | | Prop_RobotActiveDOFs = 0x00080000, ///< [robot only] active dof
s changed | |
| }; | | }; | |
| | | | |
| /// \brief A rigid body holding all its collision and rendering data. | | /// \brief A rigid body holding all its collision and rendering data. | |
| class OPENRAVE_API Link : public boost::enable_shared_from_this<Link> | | class OPENRAVE_API Link : public boost::enable_shared_from_this<Link> | |
| { | | { | |
|
| public: | | public: | |
| Link(KinBodyPtr parent); ///< pass in a ODE world | | Link(KinBodyPtr parent); ///< pass in a ODE world | |
| virtual ~Link(); | | virtual ~Link(); | |
| | | | |
| /// \brief User data for trimesh geometries. Vertices are defined i
n counter-clockwise order for outward pointing faces. | | /// \brief User data for trimesh geometries. Vertices are defined i
n counter-clockwise order for outward pointing faces. | |
| class OPENRAVE_API TRIMESH | | class OPENRAVE_API TRIMESH | |
| { | | { | |
|
| public: | | public: | |
| std::vector<Vector> vertices; | | std::vector<Vector> vertices; | |
| std::vector<int> indices; | | std::vector<int> indices; | |
| | | | |
| void ApplyTransform(const Transform& t); | | void ApplyTransform(const Transform& t); | |
| void ApplyTransform(const TransformMatrix& t); | | void ApplyTransform(const TransformMatrix& t); | |
| | | | |
| /// append another TRIMESH to this tri mesh | | /// append another TRIMESH to this tri mesh | |
| void Append(const TRIMESH& mesh); | | void Append(const TRIMESH& mesh); | |
| void Append(const TRIMESH& mesh, const Transform& trans); | | void Append(const TRIMESH& mesh, const Transform& trans); | |
| | | | |
| AABB ComputeAABB() const; | | AABB ComputeAABB() const; | |
| void serialize(std::ostream& o, int options=0) const; | | void serialize(std::ostream& o, int options=0) const; | |
| | | | |
|
| friend OPENRAVE_API std::ostream& operator<<(std::ostream& O, c
onst TRIMESH& trimesh); | | friend OPENRAVE_API std::ostream& operator<<(std::ostream& O, c
onst TRIMESH &trimesh); | |
| friend OPENRAVE_API std::istream& operator>>(std::istream& I, T
RIMESH& trimesh); | | friend OPENRAVE_API std::istream& operator>>(std::istream& I, T
RIMESH& trimesh); | |
| }; | | }; | |
| | | | |
| /// Describes the properties of a basic geometric primitive. | | /// Describes the properties of a basic geometric primitive. | |
| /// Contains everything associated with a physical body along with
a seprate (optional) render file. | | /// Contains everything associated with a physical body along with
a seprate (optional) render file. | |
| class OPENRAVE_API GEOMPROPERTIES | | class OPENRAVE_API GEOMPROPERTIES | |
| { | | { | |
|
| public: | | public: | |
| /// \brief The type of geometry primitive. | | /// \brief The type of geometry primitive. | |
| enum GeomType { | | enum GeomType { | |
| GeomNone = 0, | | GeomNone = 0, | |
| GeomBox = 1, | | GeomBox = 1, | |
| GeomSphere = 2, | | GeomSphere = 2, | |
| GeomCylinder = 3, | | GeomCylinder = 3, | |
| GeomTrimesh = 4, | | GeomTrimesh = 4, | |
| }; | | }; | |
| | | | |
| GEOMPROPERTIES(boost::shared_ptr<Link> parent); | | GEOMPROPERTIES(boost::shared_ptr<Link> parent); | |
|
| virtual ~GEOMPROPERTIES() {} | | virtual ~GEOMPROPERTIES() { | |
| | | } | |
| | | | |
| /// \brief Local transformation of the geom primitive with resp
ect to the link's coordinate system. | | /// \brief Local transformation of the geom primitive with resp
ect to the link's coordinate system. | |
|
| inline const Transform& GetTransform() const { return _t; } | | inline const Transform& GetTransform() const { | |
| inline GeomType GetType() const { return _type; } | | return _t; | |
| inline const Vector& GetRenderScale() const { return vRenderSca | | } | |
| le; } | | inline GeomType GetType() const { | |
| inline const std::string& GetRenderFilename() const { return _r | | return _type; | |
| enderfilename; } | | } | |
| inline float GetTransparency() const { return ftransparency; } | | inline const Vector& GetRenderScale() const { | |
| inline bool IsDraw() const { return _bDraw; } | | return vRenderScale; | |
| inline bool IsModifiable() const { return _bModifiable; } | | } | |
| | | inline const std::string& GetRenderFilename() const { | |
| | | return _renderfilename; | |
| | | } | |
| | | inline float GetTransparency() const { | |
| | | return ftransparency; | |
| | | } | |
| | | inline bool IsDraw() const { | |
| | | return _bDraw; | |
| | | } | |
| | | inline bool IsModifiable() const { | |
| | | return _bModifiable; | |
| | | } | |
| | | | |
|
| inline dReal GetSphereRadius() const { return vGeomData.x; } | | inline dReal GetSphereRadius() const { | |
| inline dReal GetCylinderRadius() const { return vGeomData.x; } | | return vGeomData.x; | |
| inline dReal GetCylinderHeight() const { return vGeomData.y; } | | } | |
| inline const Vector& GetBoxExtents() const { return vGeomData; | | inline dReal GetCylinderRadius() const { | |
| } | | return vGeomData.x; | |
| inline const RaveVector<float>& GetDiffuseColor() const { retur | | } | |
| n diffuseColor; } | | inline dReal GetCylinderHeight() const { | |
| inline const RaveVector<float>& GetAmbientColor() const { retur | | return vGeomData.y; | |
| n ambientColor; } | | } | |
| | | inline const Vector& GetBoxExtents() const { | |
| | | return vGeomData; | |
| | | } | |
| | | inline const RaveVector<float>& GetDiffuseColor() const { | |
| | | return diffuseColor; | |
| | | } | |
| | | inline const RaveVector<float>& GetAmbientColor() const { | |
| | | return ambientColor; | |
| | | } | |
| | | | |
| /// \brief collision data of the specific object in its local c
oordinate system. | | /// \brief collision data of the specific object in its local c
oordinate system. | |
| /// | | /// | |
| /// Should be transformed by \ref GEOMPROPERTIES::GetTransform(
) before rendering. | | /// Should be transformed by \ref GEOMPROPERTIES::GetTransform(
) before rendering. | |
| /// For spheres and cylinders, an appropriate discretization va
lue is chosen. | | /// For spheres and cylinders, an appropriate discretization va
lue is chosen. | |
|
| inline const TRIMESH& GetCollisionMesh() const { return collisi | | inline const TRIMESH& GetCollisionMesh() const { | |
| onmesh; } | | return collisionmesh; | |
| | | } | |
| | | | |
| /// \brief returns an axis aligned bounding box given that the
geometry is transformed by trans | | /// \brief returns an axis aligned bounding box given that the
geometry is transformed by trans | |
| virtual AABB ComputeAABB(const Transform& trans) const; | | virtual AABB ComputeAABB(const Transform& trans) const; | |
| virtual void serialize(std::ostream& o, int options) const; | | virtual void serialize(std::ostream& o, int options) const; | |
| | | | |
| /// \brief sets a new collision mesh and notifies every registe
red callback about it | | /// \brief sets a new collision mesh and notifies every registe
red callback about it | |
| virtual void SetCollisionMesh(const TRIMESH& mesh); | | virtual void SetCollisionMesh(const TRIMESH& mesh); | |
| /// \brief sets a drawing and notifies every registered callbac
k about it | | /// \brief sets a drawing and notifies every registered callbac
k about it | |
| virtual void SetDraw(bool bDraw); | | virtual void SetDraw(bool bDraw); | |
| /// \brief set transparency level (0 is opaque) | | /// \brief set transparency level (0 is opaque) | |
| | | | |
| skipping to change at line 149 | | skipping to change at line 178 | |
| /// \brief validates the contact normal on the surface of the g
eometry and makes sure the normal faces "outside" of the shape. | | /// \brief validates the contact normal on the surface of the g
eometry and makes sure the normal faces "outside" of the shape. | |
| /// | | /// | |
| /// \param position the position of the contact point specified
in the link's coordinate system | | /// \param position the position of the contact point specified
in the link's coordinate system | |
| /// \param normal the unit normal of the contact point specifie
d in the link's coordinate system | | /// \param normal the unit normal of the contact point specifie
d in the link's coordinate system | |
| /// \return true if the normal is changed to face outside of th
e shape | | /// \return true if the normal is changed to face outside of th
e shape | |
| virtual bool ValidateContactNormal(const Vector& position, Vect
or& normal) const; | | virtual bool ValidateContactNormal(const Vector& position, Vect
or& normal) const; | |
| | | | |
| /// \brief sets a new render filename for the geometry. This do
es not change the collision | | /// \brief sets a new render filename for the geometry. This do
es not change the collision | |
| virtual void SetRenderFilename(const std::string& renderfilenam
e); | | virtual void SetRenderFilename(const std::string& renderfilenam
e); | |
| | | | |
|
| protected: | | protected: | |
| /// triangulates the geometry object and initializes collisionm
esh. GeomTrimesh types must already be triangulated | | /// triangulates the geometry object and initializes collisionm
esh. GeomTrimesh types must already be triangulated | |
| /// \param fTessellation to control how fine the triangles need
to be. 1.0f is the default value | | /// \param fTessellation to control how fine the triangles need
to be. 1.0f is the default value | |
| bool InitCollisionMesh(float fTessellation=1); | | bool InitCollisionMesh(float fTessellation=1); | |
| | | | |
| boost::weak_ptr<Link> _parent; | | boost::weak_ptr<Link> _parent; | |
|
| Transform _t; ///< see \ref GetTransform | | Transform _t; ///< see \ref GetTransform | |
| Vector vGeomData; ///< for boxes, first 3 values are extents | | Vector vGeomData; ///< for boxes, first 3 values ar | |
| ///< for sphere it is radius | | e extents | |
| ///< for cylinder, first 2 values | | ///< for sphere it is radius | |
| are radius and height | | ///< for cylinder, first 2 values are radius and height | |
| ///< for trimesh, none | | ///< for trimesh, none | |
| RaveVector<float> diffuseColor, ambientColor; ///< hints for ho | | RaveVector<float> diffuseColor, ambientColor; ///< | |
| w to color the meshes | | hints for how to color the meshes | |
| TRIMESH collisionmesh; ///< see \ref GetCollisionMesh | | TRIMESH collisionmesh; ///< see \ref GetCollisionMe | |
| GeomType _type; ///< the type of geometry primitive | | sh | |
| std::string _renderfilename; ///< render resource file, should | | GeomType _type; ///< the type of geometry p | |
| be transformed by _t before rendering | | rimitive | |
| Vector vRenderScale; ///< render scale of the object (x,y,z) | | std::string _renderfilename; ///< render resource | |
| float ftransparency; ///< value from 0-1 for the transparency o | | file, should be transformed by _t before rendering | |
| f the rendered object, 0 is opaque | | Vector vRenderScale; ///< render scale of the objec | |
| | | t (x,y,z) | |
| | | float ftransparency; ///< value from 0-1 for the tr | |
| | | ansparency of the rendered object, 0 is opaque | |
| | | | |
|
| bool _bDraw; ///< if true, object is drawn as part of t | | bool _bDraw; ///< if true, object is drawn | |
| he 3d model (default is true) | | as part of the 3d model (default is true) | |
| bool _bModifiable; ///< if true, object geometry can be dynamic | | bool _bModifiable; ///< if true, object geometry ca | |
| ally modified (default is true) | | n be dynamically modified (default is true) | |
| | | | |
| #ifdef RAVE_PRIVATE | | #ifdef RAVE_PRIVATE | |
| #ifdef _MSC_VER | | #ifdef _MSC_VER | |
| friend class ColladaReader; | | friend class ColladaReader; | |
| friend class OpenRAVEXMLParser::LinkXMLReader; | | friend class OpenRAVEXMLParser::LinkXMLReader; | |
| friend class OpenRAVEXMLParser::KinBodyXMLReader; | | friend class OpenRAVEXMLParser::KinBodyXMLReader; | |
| #else | | #else | |
| friend class ::ColladaReader; | | friend class ::ColladaReader; | |
| friend class ::OpenRAVEXMLParser::LinkXMLReader; | | friend class ::OpenRAVEXMLParser::LinkXMLReader; | |
| friend class ::OpenRAVEXMLParser::KinBodyXMLReader; | | friend class ::OpenRAVEXMLParser::KinBodyXMLReader; | |
| #endif | | #endif | |
| #endif | | #endif | |
| friend class KinBody; | | friend class KinBody; | |
| friend class KinBody::Link; | | friend class KinBody::Link; | |
| }; | | }; | |
| | | | |
|
| inline const std::string& GetName() const { return _name; } | | inline const std::string& GetName() const { | |
| | | return _name; | |
| | | } | |
| | | | |
| /// \brief Indicates a static body that does not move with respect
to the root link. | | /// \brief Indicates a static body that does not move with respect
to the root link. | |
| /// | | /// | |
| //// Static should be used when an object has infinite mass and | | //// Static should be used when an object has infinite mass and | |
| ///< shouldn't be affected by physics (including gravity). Collisio
n still works. | | ///< shouldn't be affected by physics (including gravity). Collisio
n still works. | |
|
| inline bool IsStatic() const { return _bStatic; } | | inline bool IsStatic() const { | |
| | | return _bStatic; | |
| | | } | |
| | | | |
| /// \brief returns true if the link is enabled. \see Enable | | /// \brief returns true if the link is enabled. \see Enable | |
| virtual bool IsEnabled() const; | | virtual bool IsEnabled() const; | |
| | | | |
| /// \brief Enables a Link. An enabled link takes part in collision
detection and physics simulations | | /// \brief Enables a Link. An enabled link takes part in collision
detection and physics simulations | |
| virtual void Enable(bool enable); | | virtual void Enable(bool enable); | |
| | | | |
| /// \brief parent body that link belong to. | | /// \brief parent body that link belong to. | |
|
| inline KinBodyPtr GetParent() const { return KinBodyPtr(_parent); } | | inline KinBodyPtr GetParent() const { | |
| | | return KinBodyPtr(_parent); | |
| | | } | |
| | | | |
| /// \brief unique index into parent KinBody::GetLinks vector | | /// \brief unique index into parent KinBody::GetLinks vector | |
|
| inline int GetIndex() const { return _index; } | | inline int GetIndex() const { | |
| inline const TRIMESH& GetCollisionData() const { return collision; | | return _index; | |
| } | | } | |
| | | inline const TRIMESH& GetCollisionData() const { | |
| | | return collision; | |
| | | } | |
| | | | |
| /// \brief Compute the aabb of all the geometries of the link in th
e world coordinate system | | /// \brief Compute the aabb of all the geometries of the link in th
e world coordinate system | |
| virtual AABB ComputeAABB() const; | | virtual AABB ComputeAABB() const; | |
| | | | |
| /// \brief Return the current transformation of the link in the wor
ld coordinate system. | | /// \brief Return the current transformation of the link in the wor
ld coordinate system. | |
|
| inline Transform GetTransform() const { return _t; } | | inline Transform GetTransform() const { | |
| | | return _t; | |
| | | } | |
| | | | |
| /// \brief Return all the direct parent links in the kinematics hie
rarchy of this link. | | /// \brief Return all the direct parent links in the kinematics hie
rarchy of this link. | |
| /// | | /// | |
| /// A parent link is is immediately connected to this link by a joi
nt and has a path to the root joint so that it is possible | | /// A parent link is is immediately connected to this link by a joi
nt and has a path to the root joint so that it is possible | |
| /// to compute this link's transformation from its parent. | | /// to compute this link's transformation from its parent. | |
| /// \param[out] filled with the parent links | | /// \param[out] filled with the parent links | |
| virtual void GetParentLinks(std::vector< boost::shared_ptr<Link> >&
vParentLinks) const; | | virtual void GetParentLinks(std::vector< boost::shared_ptr<Link> >&
vParentLinks) const; | |
| | | | |
| /// \brief Tests if a link is a direct parent. | | /// \brief Tests if a link is a direct parent. | |
| /// | | /// | |
| /// \see GetParentLinks | | /// \see GetParentLinks | |
| /// \param link The link to test if it is one of the parents of thi
s link. | | /// \param link The link to test if it is one of the parents of thi
s link. | |
| virtual bool IsParentLink(boost::shared_ptr<Link const> plink) cons
t; | | virtual bool IsParentLink(boost::shared_ptr<Link const> plink) cons
t; | |
| | | | |
| /// \return center of mass offset in the link's local coordinate fr
ame | | /// \return center of mass offset in the link's local coordinate fr
ame | |
|
| inline Vector GetCOMOffset() const {return _transMass.trans; } | | inline Vector GetCOMOffset() const { | |
| inline const TransformMatrix& GetInertia() const { return _transMas | | return _transMass.trans; | |
| s; } | | } | |
| inline dReal GetMass() const { return _mass; } | | inline const TransformMatrix& GetInertia() const { | |
| | | return _transMass; | |
| | | } | |
| | | inline dReal GetMass() const { | |
| | | return _mass; | |
| | | } | |
| | | | |
| /// \brief sets a link to be static. | | /// \brief sets a link to be static. | |
| /// | | /// | |
| /// Because this can affect the kinematics, it requires the body's
internal structures to be recomputed | | /// Because this can affect the kinematics, it requires the body's
internal structures to be recomputed | |
| virtual void SetStatic(bool bStatic); | | virtual void SetStatic(bool bStatic); | |
| | | | |
| /// \brief Sets the transform of the link regardless of kinematics | | /// \brief Sets the transform of the link regardless of kinematics | |
| /// | | /// | |
| /// \param[in] t the new transformation | | /// \param[in] t the new transformation | |
| virtual void SetTransform(const Transform& transform); | | virtual void SetTransform(const Transform& transform); | |
| | | | |
| skipping to change at line 264 | | skipping to change at line 311 | |
| | | | |
| /// get the velocity of the link | | /// get the velocity of the link | |
| /// \param[out] linearvel the translational velocity | | /// \param[out] linearvel the translational velocity | |
| /// \param[out] angularvel is the rotation axis * angular speed | | /// \param[out] angularvel is the rotation axis * angular speed | |
| virtual void GetVelocity(Vector& linearvel, Vector& angularvel) con
st; | | virtual void GetVelocity(Vector& linearvel, Vector& angularvel) con
st; | |
| | | | |
| //typedef std::list<GEOMPROPERTIES>::iterator GeomPtr; | | //typedef std::list<GEOMPROPERTIES>::iterator GeomPtr; | |
| //typedef std::list<GEOMPROPERTIES>::const_iterator GeomConstPtr; | | //typedef std::list<GEOMPROPERTIES>::const_iterator GeomConstPtr; | |
| | | | |
| /// \brief returns a list of all the geometry objects. | | /// \brief returns a list of all the geometry objects. | |
|
| inline const std::list<GEOMPROPERTIES>& GetGeometries() const { ret | | inline const std::list<GEOMPROPERTIES>& GetGeometries() const { | |
| urn _listGeomProperties; } | | return _listGeomProperties; | |
| | | } | |
| virtual GEOMPROPERTIES& GetGeometry(int index); | | virtual GEOMPROPERTIES& GetGeometry(int index); | |
| | | | |
| /// \brief swaps the current geometries with the new geometries. | | /// \brief swaps the current geometries with the new geometries. | |
| /// | | /// | |
| /// This gives a user control for dynamically changing the object g
eometry. Note that the kinbody/robot hash could change. | | /// This gives a user control for dynamically changing the object g
eometry. Note that the kinbody/robot hash could change. | |
| virtual void SwapGeometries(std::list<GEOMPROPERTIES>& listNewGeome
tries); | | virtual void SwapGeometries(std::list<GEOMPROPERTIES>& listNewGeome
tries); | |
| | | | |
| /// validates the contact normal on link and makes sure the normal
faces "outside" of the geometry shape it lies on. An exception can be throw
n if position is not on a geometry surface | | /// validates the contact normal on link and makes sure the normal
faces "outside" of the geometry shape it lies on. An exception can be throw
n if position is not on a geometry surface | |
| /// \param position the position of the contact point specified in
the link's coordinate system, assumes it is on a particular geometry | | /// \param position the position of the contact point specified in
the link's coordinate system, assumes it is on a particular geometry | |
| /// \param normal the unit normal of the contact point specified in
the link's coordinate system | | /// \param normal the unit normal of the contact point specified in
the link's coordinate system | |
| | | | |
| skipping to change at line 288 | | skipping to change at line 337 | |
| /// \brief returns true if plink is rigidily attahced to this link. | | /// \brief returns true if plink is rigidily attahced to this link. | |
| virtual bool IsRigidlyAttached(boost::shared_ptr<Link const> plink)
const; | | virtual bool IsRigidlyAttached(boost::shared_ptr<Link const> plink)
const; | |
| | | | |
| /// \brief Gets all the rigidly attached links to linkindex, also a
dds the link to the list. | | /// \brief Gets all the rigidly attached links to linkindex, also a
dds the link to the list. | |
| /// | | /// | |
| /// \param vattachedlinks the array to insert all links attached to
linkindex with the link itself. | | /// \param vattachedlinks the array to insert all links attached to
linkindex with the link itself. | |
| virtual void GetRigidlyAttachedLinks(std::vector<boost::shared_ptr<
Link> >& vattachedlinks) const; | | virtual void GetRigidlyAttachedLinks(std::vector<boost::shared_ptr<
Link> >& vattachedlinks) const; | |
| | | | |
| virtual void serialize(std::ostream& o, int options) const; | | virtual void serialize(std::ostream& o, int options) const; | |
| | | | |
|
| protected: | | protected: | |
| /// \brief Updates the cached information due to changes in the col
lision data. | | /// \brief Updates the cached information due to changes in the col
lision data. | |
| virtual void _Update(); | | virtual void _Update(); | |
| | | | |
|
| Transform _t; ///< \see GetTransform | | Transform _t; ///< \see GetTransform | |
| TransformMatrix _transMass; ///< the 3x3 inertia and center of mass | | TransformMatrix _transMass; ///< the 3x3 inertia and center | |
| of the link in the link's coordinate system | | of mass of the link in the link's coordinate system | |
| dReal _mass; | | dReal _mass; | |
|
| TRIMESH collision; ///< triangles for collision checking, triangles | | TRIMESH collision; ///< triangles for collision checking, t | |
| are always the triangulation | | riangles are always the triangulation | |
| ///< of the body when it is at the identity tran | | ///< of the body when it is at the ident | |
| sformation | | ity transformation | |
| | | | |
|
| std::string _name; ///< optional link name | | std::string _name; ///< optional link name | |
| std::list<GEOMPROPERTIES> _listGeomProperties; ///< \see GetGeometr | | std::list<GEOMPROPERTIES> _listGeomProperties; ///< \see Ge | |
| ies | | tGeometries | |
| | | | |
|
| bool _bStatic; ///< \see IsStatic | | bool _bStatic; ///< \see IsStatic | |
| bool _bIsEnabled; ///< \see IsEnabled | | bool _bIsEnabled; ///< \see IsEnabled | |
| | | | |
|
| private: | | private: | |
| /// Sensitive variables that should not be modified. | | /// Sensitive variables that should not be modified. | |
| /// @name Private Link Variables | | /// @name Private Link Variables | |
| //@{ | | //@{ | |
|
| int _index; ///< \see GetIndex | | int _index; ///< \see GetIndex | |
| KinBodyWeakPtr _parent; ///< \see GetParent | | KinBodyWeakPtr _parent; ///< \see GetParent | |
| std::vector<int> _vParentLinks; ///< \see GetParentLinks, IsParentL | | std::vector<int> _vParentLinks; ///< \see GetParentLinks, I | |
| ink | | sParentLink | |
| std::vector<int> _vRigidlyAttachedLinks; ///< \see IsRigidlyAttache | | std::vector<int> _vRigidlyAttachedLinks; ///< \see IsRigidl | |
| d, GetRigidlyAttachedLinks | | yAttached, GetRigidlyAttachedLinks | |
| //@} | | //@} | |
| #ifdef RAVE_PRIVATE | | #ifdef RAVE_PRIVATE | |
| #ifdef _MSC_VER | | #ifdef _MSC_VER | |
| friend class ColladaReader; | | friend class ColladaReader; | |
| friend class OpenRAVEXMLParser::LinkXMLReader; | | friend class OpenRAVEXMLParser::LinkXMLReader; | |
| friend class OpenRAVEXMLParser::KinBodyXMLReader; | | friend class OpenRAVEXMLParser::KinBodyXMLReader; | |
| friend class OpenRAVEXMLParser::RobotXMLReader; | | friend class OpenRAVEXMLParser::RobotXMLReader; | |
| #else | | #else | |
| friend class ::ColladaReader; | | friend class ::ColladaReader; | |
| friend class ::OpenRAVEXMLParser::LinkXMLReader; | | friend class ::OpenRAVEXMLParser::LinkXMLReader; | |
| | | | |
| skipping to change at line 335 | | skipping to change at line 384 | |
| #endif | | #endif | |
| friend class KinBody; | | friend class KinBody; | |
| }; | | }; | |
| typedef boost::shared_ptr<KinBody::Link> LinkPtr; | | typedef boost::shared_ptr<KinBody::Link> LinkPtr; | |
| typedef boost::shared_ptr<KinBody::Link const> LinkConstPtr; | | typedef boost::shared_ptr<KinBody::Link const> LinkConstPtr; | |
| typedef boost::weak_ptr<KinBody::Link> LinkWeakPtr; | | typedef boost::weak_ptr<KinBody::Link> LinkWeakPtr; | |
| | | | |
| /// \brief Information about a joint that controls the relationship bet
ween two links. | | /// \brief Information about a joint that controls the relationship bet
ween two links. | |
| class OPENRAVE_API Joint : public boost::enable_shared_from_this<Joint> | | class OPENRAVE_API Joint : public boost::enable_shared_from_this<Joint> | |
| { | | { | |
|
| public: | | public: | |
| /** \brief The type of joint movement. | | /** \brief The type of joint movement. | |
| | | | |
| Non-special joints that are combinations of revolution and pris
matic joints. | | Non-special joints that are combinations of revolution and pris
matic joints. | |
| The first 4 bits specify the joint DOF, the next bits specify w
hether the joint is revolute (0) or prismatic (1). | | The first 4 bits specify the joint DOF, the next bits specify w
hether the joint is revolute (0) or prismatic (1). | |
| There can be also special joint types that are valid if the Joi
ntSpecialBit is set. | | There can be also special joint types that are valid if the Joi
ntSpecialBit is set. | |
| | | | |
| For multi-dof joints, the order is transform(parentlink) * tran
sform(axis0) * transform(axis1) ... | | For multi-dof joints, the order is transform(parentlink) * tran
sform(axis0) * transform(axis1) ... | |
|
| */ | | */ | |
| enum JointType { | | enum JointType { | |
| JointNone = 0, | | JointNone = 0, | |
| JointHinge = 0x01, | | JointHinge = 0x01, | |
| JointRevolute = 0x01, | | JointRevolute = 0x01, | |
| JointSlider = 0x11, | | JointSlider = 0x11, | |
| JointPrismatic = 0x11, | | JointPrismatic = 0x11, | |
| JointRR = 0x02, | | JointRR = 0x02, | |
| JointRP = 0x12, | | JointRP = 0x12, | |
| JointPR = 0x22, | | JointPR = 0x22, | |
| JointPP = 0x32, | | JointPP = 0x32, | |
| JointSpecialBit = 0x80000000, | | JointSpecialBit = 0x80000000, | |
| JointUniversal = 0x80000001, | | JointUniversal = 0x80000001, | |
| JointHinge2 = 0x80000002, | | JointHinge2 = 0x80000002, | |
| JointSpherical = 0x80000003, | | JointSpherical = 0x80000003, | |
| }; | | }; | |
| | | | |
| Joint(KinBodyPtr parent); | | Joint(KinBodyPtr parent); | |
| virtual ~Joint(); | | virtual ~Joint(); | |
| | | | |
| /// \brief The unique name of the joint | | /// \brief The unique name of the joint | |
|
| inline const std::string& GetName() const { return _name; } | | inline const std::string& GetName() const { | |
| | | return _name; | |
| | | } | |
| | | | |
|
| inline dReal GetMaxVel(int iaxis=0) const { return _vmaxvel[iaxis]; | | inline dReal GetMaxVel(int iaxis=0) const { | |
| } | | return _vmaxvel[iaxis]; | |
| inline dReal GetMaxAccel(int iaxis=0) const { return _vmaxaccel[iax | | } | |
| is]; } | | inline dReal GetMaxAccel(int iaxis=0) const { | |
| inline dReal GetMaxTorque(int iaxis=0) const { return _vmaxtorque[i | | return _vmaxaccel[iaxis]; | |
| axis]; } | | } | |
| | | inline dReal GetMaxTorque(int iaxis=0) const { | |
| | | return _vmaxtorque[iaxis]; | |
| | | } | |
| | | | |
| /// \brief Get the degree of freedom index in the body's DOF array. | | /// \brief Get the degree of freedom index in the body's DOF array. | |
| /// | | /// | |
| /// This does not index in KinBody::GetJoints() directly! In other
words, KinBody::GetDOFValues()[GetDOFIndex()] == GetValues()[0] | | /// This does not index in KinBody::GetJoints() directly! In other
words, KinBody::GetDOFValues()[GetDOFIndex()] == GetValues()[0] | |
|
| inline int GetDOFIndex() const { return dofindex; } | | inline int GetDOFIndex() const { | |
| | | return dofindex; | |
| | | } | |
| | | | |
| /// \brief Get the joint index into KinBody::GetJoints. | | /// \brief Get the joint index into KinBody::GetJoints. | |
|
| inline int GetJointIndex() const { return jointindex; } | | inline int GetJointIndex() const { | |
| | | return jointindex; | |
| | | } | |
| | | | |
|
| inline KinBodyPtr GetParent() const { return KinBodyPtr(_parent); } | | inline KinBodyPtr GetParent() const { | |
| | | return KinBodyPtr(_parent); | |
| | | } | |
| | | | |
|
| inline LinkPtr GetFirstAttached() const { return _attachedbodies[0] | | inline LinkPtr GetFirstAttached() const { | |
| ; } | | return _attachedbodies[0]; | |
| inline LinkPtr GetSecondAttached() const { return _attachedbodies[1 | | } | |
| ]; } | | inline LinkPtr GetSecondAttached() const { | |
| | | return _attachedbodies[1]; | |
| | | } | |
| | | | |
|
| inline JointType GetType() const { return _type; } | | inline JointType GetType() const { | |
| | | return _type; | |
| | | } | |
| | | | |
| /// \brief The discretization of the joint used when line-collision
checking. | | /// \brief The discretization of the joint used when line-collision
checking. | |
| /// | | /// | |
| /// The resolutions are set as large as possible such that the join
t will not go through obstacles of determined size. | | /// The resolutions are set as large as possible such that the join
t will not go through obstacles of determined size. | |
|
| inline dReal GetResolution() const { return fResolution; } | | inline dReal GetResolution() const { | |
| | | return fResolution; | |
| | | } | |
| virtual void SetResolution(dReal resolution); | | virtual void SetResolution(dReal resolution); | |
| | | | |
| /// \brief The degrees of freedom of the joint. Each joint supports
a max of 3 degrees of freedom. | | /// \brief The degrees of freedom of the joint. Each joint supports
a max of 3 degrees of freedom. | |
| virtual int GetDOF() const; | | virtual int GetDOF() const; | |
| | | | |
| /// \brief Return true if joint axis has an identification at some
of its lower and upper limits. | | /// \brief Return true if joint axis has an identification at some
of its lower and upper limits. | |
| /// | | /// | |
| /// An identification of the lower and upper limits means that once
the joint reaches its upper limits, it is also | | /// An identification of the lower and upper limits means that once
the joint reaches its upper limits, it is also | |
| /// at its lower limit. The most common identification on revolute
joints at -pi and pi. 'circularity' means the | | /// at its lower limit. The most common identification on revolute
joints at -pi and pi. 'circularity' means the | |
| /// joint does not stop at limits. | | /// joint does not stop at limits. | |
| /// Although currently not developed, it could be possible to suppo
rt identification for joints that are not revolute. | | /// Although currently not developed, it could be possible to suppo
rt identification for joints that are not revolute. | |
|
| virtual bool IsCircular(int iaxis) const { return _bIsCircular.at(i | | virtual bool IsCircular(int iaxis) const { | |
| axis); } | | return _bIsCircular.at(iaxis); | |
| | | } | |
| | | | |
| /// \brief returns true if the axis describes a rotation around an
axis. | | /// \brief returns true if the axis describes a rotation around an
axis. | |
| /// | | /// | |
| /// \param iaxis the axis of the joint to return the results for | | /// \param iaxis the axis of the joint to return the results for | |
| virtual bool IsRevolute(int iaxis) const; | | virtual bool IsRevolute(int iaxis) const; | |
| | | | |
| /// \brief returns true if the axis describes a translation around
an axis. | | /// \brief returns true if the axis describes a translation around
an axis. | |
| /// | | /// | |
| /// \param iaxis the axis of the joint to return the results for | | /// \param iaxis the axis of the joint to return the results for | |
| virtual bool IsPrismatic(int iaxis) const; | | virtual bool IsPrismatic(int iaxis) const; | |
| | | | |
| skipping to change at line 446 | | skipping to change at line 519 | |
| /// \brief The axis of the joint in global coordinates | | /// \brief The axis of the joint in global coordinates | |
| /// | | /// | |
| /// \param[in] axis the axis to get | | /// \param[in] axis the axis to get | |
| virtual Vector GetAxis(int axis = 0) const; | | virtual Vector GetAxis(int axis = 0) const; | |
| | | | |
| /** \brief Returns the limits of the joint | | /** \brief Returns the limits of the joint | |
| | | | |
| \param[out] vLowerLimit the lower limits | | \param[out] vLowerLimit the lower limits | |
| \param[out] vUpperLimit the upper limits | | \param[out] vUpperLimit the upper limits | |
| \param[in] bAppend if true will append to the end of the vector
instead of erasing it | | \param[in] bAppend if true will append to the end of the vector
instead of erasing it | |
|
| */ | | */ | |
| virtual void GetLimits(std::vector<dReal>& vLowerLimit, std::vector
<dReal>& vUpperLimit, bool bAppend=false) const; | | virtual void GetLimits(std::vector<dReal>& vLowerLimit, std::vector
<dReal>& vUpperLimit, bool bAppend=false) const; | |
| | | | |
| /// \brief \see GetLimits | | /// \brief \see GetLimits | |
| virtual void SetLimits(const std::vector<dReal>& lower, const std::
vector<dReal>& upper); | | virtual void SetLimits(const std::vector<dReal>& lower, const std::
vector<dReal>& upper); | |
| | | | |
| /// \deprecated (11/1/1) | | /// \deprecated (11/1/1) | |
|
| virtual void SetJointLimits(const std::vector<dReal>& lower, const | | virtual void SetJointLimits(const std::vector<dReal>& lower, const | |
| std::vector<dReal>& upper) RAVE_DEPRECATED { SetLimits(lower,upper); } | | std::vector<dReal>& upper) RAVE_DEPRECATED { | |
| | | SetLimits(lower,upper); | |
| | | } | |
| | | | |
| /** \brief Returns the max velocities of the joint | | /** \brief Returns the max velocities of the joint | |
| | | | |
| \param[out] vlower the lower velocity limits | | \param[out] vlower the lower velocity limits | |
| \param[out] vupper the lower velocity limits | | \param[out] vupper the lower velocity limits | |
| \param[in] bAppend if true will append to the end of the vector
instead of erasing it | | \param[in] bAppend if true will append to the end of the vector
instead of erasing it | |
|
| */ | | */ | |
| virtual void GetVelocityLimits(std::vector<dReal>& vlower, std::vec
tor<dReal>& vupper, bool bAppend=false) const; | | virtual void GetVelocityLimits(std::vector<dReal>& vlower, std::vec
tor<dReal>& vupper, bool bAppend=false) const; | |
| | | | |
| /// \brief \see GetVelocityLimits | | /// \brief \see GetVelocityLimits | |
| virtual void SetVelocityLimits(const std::vector<dReal>& vmaxvel); | | virtual void SetVelocityLimits(const std::vector<dReal>& vmaxvel); | |
| | | | |
| /// \brief The weight associated with a joint's axis for computing
a distance in the robot configuration space. | | /// \brief The weight associated with a joint's axis for computing
a distance in the robot configuration space. | |
| virtual dReal GetWeight(int axis=0) const; | | virtual dReal GetWeight(int axis=0) const; | |
| /// \brief \see GetWeight | | /// \brief \see GetWeight | |
| virtual void SetWeights(const std::vector<dReal>& weights); | | virtual void SetWeights(const std::vector<dReal>& weights); | |
| | | | |
| /// \brief Return internal offset parameter that determines the bra
nch the angle centers on | | /// \brief Return internal offset parameter that determines the bra
nch the angle centers on | |
| /// | | /// | |
| /// Wrap offsets are needed for rotation joints since the range is
limited to 2*pi. | | /// Wrap offsets are needed for rotation joints since the range is
limited to 2*pi. | |
| /// This allows the wrap offset to be set so the joint can function
in [-pi+offset,pi+offset].. | | /// This allows the wrap offset to be set so the joint can function
in [-pi+offset,pi+offset].. | |
| /// \param iaxis the axis to get the offset from | | /// \param iaxis the axis to get the offset from | |
|
| inline dReal GetWrapOffset(int iaxis=0) const { return _voffsets.at | | inline dReal GetWrapOffset(int iaxis=0) const { | |
| (iaxis); } | | return _voffsets.at(iaxis); | |
| | | } | |
| | | | |
|
| inline dReal GetOffset(int iaxis=0) const RAVE_DEPRECATED { return | | inline dReal GetOffset(int iaxis=0) const RAVE_DEPRECATED { | |
| GetWrapOffset(iaxis); } | | return GetWrapOffset(iaxis); | |
| | | } | |
| | | | |
| /// \brief \see GetWrapOffset | | /// \brief \see GetWrapOffset | |
| virtual void SetWrapOffset(dReal offset, int iaxis=0); | | virtual void SetWrapOffset(dReal offset, int iaxis=0); | |
| /// \deprecated (11/1/16) | | /// \deprecated (11/1/16) | |
|
| virtual void SetOffset(dReal offset, int iaxis=0) RAVE_DEPRECATED { | | virtual void SetOffset(dReal offset, int iaxis=0) RAVE_DEPRECATED { | |
| SetWrapOffset(offset,iaxis); } | | SetWrapOffset(offset,iaxis); | |
| | | } | |
| | | | |
| virtual void serialize(std::ostream& o, int options) const; | | virtual void serialize(std::ostream& o, int options) const; | |
| | | | |
| /// @name Internal Hierarchy Methods | | /// @name Internal Hierarchy Methods | |
| //@{ | | //@{ | |
| /// \brief Return the parent link which the joint measures its angl
e off from (either GetFirstAttached() or GetSecondAttached()) | | /// \brief Return the parent link which the joint measures its angl
e off from (either GetFirstAttached() or GetSecondAttached()) | |
| virtual LinkPtr GetHierarchyParentLink() const; | | virtual LinkPtr GetHierarchyParentLink() const; | |
| /// \brief Return the child link whose transformation is computed b
y this joint's values (either GetFirstAttached() or GetSecondAttached()) | | /// \brief Return the child link whose transformation is computed b
y this joint's values (either GetFirstAttached() or GetSecondAttached()) | |
| virtual LinkPtr GetHierarchyChildLink() const; | | virtual LinkPtr GetHierarchyChildLink() const; | |
| /// \deprecated (11/1/27) | | /// \deprecated (11/1/27) | |
| | | | |
| skipping to change at line 527 | | skipping to change at line 608 | |
| | | | |
| /** \brief If the joint is mimic, returns the equation to compute i
ts value | | /** \brief If the joint is mimic, returns the equation to compute i
ts value | |
| | | | |
| \param[in] axis the axis index | | \param[in] axis the axis index | |
| \param[in] type 0 for position, 1 for velocity, 2 for accelerat
ion. | | \param[in] type 0 for position, 1 for velocity, 2 for accelerat
ion. | |
| \param[in] format the format the equations are returned in. If
empty or "fparser", equation in fparser format. Also supports: "mathml". | | \param[in] format the format the equations are returned in. If
empty or "fparser", equation in fparser format. Also supports: "mathml". | |
| | | | |
| MathML: | | MathML: | |
| | | | |
| Set 'format' to "mathml". The joint variables are specified wit
h <csymbol>. If a targetted joint has more than one degree of freedom, then
axis is suffixed with _\%d. If 'type' is 1 or 2, the partial derivatives a
re outputted as consecutive <math></math> tags in the same order as \ref MI
MIC::_vdofformat | | Set 'format' to "mathml". The joint variables are specified wit
h <csymbol>. If a targetted joint has more than one degree of freedom, then
axis is suffixed with _\%d. If 'type' is 1 or 2, the partial derivatives a
re outputted as consecutive <math></math> tags in the same order as \ref MI
MIC::_vdofformat | |
|
| */ | | */ | |
| std::string GetMimicEquation(int axis=0, int type=0, const std::str
ing& format="") const; | | std::string GetMimicEquation(int axis=0, int type=0, const std::str
ing& format="") const; | |
| | | | |
| /** \brief Returns the set of DOF indices that the computation of a
joint axis depends on. Order is arbitrary. | | /** \brief Returns the set of DOF indices that the computation of a
joint axis depends on. Order is arbitrary. | |
| | | | |
| If the mimic joint uses the values of other mimic joints, then
the dependent DOFs of that joint are also | | If the mimic joint uses the values of other mimic joints, then
the dependent DOFs of that joint are also | |
| copied over. Therefore, the dof indices returned can be more th
an the actual variables used in the equation. | | copied over. Therefore, the dof indices returned can be more th
an the actual variables used in the equation. | |
| \throw openrave_exception Throws an exception if the axis is no
t mimic. | | \throw openrave_exception Throws an exception if the axis is no
t mimic. | |
|
| */ | | */ | |
| void GetMimicDOFIndices(std::vector<int>& vmimicdofs, int axis=0) c
onst; | | void GetMimicDOFIndices(std::vector<int>& vmimicdofs, int axis=0) c
onst; | |
| | | | |
| /** \brief Sets the mimic properties of the joint. | | /** \brief Sets the mimic properties of the joint. | |
| | | | |
| The equations can use the joint names directly in the equation,
which represent the position of the joint. Any non-mimic joint part of Kin
Body::GetJoints() can be used in the computation of the values. | | The equations can use the joint names directly in the equation,
which represent the position of the joint. Any non-mimic joint part of Kin
Body::GetJoints() can be used in the computation of the values. | |
| If a joint has more than one degree of freedom, then suffix it
'_' and the axis index. For example universaljoint_0 * 10 + sin(universaljo
int_1). | | If a joint has more than one degree of freedom, then suffix it
'_' and the axis index. For example universaljoint_0 * 10 + sin(universaljo
int_1). | |
| | | | |
| See http://warp.povusers.org/FunctionParser/fparser.html for a
full description of the equation formats. | | See http://warp.povusers.org/FunctionParser/fparser.html for a
full description of the equation formats. | |
| | | | |
| The velocity and acceleration equations are specified in terms
of partial derivatives, which means one expression needs to be specified pe
r degree of freedom of used. In order to separate the expressions use "|nam
e ...". The name should immediately follow '|'. For example: | | The velocity and acceleration equations are specified in terms
of partial derivatives, which means one expression needs to be specified pe
r degree of freedom of used. In order to separate the expressions use "|nam
e ...". The name should immediately follow '|'. For example: | |
| | | | |
|
| |universaljoint_0 10 |universaljoint_1 10*cos(universaljoint_1) | | |universaljoint_0 10 |universaljoint_1 10*cos(universaljoint_1) | |
| | | | |
| If there is only one variable used in the position equation, th
en the equation can be specified directly without using "{}". | | If there is only one variable used in the position equation, th
en the equation can be specified directly without using "{}". | |
| | | | |
| \param[in] axis the axis to set the properties for. | | \param[in] axis the axis to set the properties for. | |
| \param[in] poseq Equation for joint's position. If it is empty,
the mimic properties are turned off for this joint. | | \param[in] poseq Equation for joint's position. If it is empty,
the mimic properties are turned off for this joint. | |
| \param[in] veleq First-order partial derivatives of poseq with
respect to all used DOFs. Only the variables used in poseq are allowed to b
e used. If poseq is not empty, this is required. | | \param[in] veleq First-order partial derivatives of poseq with
respect to all used DOFs. Only the variables used in poseq are allowed to b
e used. If poseq is not empty, this is required. | |
| \param[in] acceleq Second-order partial derivatives of poseq wi
th respect to all used DOFs. Only the variables used in poseq are allowed t
o be used. Optional. | | \param[in] acceleq Second-order partial derivatives of poseq wi
th respect to all used DOFs. Only the variables used in poseq are allowed t
o be used. Optional. | |
| \throw openrave_exception Throws an exception if the mimic equa
tion is invalid in any way. | | \throw openrave_exception Throws an exception if the mimic equa
tion is invalid in any way. | |
|
| */ | | */ | |
| void SetMimicEquations(int axis, const std::string& poseq, const st
d::string& veleq, const std::string& acceleq=""); | | void SetMimicEquations(int axis, const std::string& poseq, const st
d::string& veleq, const std::string& acceleq=""); | |
| //@} | | //@} | |
| | | | |
|
| protected: | | protected: | |
| boost::array<Vector,3> _vaxes; ///< axes in body[0]'s or env | | boost::array<Vector,3> _vaxes; ///< axes in body[0]' | |
| ironment coordinate system used to define joint movement | | s or environment coordinate system used to define joint movement | |
| Vector vanchor; ///< anchor of the joint, this is only used | | Vector vanchor; ///< anchor of the joint, this is o | |
| to construct the internal left/right matrices | | nly used to construct the internal left/right matrices | |
| dReal fResolution; ///< interpolation resolution | | dReal fResolution; ///< interpolation resolution | |
| boost::array<dReal,3> _vmaxvel; ///< the soft maximum velo | | boost::array<dReal,3> _vmaxvel; ///< the soft maxi | |
| city (rad/s) to move the joint when planning | | mum velocity (rad/s) to move the joint when planning | |
| boost::array<dReal,3> fHardMaxVel; ///< the hard maximum veloc | | boost::array<dReal,3> fHardMaxVel; ///< the hard maxim | |
| ity, robot cannot exceed this velocity. used for verification checking | | um velocity, robot cannot exceed this velocity. used for verification check | |
| boost::array<dReal,3> _vmaxaccel; ///< the maximum accelerat | | ing | |
| ion (rad/s^2) of the joint | | boost::array<dReal,3> _vmaxaccel; ///< the maximum a | |
| boost::array<dReal,3> _vmaxtorque; ///< maximum torque (N.m, | | cceleration (rad/s^2) of the joint | |
| kg m^2/s^2) that can be applied to the joint | | boost::array<dReal,3> _vmaxtorque; ///< maximum torqu | |
| boost::array<dReal,3> _vweights; ///< the weights of the joi | | e (N.m, kg m^2/s^2) that can be applied to the joint | |
| nt for computing distance metrics. | | boost::array<dReal,3> _vweights; ///< the weights of | |
| boost::array<dReal,3> _voffsets; ///< \see GetOffset | | the joint for computing distance metrics. | |
| boost::array<dReal,3> _vlowerlimit, _vupperlimit; ///< joint limits | | boost::array<dReal,3> _voffsets; ///< \see GetOff | |
| | | set | |
| | | boost::array<dReal,3> _vlowerlimit, _vupperlimit; ///< join | |
| | | t limits | |
| /// \brief Holds mimic information about position, velocity, and ac
celeration of one axis of the joint. | | /// \brief Holds mimic information about position, velocity, and ac
celeration of one axis of the joint. | |
| /// | | /// | |
| /// In every array, [0] is position, [1] is velocity, [2] is accele
ration. | | /// In every array, [0] is position, [1] is velocity, [2] is accele
ration. | |
| struct OPENRAVE_API MIMIC | | struct OPENRAVE_API MIMIC | |
| { | | { | |
| struct DOFFormat | | struct DOFFormat | |
| { | | { | |
|
| int16_t jointindex; ///< the index into the joints, if >= G | | int16_t jointindex; ///< the index into the joints, | |
| etJoints.size(), then points to the passive joints | | if >= GetJoints.size(), then points to the passive joints | |
| int16_t dofindex : 14; ///< if >= 0, then points to a DOF o | | int16_t dofindex : 14; ///< if >= 0, then points to | |
| f the robot that is NOT mimiced | | a DOF of the robot that is NOT mimiced | |
| uint8_t axis : 2; ///< the axis of the joint index | | uint8_t axis : 2; ///< the axis of the joint index | |
| bool operator <(const DOFFormat& r) const; | | bool operator <(const DOFFormat& r) const; | |
| bool operator ==(const DOFFormat& r) const; | | bool operator ==(const DOFFormat& r) const; | |
| boost::shared_ptr<Joint> GetJoint(KinBodyPtr parent) const; | | boost::shared_ptr<Joint> GetJoint(KinBodyPtr parent) const; | |
| boost::shared_ptr<Joint const> GetJoint(KinBodyConstPtr par
ent) const; | | boost::shared_ptr<Joint const> GetJoint(KinBodyConstPtr par
ent) const; | |
| }; | | }; | |
|
| std::vector< DOFFormat > _vdofformat; ///< the format of the va
lues the equation takes order is important. | | std::vector< DOFFormat > _vdofformat; ///< the format o
f the values the equation takes order is important. | |
| struct DOFHierarchy | | struct DOFHierarchy | |
| { | | { | |
|
| int16_t dofindex; ///< >=0 dof index | | int16_t dofindex; ///< >=0 dof index | |
| uint16_t dofformatindex; ///< index into _vdofformat to fol | | uint16_t dofformatindex; ///< index into _vdofforma | |
| low the computation | | t to follow the computation | |
| bool operator ==(const DOFHierarchy& r) const { return dofi | | bool operator ==(const DOFHierarchy& r) const { | |
| ndex==r.dofindex && dofformatindex == r.dofformatindex; } | | return dofindex==r.dofindex && dofformatindex == r.doff | |
| | | ormatindex; | |
| | | } | |
| }; | | }; | |
|
| std::vector<DOFHierarchy> _vmimicdofs; ///< all dof indices tha
t the equations depends on. DOFHierarchy::dofindex can repeat | | std::vector<DOFHierarchy> _vmimicdofs; ///< all dof ind
ices that the equations depends on. DOFHierarchy::dofindex can repeat | |
| boost::shared_ptr<FunctionParserBase<dReal> > _posfn; | | boost::shared_ptr<FunctionParserBase<dReal> > _posfn; | |
|
| std::vector<boost::shared_ptr<FunctionParserBase<dReal> > > _ve | | std::vector<boost::shared_ptr<FunctionParserBase<dReal> > > _ve | |
| lfns, _accelfns; ///< the velocity and acceleration partial derivatives wit | | lfns, _accelfns; ///< the velocity and acceleration partial derivat | |
| h respect to each of the values in _vdofformat | | ives with respect to each of the values in _vdofformat | |
| boost::array< std::string, 3> _equations; ///< the original eq | | boost::array< std::string, 3> _equations; ///< the ori | |
| uations | | ginal equations | |
| }; | | }; | |
|
| boost::array< boost::shared_ptr<MIMIC> ,3> _vmimic; ///< the mimic
properties of each of the joint axes. It is theoretically possible for a mu
lti-dof joint to have one axes mimiced and the others free. When cloning, i
s it ok to copy this and assume it is constant? | | boost::array< boost::shared_ptr<MIMIC>,3> _vmimic; ///< th
e mimic properties of each of the joint axes. It is theoretically possible
for a multi-dof joint to have one axes mimiced and the others free. When cl
oning, is it ok to copy this and assume it is constant? | |
| | | | |
| /** \brief computes the partial velocities with respect to all depe
ndent DOFs specified by MIMIC::_vmimicdofs. | | /** \brief computes the partial velocities with respect to all depe
ndent DOFs specified by MIMIC::_vmimicdofs. | |
| | | | |
| If the joint is not mimic, then just returns its own index | | If the joint is not mimic, then just returns its own index | |
| \param[out] vpartials A list of dofindex/velocity_partial pairs
. The final velocity is computed by taking the dot product. The dofindices
do not repeat. | | \param[out] vpartials A list of dofindex/velocity_partial pairs
. The final velocity is computed by taking the dot product. The dofindices
do not repeat. | |
| \param[in] iaxis the axis | | \param[in] iaxis the axis | |
| \param[in,out] vcachedpartials set of cached partials for each
degree of freedom | | \param[in,out] vcachedpartials set of cached partials for each
degree of freedom | |
|
| */ | | */ | |
| virtual void _ComputePartialVelocities(std::vector<std::pair<int,dR
eal> >& vpartials, int iaxis, std::map< std::pair<MIMIC::DOFFormat, int>, d
Real >& mapcachedpartials) const; | | virtual void _ComputePartialVelocities(std::vector<std::pair<int,dR
eal> >& vpartials, int iaxis, std::map< std::pair<MIMIC::DOFFormat, int>, d
Real >& mapcachedpartials) const; | |
| | | | |
| /** \brief Compute internal transformations and specify the attache
d links of the joint. | | /** \brief Compute internal transformations and specify the attache
d links of the joint. | |
| | | | |
| Called after the joint protected parameters {vAxes, vanchor, an
d _voffsets} have been initialized. vAxes and vanchor should be in the fra
me of plink0. | | Called after the joint protected parameters {vAxes, vanchor, an
d _voffsets} have been initialized. vAxes and vanchor should be in the fra
me of plink0. | |
| Compute the left and right multiplications of the joint transfo
rmation and cleans up the attached bodies. | | Compute the left and right multiplications of the joint transfo
rmation and cleans up the attached bodies. | |
| After function completes, the following parameters are initiali
zed: _tRight, _tLeft, _tinvRight, _tinvLeft, _attachedbodies. _attachedbodi
es does not necessarily contain the links in the same order as they were in
put. | | After function completes, the following parameters are initiali
zed: _tRight, _tLeft, _tinvRight, _tinvLeft, _attachedbodies. _attachedbodi
es does not necessarily contain the links in the same order as they were in
put. | |
| \param plink0 the first attaching link, all axes and anchors ar
e defined in its coordinate system | | \param plink0 the first attaching link, all axes and anchors ar
e defined in its coordinate system | |
| \param plink1 the second attaching link | | \param plink1 the second attaching link | |
| \param vanchor the anchor of the rotation axes | | \param vanchor the anchor of the rotation axes | |
| \param vaxes the axes in plink0's coordinate system of the join
ts | | \param vaxes the axes in plink0's coordinate system of the join
ts | |
| \param vinitialvalues the current values of the robot used to s
et the 0 offset of the robot | | \param vinitialvalues the current values of the robot used to s
et the 0 offset of the robot | |
|
| */ | | */ | |
| virtual void _ComputeInternalInformation(LinkPtr plink0, LinkPtr pl
ink1, const Vector& vanchor, const std::vector<Vector>& vaxes, const std::v
ector<dReal>& vcurrentvalues); | | virtual void _ComputeInternalInformation(LinkPtr plink0, LinkPtr pl
ink1, const Vector& vanchor, const std::vector<Vector>& vaxes, const std::v
ector<dReal>& vcurrentvalues); | |
| | | | |
|
| std::string _name; ///< \see GetName | | std::string _name; ///< \see GetName | |
| boost::array<bool,3> _bIsCircular; ///< \see IsCircular | | boost::array<bool,3> _bIsCircular; ///< \see IsCircular | |
| private: | | private: | |
| /// Sensitive variables that should not be modified. | | /// Sensitive variables that should not be modified. | |
| /// @name Private Joint Variables | | /// @name Private Joint Variables | |
| //@{ | | //@{ | |
|
| int dofindex; ///< the degree of freedom index in the bod | | int dofindex; ///< the degree of freedom index in | |
| y's DOF array, does not index in KinBody::_vecjoints! | | the body's DOF array, does not index in KinBody::_vecjoints! | |
| int jointindex; ///< the joint index into KinBody::_vecjoin | | int jointindex; ///< the joint index into KinBody:: | |
| ts | | _vecjoints | |
| JointType _type; | | JointType _type; | |
|
| bool _bActive; ///< if true, should belong to the DOF of th
e body, unless it is a mimic joint (_ComputeInternalInformation decides thi
s) | | bool _bActive; ///< if true, should belong to the D
OF of the body, unless it is a mimic joint (_ComputeInternalInformation dec
ides this) | |
| | | | |
|
| KinBodyWeakPtr _parent; ///< body that joint belong to | | KinBodyWeakPtr _parent; ///< body that joint belong t | |
| boost::array<LinkPtr,2> _attachedbodies; ///< attached bodies. The | | o | |
| link in [0] is computed first in the hierarchy before the other body. | | boost::array<LinkPtr,2> _attachedbodies; ///< attached bodi | |
| Transform _tRight, _tLeft;///< transforms used to get body[1]'s tra | | es. The link in [0] is computed first in the hierarchy before the other bod | |
| nsformation with respect to body[0]'s: Tbody1 = Tbody0 * tLeft * JointOffse | | y. | |
| tLeft * JointRotation * JointOffsetRight * tRight | | Transform _tRight, _tLeft; ///< transforms used to get body | |
| Transform _tRightNoOffset, _tLeftNoOffset; ///< same as _tLeft and | | [1]'s transformation with respect to body[0]'s: Tbody1 = Tbody0 * tLeft * J | |
| _tRight except it doesn't not include the offset | | ointOffsetLeft * JointRotation * JointOffsetRight * tRight | |
| Transform _tinvRight, _tinvLeft; ///< the inverse transformations o | | Transform _tRightNoOffset, _tLeftNoOffset; ///< same as _tL | |
| f tRight and tLeft | | eft and _tRight except it doesn't not include the offset | |
| | | Transform _tinvRight, _tinvLeft; ///< the inverse transform | |
| | | ations of tRight and tLeft | |
| bool _bInitialized; | | bool _bInitialized; | |
| //@} | | //@} | |
| #ifdef RAVE_PRIVATE | | #ifdef RAVE_PRIVATE | |
| #ifdef _MSC_VER | | #ifdef _MSC_VER | |
| friend class ColladaReader; | | friend class ColladaReader; | |
| friend class ColladaWriter; | | friend class ColladaWriter; | |
| friend class OpenRAVEXMLParser::JointXMLReader; | | friend class OpenRAVEXMLParser::JointXMLReader; | |
| friend class OpenRAVEXMLParser::KinBodyXMLReader; | | friend class OpenRAVEXMLParser::KinBodyXMLReader; | |
| friend class OpenRAVEXMLParser::RobotXMLReader; | | friend class OpenRAVEXMLParser::RobotXMLReader; | |
| #else | | #else | |
| | | | |
| skipping to change at line 664 | | skipping to change at line 747 | |
| #endif | | #endif | |
| friend class KinBody; | | friend class KinBody; | |
| }; | | }; | |
| typedef boost::shared_ptr<KinBody::Joint> JointPtr; | | typedef boost::shared_ptr<KinBody::Joint> JointPtr; | |
| typedef boost::shared_ptr<KinBody::Joint const> JointConstPtr; | | typedef boost::shared_ptr<KinBody::Joint const> JointConstPtr; | |
| typedef boost::weak_ptr<KinBody::Joint> JointWeakPtr; | | typedef boost::weak_ptr<KinBody::Joint> JointWeakPtr; | |
| | | | |
| /// \brief Stores the state of the current body that is published in a
thread safe way from the environment without requiring locking the environm
ent. | | /// \brief Stores the state of the current body that is published in a
thread safe way from the environment without requiring locking the environm
ent. | |
| class BodyState | | class BodyState | |
| { | | { | |
|
| public: | | public: | |
| BodyState() : environmentid(0){} | | BodyState() : environmentid(0){ | |
| virtual ~BodyState() {} | | } | |
| | | virtual ~BodyState() { | |
| | | } | |
| KinBodyPtr pbody; | | KinBodyPtr pbody; | |
| std::vector<RaveTransform<dReal> > vectrans; | | std::vector<RaveTransform<dReal> > vectrans; | |
| std::vector<dReal> jointvalues; | | std::vector<dReal> jointvalues; | |
| UserDataPtr pguidata, puserdata; | | UserDataPtr pguidata, puserdata; | |
|
| std::string strname; ///< name of the body | | std::string strname; ///< name of the body | |
| int environmentid; | | int environmentid; | |
| }; | | }; | |
| typedef boost::shared_ptr<KinBody::BodyState> BodyStatePtr; | | typedef boost::shared_ptr<KinBody::BodyState> BodyStatePtr; | |
| typedef boost::shared_ptr<KinBody::BodyState const> BodyStateConstPtr; | | typedef boost::shared_ptr<KinBody::BodyState const> BodyStateConstPtr; | |
| | | | |
| /// \brief Access point of the sensor system that manages the body. | | /// \brief Access point of the sensor system that manages the body. | |
| class OPENRAVE_API ManageData : public boost::enable_shared_from_this<M
anageData> | | class OPENRAVE_API ManageData : public boost::enable_shared_from_this<M
anageData> | |
| { | | { | |
|
| public: | | public: | |
| ManageData(SensorSystemBasePtr psensorsystem) : _psensorsystem(psensors | | ManageData(SensorSystemBasePtr psensorsystem) : _psensorsystem(psen | |
| ystem) {} | | sorsystem) { | |
| virtual ~ManageData() {} | | } | |
| | | virtual ~ManageData() { | |
| | | } | |
| | | | |
|
| virtual SensorSystemBasePtr GetSystem() { return SensorSystemBasePt | | virtual SensorSystemBasePtr GetSystem() { | |
| r(_psensorsystem); } | | return SensorSystemBasePtr(_psensorsystem); | |
| | | } | |
| | | | |
| /// returns a pointer to the data used to initialize the BODY with
AddKinBody. | | /// returns a pointer to the data used to initialize the BODY with
AddKinBody. | |
| /// if psize is not NULL, will be filled with the size of the data
in bytes | | /// if psize is not NULL, will be filled with the size of the data
in bytes | |
| /// This function will be used to restore bodies that were removed | | /// This function will be used to restore bodies that were removed | |
| virtual XMLReadableConstPtr GetData() const = 0; | | virtual XMLReadableConstPtr GetData() const = 0; | |
| | | | |
| /// particular link that sensor system is tracking. | | /// particular link that sensor system is tracking. | |
| /// All transformations describe this link. | | /// All transformations describe this link. | |
| virtual KinBody::LinkPtr GetOffsetLink() const = 0; | | virtual KinBody::LinkPtr GetOffsetLink() const = 0; | |
| | | | |
| | | | |
| skipping to change at line 707 | | skipping to change at line 796 | |
| | | | |
| /// true if should update openrave body | | /// true if should update openrave body | |
| virtual bool IsEnabled() const = 0; | | virtual bool IsEnabled() const = 0; | |
| | | | |
| /// if true, the vision system should not destroy this object once
it stops being present | | /// if true, the vision system should not destroy this object once
it stops being present | |
| virtual bool IsLocked() const = 0; | | virtual bool IsLocked() const = 0; | |
| | | | |
| /// set a lock on a particular body | | /// set a lock on a particular body | |
| virtual bool Lock(bool bDoLock) = 0; | | virtual bool Lock(bool bDoLock) = 0; | |
| | | | |
|
| private: | | private: | |
| /// the system that owns this class, note that it is a weak pointer
in order because | | /// the system that owns this class, note that it is a weak pointer
in order because | |
| /// this object is managed by the sensor system and should be delet
ed when it goes out of scope. | | /// this object is managed by the sensor system and should be delet
ed when it goes out of scope. | |
| SensorSystemBaseWeakPtr _psensorsystem; | | SensorSystemBaseWeakPtr _psensorsystem; | |
| }; | | }; | |
| | | | |
| typedef boost::shared_ptr<KinBody::ManageData> ManageDataPtr; | | typedef boost::shared_ptr<KinBody::ManageData> ManageDataPtr; | |
| typedef boost::shared_ptr<KinBody::ManageData const> ManageDataConstPtr
; | | typedef boost::shared_ptr<KinBody::ManageData const> ManageDataConstPtr
; | |
| | | | |
| /// \brief Parameters passed into the state savers to control what info
rmation gets saved. | | /// \brief Parameters passed into the state savers to control what info
rmation gets saved. | |
| enum SaveParameters | | enum SaveParameters | |
| { | | { | |
|
| Save_LinkTransformation=0x00000001, ///< [default] save link transf | | Save_LinkTransformation=0x00000001, ///< [default] save link tr | |
| ormations | | ansformations | |
| Save_LinkEnable=0x00000002, ///< [default] save link enable states | | Save_LinkEnable=0x00000002, ///< [default] save link enable sta | |
| Save_LinkVelocities=0x00000004, ///< save the link velocities | | tes | |
| Save_ActiveDOF=0x00010000, ///< [robot only], saves and restores th | | Save_LinkVelocities=0x00000004, ///< save the link velocities | |
| e current active degrees of freedom | | Save_ActiveDOF=0x00010000, ///< [robot only], saves and restore | |
| Save_ActiveManipulator=0x00020000, ///< [robot only], saves the act | | s the current active degrees of freedom | |
| ive manipulator | | Save_ActiveManipulator=0x00020000, ///< [robot only], saves the | |
| Save_GrabbedBodies=0x00040000, ///< [robot only], saves the grabbed | | active manipulator | |
| state of the bodies. This does not affect the configuraiton of those bodie | | Save_GrabbedBodies=0x00040000, ///< [robot only], saves the gra | |
| s. | | bbed state of the bodies. This does not affect the configuraiton of those b | |
| | | odies. | |
| }; | | }; | |
| | | | |
| /// \brief Helper class to save and restore the entire kinbody state. | | /// \brief Helper class to save and restore the entire kinbody state. | |
| /// | | /// | |
| /// Options can be passed to the constructor in order to choose which p
arameters to save (see \ref SaveParameters) | | /// Options can be passed to the constructor in order to choose which p
arameters to save (see \ref SaveParameters) | |
| class OPENRAVE_API KinBodyStateSaver | | class OPENRAVE_API KinBodyStateSaver | |
| { | | { | |
|
| public: | | public: | |
| KinBodyStateSaver(KinBodyPtr pbody, int options = Save_LinkTransfor
mation|Save_LinkEnable); | | KinBodyStateSaver(KinBodyPtr pbody, int options = Save_LinkTransfor
mation|Save_LinkEnable); | |
| virtual ~KinBodyStateSaver(); | | virtual ~KinBodyStateSaver(); | |
|
| protected: | | protected: | |
| int _options; ///< saved options | | int _options; ///< saved options | |
| std::vector<Transform> _vLinkTransforms; | | std::vector<Transform> _vLinkTransforms; | |
| std::vector<uint8_t> _vEnabledLinks; | | std::vector<uint8_t> _vEnabledLinks; | |
| std::vector<std::pair<Vector,Vector> > _vLinkVelocities; | | std::vector<std::pair<Vector,Vector> > _vLinkVelocities; | |
| KinBodyPtr _pbody; | | KinBodyPtr _pbody; | |
| }; | | }; | |
| | | | |
| virtual ~KinBody(); | | virtual ~KinBody(); | |
| | | | |
| /// return the static interface type this class points to (used for saf
e casting) | | /// return the static interface type this class points to (used for saf
e casting) | |
|
| static inline InterfaceType GetInterfaceTypeStatic() { return PT_KinBod | | static inline InterfaceType GetInterfaceTypeStatic() { | |
| y; } | | return PT_KinBody; | |
| | | } | |
| | | | |
| virtual void Destroy(); | | virtual void Destroy(); | |
| | | | |
| /// \deprecated (11/02/18) \see EnvironmentBase::ReadKinBodyXMLFile | | /// \deprecated (11/02/18) \see EnvironmentBase::ReadKinBodyXMLFile | |
| virtual bool InitFromFile(const std::string& filename, const Attributes
List& atts = AttributesList()) RAVE_DEPRECATED; | | virtual bool InitFromFile(const std::string& filename, const Attributes
List& atts = AttributesList()) RAVE_DEPRECATED; | |
| /// \deprecated (11/02/18) \see EnvironmentBase::ReadKinBodyXMLData | | /// \deprecated (11/02/18) \see EnvironmentBase::ReadKinBodyXMLData | |
| virtual bool InitFromData(const std::string& data, const AttributesList
& atts = AttributesList()) RAVE_DEPRECATED; | | virtual bool InitFromData(const std::string& data, const AttributesList
& atts = AttributesList()) RAVE_DEPRECATED; | |
| | | | |
| /// \brief Create a kinbody with one link composed of an array of align
ed bounding boxes. | | /// \brief Create a kinbody with one link composed of an array of align
ed bounding boxes. | |
| /// | | /// | |
| | | | |
| skipping to change at line 779 | | skipping to change at line 870 | |
| /// \param vspheres the XYZ position of the spheres with the W coordina
te representing the individual radius | | /// \param vspheres the XYZ position of the spheres with the W coordina
te representing the individual radius | |
| virtual bool InitFromSpheres(const std::vector<Vector>& vspheres, bool
draw); | | virtual bool InitFromSpheres(const std::vector<Vector>& vspheres, bool
draw); | |
| | | | |
| /// \brief Create a kinbody with one link composed of a triangle mesh s
urface | | /// \brief Create a kinbody with one link composed of a triangle mesh s
urface | |
| /// | | /// | |
| /// \param trimesh the triangle mesh | | /// \param trimesh the triangle mesh | |
| /// \param bDraw if true, will be rendered in the scene | | /// \param bDraw if true, will be rendered in the scene | |
| virtual bool InitFromTrimesh(const Link::TRIMESH& trimesh, bool draw); | | virtual bool InitFromTrimesh(const Link::TRIMESH& trimesh, bool draw); | |
| | | | |
| /// \brief Unique name of the robot. | | /// \brief Unique name of the robot. | |
|
| virtual const std::string& GetName() const { return _name; } | | virtual const std::string& GetName() const { | |
| | | return _name; | |
| | | } | |
| | | | |
| /// \brief Set the name of the robot, notifies the environment and chec
ks for uniqueness. | | /// \brief Set the name of the robot, notifies the environment and chec
ks for uniqueness. | |
| virtual void SetName(const std::string& name); | | virtual void SetName(const std::string& name); | |
| | | | |
| /// Methods for accessing basic information about joints | | /// Methods for accessing basic information about joints | |
| /// @name Basic Information | | /// @name Basic Information | |
| //@{ | | //@{ | |
| | | | |
| /// \brief Number controllable degrees of freedom of the body. | | /// \brief Number controllable degrees of freedom of the body. | |
| /// | | /// | |
| | | | |
| skipping to change at line 802 | | skipping to change at line 895 | |
| | | | |
| /// \brief Returns all the joint values as organized by the DOF indices
. | | /// \brief Returns all the joint values as organized by the DOF indices
. | |
| virtual void GetDOFValues(std::vector<dReal>& v) const; | | virtual void GetDOFValues(std::vector<dReal>& v) const; | |
| /// \brief Returns all the joint velocities as organized by the DOF ind
ices. | | /// \brief Returns all the joint velocities as organized by the DOF ind
ices. | |
| virtual void GetDOFVelocities(std::vector<dReal>& v) const; | | virtual void GetDOFVelocities(std::vector<dReal>& v) const; | |
| /// \brief Returns all the joint limits as organized by the DOF indices
. | | /// \brief Returns all the joint limits as organized by the DOF indices
. | |
| virtual void GetDOFLimits(std::vector<dReal>& vLowerLimit, std::vector<
dReal>& vUpperLimit) const; | | virtual void GetDOFLimits(std::vector<dReal>& vLowerLimit, std::vector<
dReal>& vUpperLimit) const; | |
| /// \brief Returns all the joint velocity limits as organized by the DO
F indices. | | /// \brief Returns all the joint velocity limits as organized by the DO
F indices. | |
| virtual void GetDOFVelocityLimits(std::vector<dReal>& vLowerLimit, std:
:vector<dReal>& vUpperLimit) const; | | virtual void GetDOFVelocityLimits(std::vector<dReal>& vLowerLimit, std:
:vector<dReal>& vUpperLimit) const; | |
| /// \deprecated (11/05/26) | | /// \deprecated (11/05/26) | |
|
| virtual void GetDOFMaxVel(std::vector<dReal>& v) const RAVE_DEPRECATED | | virtual void GetDOFMaxVel(std::vector<dReal>& v) const RAVE_DEPRECATED | |
| { std::vector<dReal> dummy; GetDOFVelocityLimits(dummy,v); } | | { | |
| | | std::vector<dReal> dummy; GetDOFVelocityLimits(dummy,v); | |
| | | } | |
| virtual void GetDOFMaxAccel(std::vector<dReal>& v) const; | | virtual void GetDOFMaxAccel(std::vector<dReal>& v) const; | |
| virtual void GetDOFMaxTorque(std::vector<dReal>& v) const; | | virtual void GetDOFMaxTorque(std::vector<dReal>& v) const; | |
| virtual void GetDOFResolutions(std::vector<dReal>& v) const; | | virtual void GetDOFResolutions(std::vector<dReal>& v) const; | |
| virtual void GetDOFWeights(std::vector<dReal>& v) const; | | virtual void GetDOFWeights(std::vector<dReal>& v) const; | |
| | | | |
| /// \deprecated Returns all the joint values in the order of GetJoints(
) (use GetDOFValues instead) (10/07/10) | | /// \deprecated Returns all the joint values in the order of GetJoints(
) (use GetDOFValues instead) (10/07/10) | |
|
| virtual void GetJointValues(std::vector<dReal>& v) const RAVE_DEPRECATE | | virtual void GetJointValues(std::vector<dReal>& v) const RAVE_DEPRECATE | |
| D { GetDOFValues(v); } | | D { | |
| virtual void GetJointVelocities(std::vector<dReal>& v) const RAVE_DEPRE | | GetDOFValues(v); | |
| CATED { GetDOFVelocities(v); } | | } | |
| virtual void GetJointLimits(std::vector<dReal>& vLowerLimit, std::vecto | | virtual void GetJointVelocities(std::vector<dReal>& v) const RAVE_DEPRE | |
| r<dReal>& vUpperLimit) const RAVE_DEPRECATED { GetDOFLimits(vLowerLimit,vUp | | CATED { | |
| perLimit); } | | GetDOFVelocities(v); | |
| virtual void GetJointMaxVel(std::vector<dReal>& v) const RAVE_DEPRECATE | | } | |
| D { std::vector<dReal> dummy; GetDOFVelocityLimits(dummy,v); } | | virtual void GetJointLimits(std::vector<dReal>& vLowerLimit, std::vecto | |
| virtual void GetJointMaxAccel(std::vector<dReal>& v) const RAVE_DEPRECA | | r<dReal>& vUpperLimit) const RAVE_DEPRECATED { | |
| TED { GetDOFMaxAccel(v); } | | GetDOFLimits(vLowerLimit,vUpperLimit); | |
| virtual void GetJointMaxTorque(std::vector<dReal>& v) const RAVE_DEPREC | | } | |
| ATED { GetDOFMaxTorque(v); } | | virtual void GetJointMaxVel(std::vector<dReal>& v) const RAVE_DEPRECATE | |
| virtual void GetJointResolutions(std::vector<dReal>& v) const RAVE_DEPR | | D { | |
| ECATED { GetDOFResolutions(v); } | | std::vector<dReal> dummy; GetDOFVelocityLimits(dummy,v); | |
| virtual void GetJointWeights(std::vector<dReal>& v) const RAVE_DEPRECAT | | } | |
| ED { GetDOFWeights(v); } | | virtual void GetJointMaxAccel(std::vector<dReal>& v) const RAVE_DEPRECA | |
| | | TED { | |
| | | GetDOFMaxAccel(v); | |
| | | } | |
| | | virtual void GetJointMaxTorque(std::vector<dReal>& v) const RAVE_DEPREC | |
| | | ATED { | |
| | | GetDOFMaxTorque(v); | |
| | | } | |
| | | virtual void GetJointResolutions(std::vector<dReal>& v) const RAVE_DEPR | |
| | | ECATED { | |
| | | GetDOFResolutions(v); | |
| | | } | |
| | | virtual void GetJointWeights(std::vector<dReal>& v) const RAVE_DEPRECAT | |
| | | ED { | |
| | | GetDOFWeights(v); | |
| | | } | |
| | | | |
| /// \brief Returns the joints making up the controllable degrees of fre
edom of the body. | | /// \brief Returns the joints making up the controllable degrees of fre
edom of the body. | |
|
| const std::vector<JointPtr>& GetJoints() const { return _vecjoints; } | | const std::vector<JointPtr>& GetJoints() const { | |
| | | return _vecjoints; | |
| | | } | |
| | | | |
| /** \brief Returns the passive joints, order does not matter. | | /** \brief Returns the passive joints, order does not matter. | |
| | | | |
| A passive joint is not directly controlled by the body's degrees of
freedom so it has no | | A passive joint is not directly controlled by the body's degrees of
freedom so it has no | |
| joint index and no dof index. Passive joints allows mimic joints to
be hidden from the users. | | joint index and no dof index. Passive joints allows mimic joints to
be hidden from the users. | |
| However, there are cases when passive joints are not mimic; for exa
mple, suspension mechanism on vehicles. | | However, there are cases when passive joints are not mimic; for exa
mple, suspension mechanism on vehicles. | |
|
| */ | | */ | |
| const std::vector<JointPtr>& GetPassiveJoints() const { return _vPassiv | | const std::vector<JointPtr>& GetPassiveJoints() const { | |
| eJoints; } | | return _vPassiveJoints; | |
| | | } | |
| | | | |
| /// \deprecated \see Link::GetRigidlyAttachedLinks (10/12/12) | | /// \deprecated \see Link::GetRigidlyAttachedLinks (10/12/12) | |
| virtual void GetRigidlyAttachedLinks(int linkindex, std::vector<LinkPtr
>& vattachedlinks) const RAVE_DEPRECATED; | | virtual void GetRigidlyAttachedLinks(int linkindex, std::vector<LinkPtr
>& vattachedlinks) const RAVE_DEPRECATED; | |
| | | | |
| /// \brief Returns the joints in hierarchical order starting at the bas
e link. | | /// \brief Returns the joints in hierarchical order starting at the bas
e link. | |
| /// | | /// | |
| /// In the case of closed loops, the joints are returned in the order c
losest to the root. | | /// In the case of closed loops, the joints are returned in the order c
losest to the root. | |
| /// All the joints affecting a particular joint's transformation will a
lways come before the joint in the list. | | /// All the joints affecting a particular joint's transformation will a
lways come before the joint in the list. | |
| virtual const std::vector<JointPtr>& GetDependencyOrderedJoints() const
; | | virtual const std::vector<JointPtr>& GetDependencyOrderedJoints() const
; | |
| | | | |
| /** \brief Return the set of unique closed loops of the kinematics hier
archy. | | /** \brief Return the set of unique closed loops of the kinematics hier
archy. | |
| | | | |
| Each loop is a set of link indices and joint indices. For example,
a loop of link indices: | | Each loop is a set of link indices and joint indices. For example,
a loop of link indices: | |
| [l_0,l_1,l_2] will consist of three joints connecting l_0 to l_1, l
_1 to l_2, and l_2 to l_0. | | [l_0,l_1,l_2] will consist of three joints connecting l_0 to l_1, l
_1 to l_2, and l_2 to l_0. | |
| The first element in the pair is the link l_X, the second element i
n the joint connecting l_X to l_(X+1). | | The first element in the pair is the link l_X, the second element i
n the joint connecting l_X to l_(X+1). | |
|
| */ | | */ | |
| virtual const std::vector< std::vector< std::pair<LinkPtr, JointPtr> >
>& GetClosedLoops() const; | | virtual const std::vector< std::vector< std::pair<LinkPtr, JointPtr> >
>& GetClosedLoops() const; | |
| | | | |
| /** \en \brief Computes the minimal chain of joints that are between tw
o links in the order of linkindex1 to linkindex2 | | /** \en \brief Computes the minimal chain of joints that are between tw
o links in the order of linkindex1 to linkindex2 | |
| | | | |
| Passive joints are also used in the computation of the chain and ca
n be returned. | | Passive joints are also used in the computation of the chain and ca
n be returned. | |
| Note that a passive joint has a joint index and dof index of -1. | | Note that a passive joint has a joint index and dof index of -1. | |
| \param[in] linkindex1 the link index to start the search | | \param[in] linkindex1 the link index to start the search | |
| \param[in] linkindex2 the link index where the search ends | | \param[in] linkindex2 the link index where the search ends | |
| \param[out] vjoints the joints to fill that describe the chain | | \param[out] vjoints the joints to fill that describe the chain | |
| \return true if the two links are connected (vjoints will be filled
), false if the links are separate | | \return true if the two links are connected (vjoints will be filled
), false if the links are separate | |
| | | | |
| \ja \brief 2つのリンクを繋ぐ関節の最短経路を計算する. | | \ja \brief 2つのリンクを繋ぐ関節の最短経路を計算する. | |
| | | | |
| 受動的な関節は,位置関係が固定されているリンクを見つけるために調べられている | | 受動的な関節は,位置関係が固定されているリンクを見つけるために調べられている | |
| 受動的な関節も返される可能があるから,注意する必要があります. | | 受動的な関節も返される可能があるから,注意する必要があります. | |
| \param[in] linkindex1 始点リンクインデックス | | \param[in] linkindex1 始点リンクインデックス | |
| \param[in] linkindex2 終点リンクインデックス | | \param[in] linkindex2 終点リンクインデックス | |
| \param[out] vjoints 関節の経路 | | \param[out] vjoints 関節の経路 | |
| \return 経路が存在している場合,trueを返す. | | \return 経路が存在している場合,trueを返す. | |
|
| */ | | */ | |
| virtual bool GetChain(int linkindex1, int linkindex2, std::vector<Joint
Ptr>& vjoints) const; | | virtual bool GetChain(int linkindex1, int linkindex2, std::vector<Joint
Ptr>& vjoints) const; | |
| | | | |
| /// \brief similar to \ref GetChain(int,int,std::vector<JointPtr>&) exc
ept returns the links along the path. | | /// \brief similar to \ref GetChain(int,int,std::vector<JointPtr>&) exc
ept returns the links along the path. | |
| virtual bool GetChain(int linkindex1, int linkindex2, std::vector<LinkP
tr>& vlinks) const; | | virtual bool GetChain(int linkindex1, int linkindex2, std::vector<LinkP
tr>& vlinks) const; | |
| | | | |
| /// \brief Returns true if the dof index affects the relative transform
ation between the two links. | | /// \brief Returns true if the dof index affects the relative transform
ation between the two links. | |
| /// | | /// | |
| /// The internal implementation uses \ref KinBody::DoesAffect, therefor
e mimic indices are correctly handled. | | /// The internal implementation uses \ref KinBody::DoesAffect, therefor
e mimic indices are correctly handled. | |
| /// \param[in] linkindex1 the link index to start the search | | /// \param[in] linkindex1 the link index to start the search | |
| /// \param[in] linkindex2 the link index where the search ends | | /// \param[in] linkindex2 the link index where the search ends | |
| | | | |
| skipping to change at line 894 | | skipping to change at line 1009 | |
| /// Note that the mapping of joint structures is not the same as the va
lues in GetJointValues since each joint can have more than one degree of fr
eedom. | | /// Note that the mapping of joint structures is not the same as the va
lues in GetJointValues since each joint can have more than one degree of fr
eedom. | |
| virtual JointPtr GetJointFromDOFIndex(int dofindex) const; | | virtual JointPtr GetJointFromDOFIndex(int dofindex) const; | |
| //@} | | //@} | |
| | | | |
| /// \brief Computes the configuration difference values1-values2 and st
ores it in values1. | | /// \brief Computes the configuration difference values1-values2 and st
ores it in values1. | |
| /// | | /// | |
| /// Takes into account joint limits and wrapping of circular joints. | | /// Takes into account joint limits and wrapping of circular joints. | |
| virtual void SubtractDOFValues(std::vector<dReal>& values1, const std::
vector<dReal>& values2) const; | | virtual void SubtractDOFValues(std::vector<dReal>& values1, const std::
vector<dReal>& values2) const; | |
| | | | |
| /// \deprecated (01/01/11) | | /// \deprecated (01/01/11) | |
|
| virtual void SubtractJointValues(std::vector<dReal>& q1, const std::vec | | virtual void SubtractJointValues(std::vector<dReal>& q1, const std::vec | |
| tor<dReal>& q2) const RAVE_DEPRECATED { SubtractDOFValues(q1,q2); } | | tor<dReal>& q2) const RAVE_DEPRECATED { | |
| | | SubtractDOFValues(q1,q2); | |
| | | } | |
| | | | |
| /// \brief Adds a torque to every joint. | | /// \brief Adds a torque to every joint. | |
| /// | | /// | |
| /// \param bAdd if true, adds to previous torques, otherwise resets the
torques on all bodies and starts from 0 | | /// \param bAdd if true, adds to previous torques, otherwise resets the
torques on all bodies and starts from 0 | |
| virtual void SetDOFTorques(const std::vector<dReal>& torques, bool add)
; | | virtual void SetDOFTorques(const std::vector<dReal>& torques, bool add)
; | |
| | | | |
| /// \deprecated (11/06/17) | | /// \deprecated (11/06/17) | |
|
| virtual void SetJointTorques(const std::vector<dReal>& torques, bool ad | | virtual void SetJointTorques(const std::vector<dReal>& torques, bool ad | |
| d) RAVE_DEPRECATED { SetDOFTorques(torques,add); } | | d) RAVE_DEPRECATED { | |
| | | SetDOFTorques(torques,add); | |
| | | } | |
| | | | |
| /// \brief Returns all the rigid links of the body. | | /// \brief Returns all the rigid links of the body. | |
|
| virtual const std::vector<LinkPtr>& GetLinks() const { return _veclinks | | virtual const std::vector<LinkPtr>& GetLinks() const { | |
| ; } | | return _veclinks; | |
| | | } | |
| | | | |
|
| /// return a pointer to the link with the given name | | /// return a pointer to the link with the given name | |
| virtual LinkPtr GetLink(const std::string& name) const; | | virtual LinkPtr GetLink(const std::string& name) const; | |
| | | | |
| /// Updates the bounding box and any other parameters that could have c
hanged by a simulation step | | /// Updates the bounding box and any other parameters that could have c
hanged by a simulation step | |
| virtual void SimulationStep(dReal fElapsedTime); | | virtual void SimulationStep(dReal fElapsedTime); | |
| | | | |
| /// \brief get the transformations of all the links at once | | /// \brief get the transformations of all the links at once | |
| virtual void GetLinkTransformations(std::vector<Transform>& transforms)
const; | | virtual void GetLinkTransformations(std::vector<Transform>& transforms)
const; | |
| | | | |
| /// \deprecated (11/05/26) | | /// \deprecated (11/05/26) | |
| virtual void GetBodyTransformations(std::vector<Transform>& transforms)
const RAVE_DEPRECATED { | | virtual void GetBodyTransformations(std::vector<Transform>& transforms)
const RAVE_DEPRECATED { | |
| | | | |
| skipping to change at line 938 | | skipping to change at line 1059 | |
| | | | |
| /** \brief Sets the velocity of the base link and each of the joints. | | /** \brief Sets the velocity of the base link and each of the joints. | |
| | | | |
| Computes internally what the correponding velocities of each of the
links should be in order to | | Computes internally what the correponding velocities of each of the
links should be in order to | |
| achieve consistent results with the joint velocities. Sends the vel
ocities to the physics engine. | | achieve consistent results with the joint velocities. Sends the vel
ocities to the physics engine. | |
| Velocities correspond to the link's coordinate system origin. | | Velocities correspond to the link's coordinate system origin. | |
| \param[in] linearvel linear velocity of base link | | \param[in] linearvel linear velocity of base link | |
| \param[in] angularvel angular velocity rotation_axis*theta_dot | | \param[in] angularvel angular velocity rotation_axis*theta_dot | |
| \param[in] vDOFVelocities - velocities of each of the degrees of fr
eeom | | \param[in] vDOFVelocities - velocities of each of the degrees of fr
eeom | |
| \param checklimits if true, will excplicitly check the joint veloci
ty limits before setting the values. | | \param checklimits if true, will excplicitly check the joint veloci
ty limits before setting the values. | |
|
| */ | | */ | |
| virtual void SetDOFVelocities(const std::vector<dReal>& vDOFVelocities,
const Vector& linearvel, const Vector& angularvel,bool checklimits = false
); | | virtual void SetDOFVelocities(const std::vector<dReal>& vDOFVelocities,
const Vector& linearvel, const Vector& angularvel,bool checklimits = false
); | |
| | | | |
| /// \brief Sets the velocity of the joints. | | /// \brief Sets the velocity of the joints. | |
| /// | | /// | |
| /// Copies the current velocity of the base link and calls SetDOFVeloci
ties(linearvel,angularvel,vDOFVelocities) | | /// Copies the current velocity of the base link and calls SetDOFVeloci
ties(linearvel,angularvel,vDOFVelocities) | |
| /// \param[in] vDOFVelocity - velocities of each of the degrees of free
om | | /// \param[in] vDOFVelocity - velocities of each of the degrees of free
om | |
| /// \praam checklimits if true, will excplicitly check the joint veloci
ty limits before setting the values. | | /// \praam checklimits if true, will excplicitly check the joint veloci
ty limits before setting the values. | |
| virtual void SetDOFVelocities(const std::vector<dReal>& vDOFVelocities,
bool checklimits = false); | | virtual void SetDOFVelocities(const std::vector<dReal>& vDOFVelocities,
bool checklimits = false); | |
| | | | |
| /// \brief Returns the linear and angular velocities for each link | | /// \brief Returns the linear and angular velocities for each link | |
| virtual void GetLinkVelocities(std::vector<std::pair<Vector,Vector> >&
velocities) const; | | virtual void GetLinkVelocities(std::vector<std::pair<Vector,Vector> >&
velocities) const; | |
| | | | |
| /** \en \brief set the transform of the first link (the rest of the lin
ks are computed based on the joint values). | | /** \en \brief set the transform of the first link (the rest of the lin
ks are computed based on the joint values). | |
| | | | |
| \param transform affine transformation | | \param transform affine transformation | |
| | | | |
| \ja \brief 胴体の絶対姿勢を設定、残りのリンクは運動学の構造に従って変換される. | | \ja \brief 胴体の絶対姿勢を設定、残りのリンクは運動学の構造に従って変換される. | |
| | | | |
| \param transform 変換行列 | | \param transform 変換行列 | |
|
| */ | | */ | |
| virtual void SetTransform(const Transform& transform); | | virtual void SetTransform(const Transform& transform); | |
| | | | |
| /// \brief Return an axis-aligned bounding box of the entire object in
the world coordinate system. | | /// \brief Return an axis-aligned bounding box of the entire object in
the world coordinate system. | |
| virtual AABB ComputeAABB() const; | | virtual AABB ComputeAABB() const; | |
| | | | |
| /// \brief Return the center of mass of entire robot in the world coord
inate system. | | /// \brief Return the center of mass of entire robot in the world coord
inate system. | |
| virtual Vector GetCenterOfMass() const; | | virtual Vector GetCenterOfMass() const; | |
| | | | |
| /// \brief Enables or disables the bodies. | | /// \brief Enables or disables the bodies. | |
| virtual void Enable(bool enable); | | virtual void Enable(bool enable); | |
| | | | |
| /// \deprecated (10/09/08) | | /// \deprecated (10/09/08) | |
|
| virtual void EnableLink(LinkPtr plink, bool bEnable) RAVE_DEPRECATED { | | virtual void EnableLink(LinkPtr plink, bool bEnable) RAVE_DEPRECATED { | |
| plink->Enable(bEnable); } | | plink->Enable(bEnable); | |
| | | } | |
| | | | |
| /// \return true if any link of the KinBody is enabled | | /// \return true if any link of the KinBody is enabled | |
| virtual bool IsEnabled() const; | | virtual bool IsEnabled() const; | |
| | | | |
| /// \brief Sets the joint values of the robot. | | /// \brief Sets the joint values of the robot. | |
| /// | | /// | |
| /// \param values the values to set the joint angles (ordered by the do
f indices) | | /// \param values the values to set the joint angles (ordered by the do
f indices) | |
| /// \praam checklimits if true, will excplicitly check the joint limits
before setting the values. | | /// \praam checklimits if true, will excplicitly check the joint limits
before setting the values. | |
| virtual void SetDOFValues(const std::vector<dReal>& values, bool checkl
imits = false); | | virtual void SetDOFValues(const std::vector<dReal>& values, bool checkl
imits = false); | |
| | | | |
| | | | |
| skipping to change at line 1002 | | skipping to change at line 1125 | |
| | | | |
| virtual void SetJointValues(const std::vector<dReal>& values, const Tra
nsform& transform, bool checklimits = false) | | virtual void SetJointValues(const std::vector<dReal>& values, const Tra
nsform& transform, bool checklimits = false) | |
| { | | { | |
| SetDOFValues(values,transform,checklimits); | | SetDOFValues(values,transform,checklimits); | |
| } | | } | |
| | | | |
| /// \brief sets the transformations of all the links at once | | /// \brief sets the transformations of all the links at once | |
| virtual void SetLinkTransformations(const std::vector<Transform>& trans
forms); | | virtual void SetLinkTransformations(const std::vector<Transform>& trans
forms); | |
| | | | |
| /// \deprecated (11/05/26) | | /// \deprecated (11/05/26) | |
|
| virtual void SetBodyTransformations(const std::vector<Transform>& trans | | virtual void SetBodyTransformations(const std::vector<Transform>& trans | |
| forms) RAVE_DEPRECATED { SetLinkTransformations(transforms); } | | forms) RAVE_DEPRECATED { | |
| | | SetLinkTransformations(transforms); | |
| | | } | |
| | | | |
| /// \brief sets the link velocities | | /// \brief sets the link velocities | |
| virtual void SetLinkVelocities(const std::vector<std::pair<Vector,Vecto
r> >& velocities); | | virtual void SetLinkVelocities(const std::vector<std::pair<Vector,Vecto
r> >& velocities); | |
| | | | |
| /// \brief Computes the translation jacobian with respect to a world po
sition. | | /// \brief Computes the translation jacobian with respect to a world po
sition. | |
| /// | | /// | |
| /// Gets the jacobian with respect to a link by computing the partial d
ifferentials for all joints that in the path from the root node to GetLinks
()[index] | | /// Gets the jacobian with respect to a link by computing the partial d
ifferentials for all joints that in the path from the root node to GetLinks
()[index] | |
| /// (doesn't touch the rest of the values) | | /// (doesn't touch the rest of the values) | |
| /// \param linkindex of the link that the rotation is attached to | | /// \param linkindex of the link that the rotation is attached to | |
| /// \param position position in world space where to compute derivative
s from. | | /// \param position position in world space where to compute derivative
s from. | |
| | | | |
| skipping to change at line 1044 | | skipping to change at line 1169 | |
| | | | |
| /// \return true if two bodies should be considered as one during colli
sion (ie one is grabbing the other) | | /// \return true if two bodies should be considered as one during colli
sion (ie one is grabbing the other) | |
| virtual bool IsAttached(KinBodyConstPtr body) const; | | virtual bool IsAttached(KinBodyConstPtr body) const; | |
| | | | |
| /// \brief Recursively get all attached bodies of this body, including
this body. | | /// \brief Recursively get all attached bodies of this body, including
this body. | |
| /// | | /// | |
| /// \param setAttached fills with the attached bodies. If any bodies ar
e already in setAttached, then ignores recursing on their attached bodies. | | /// \param setAttached fills with the attached bodies. If any bodies ar
e already in setAttached, then ignores recursing on their attached bodies. | |
| virtual void GetAttached(std::set<KinBodyPtr>& setAttached) const; | | virtual void GetAttached(std::set<KinBodyPtr>& setAttached) const; | |
| | | | |
| /// \brief Return true if this body is derived from RobotBase. | | /// \brief Return true if this body is derived from RobotBase. | |
|
| virtual bool IsRobot() const { return false; } | | virtual bool IsRobot() const { | |
| | | return false; | |
| | | } | |
| | | | |
| /// \brief return a unique id of the body used in the environment. | | /// \brief return a unique id of the body used in the environment. | |
| /// | | /// | |
| /// If object is not added to the environment, this will return 0. So c
hecking if GetEnvironmentId() is 0 is a good way to check if object is pres
ent in the environment. | | /// If object is not added to the environment, this will return 0. So c
hecking if GetEnvironmentId() is 0 is a good way to check if object is pres
ent in the environment. | |
| /// This id will not be copied when cloning in order to respect another
environment's ids. | | /// This id will not be copied when cloning in order to respect another
environment's ids. | |
| virtual int GetEnvironmentId() const; | | virtual int GetEnvironmentId() const; | |
| | | | |
| /** \brief Returns a nonzero value if the joint effects the link transf
ormation. | | /** \brief Returns a nonzero value if the joint effects the link transf
ormation. | |
| | | | |
| In closed loops, all joints on all paths to the root link are count
ed as affecting the link. | | In closed loops, all joints on all paths to the root link are count
ed as affecting the link. | |
| If a mimic joint affects the link, then all the joints used in the
mimic joint's computation affect the link. | | If a mimic joint affects the link, then all the joints used in the
mimic joint's computation affect the link. | |
| If negative, the partial derivative of the Jacobian should be negat
ed. | | If negative, the partial derivative of the Jacobian should be negat
ed. | |
| \param jointindex index of the joint | | \param jointindex index of the joint | |
| \param linkindex index of the link | | \param linkindex index of the link | |
|
| */ | | */ | |
| virtual int8_t DoesAffect(int jointindex, int linkindex) const; | | virtual int8_t DoesAffect(int jointindex, int linkindex) const; | |
| | | | |
| /// \brief GUI data to let the viewer store specific graphic handles fo
r the object. | | /// \brief GUI data to let the viewer store specific graphic handles fo
r the object. | |
|
| virtual void SetGuiData(UserDataPtr data) { _pGuiData = data; } | | virtual void SetGuiData(UserDataPtr data) { | |
| | | _pGuiData = data; | |
| | | } | |
| | | | |
| /// \see SetGuiData | | /// \see SetGuiData | |
|
| virtual UserDataPtr GetGuiData() const { return _pGuiData; } | | virtual UserDataPtr GetGuiData() const { | |
| | | return _pGuiData; | |
| | | } | |
| | | | |
| /// \brief specifies the type of adjacent link information to receive | | /// \brief specifies the type of adjacent link information to receive | |
| enum AdjacentOptions | | enum AdjacentOptions | |
| { | | { | |
|
| AO_Enabled = 1, ///< return only enabled link pairs | | AO_Enabled = 1, ///< return only enabled link pairs | |
| AO_ActiveDOFs = 2, ///< return only link pairs that have an active | | AO_ActiveDOFs = 2, ///< return only link pairs that have an act | |
| in its path | | ive in its path | |
| }; | | }; | |
| | | | |
| /// \brief return all possible link pairs that could get in collision. | | /// \brief return all possible link pairs that could get in collision. | |
| /// \param adjacentoptions a bitmask of \ref AdjacentOptions values | | /// \param adjacentoptions a bitmask of \ref AdjacentOptions values | |
| virtual const std::set<int>& GetNonAdjacentLinks(int adjacentoptions=0)
const; | | virtual const std::set<int>& GetNonAdjacentLinks(int adjacentoptions=0)
const; | |
| | | | |
| /// \brief return all possible link pairs whose collisions are ignored. | | /// \brief return all possible link pairs whose collisions are ignored. | |
| virtual const std::set<int>& GetAdjacentLinks() const; | | virtual const std::set<int>& GetAdjacentLinks() const; | |
| | | | |
| /// \see SetPhysicsData | | /// \see SetPhysicsData | |
|
| virtual UserDataPtr GetPhysicsData() const { return _pPhysicsData; } | | virtual UserDataPtr GetPhysicsData() const { | |
| | | return _pPhysicsData; | |
| | | } | |
| /// \brief SetCollisionData | | /// \brief SetCollisionData | |
|
| virtual UserDataPtr GetCollisionData() const { return _pCollisionData; | | virtual UserDataPtr GetCollisionData() const { | |
| } | | return _pCollisionData; | |
| virtual ManageDataPtr GetManageData() const { return _pManageData; } | | } | |
| | | virtual ManageDataPtr GetManageData() const { | |
| | | return _pManageData; | |
| | | } | |
| | | | |
| /// \brief Return a unique id for every transformation state change of
any link. Used to check if robot state has changed. | | /// \brief Return a unique id for every transformation state change of
any link. Used to check if robot state has changed. | |
| /// | | /// | |
| /// The stamp is used by the collision checkers, physics engines, or an
y other item | | /// The stamp is used by the collision checkers, physics engines, or an
y other item | |
| /// that needs to keep track of any changes of the KinBody as it moves. | | /// that needs to keep track of any changes of the KinBody as it moves. | |
| /// Currently stamps monotonically increment for every transformation/j
oint angle change. | | /// Currently stamps monotonically increment for every transformation/j
oint angle change. | |
|
| virtual int GetUpdateStamp() const { return _nUpdateStampId; } | | virtual int GetUpdateStamp() const { | |
| | | return _nUpdateStampId; | |
| | | } | |
| | | | |
| virtual void Clone(InterfaceBaseConstPtr preference, int cloningoptions
); | | virtual void Clone(InterfaceBaseConstPtr preference, int cloningoptions
); | |
| | | | |
| /// \brief Register a callback with the interface. | | /// \brief Register a callback with the interface. | |
| /// | | /// | |
| /// Everytime a static property of the interface changes, all | | /// Everytime a static property of the interface changes, all | |
| /// registered callbacks are called to update the users of the changes.
Note that the callbacks will | | /// registered callbacks are called to update the users of the changes.
Note that the callbacks will | |
| /// block the thread that made the parameter change. | | /// block the thread that made the parameter change. | |
| /// \param callback | | /// \param callback | |
| /// \param properties a mask of the \ref KinBodyProperty values that th
e callback should be called for when they change | | /// \param properties a mask of the \ref KinBodyProperty values that th
e callback should be called for when they change | |
| | | | |
| skipping to change at line 1134 | | skipping to change at line 1273 | |
| /// \brief Sets the joint offsets so that the current configuration bec
omes the new zero state of the robot. | | /// \brief Sets the joint offsets so that the current configuration bec
omes the new zero state of the robot. | |
| /// | | /// | |
| /// When this function returns, the returned DOF values should be all z
ero for controllable joints. | | /// When this function returns, the returned DOF values should be all z
ero for controllable joints. | |
| /// Mimic equations will use the new offsetted values when computing th
eir joints. | | /// Mimic equations will use the new offsetted values when computing th
eir joints. | |
| /// This is primarily used for calibrating a robot's zero position | | /// This is primarily used for calibrating a robot's zero position | |
| virtual void SetZeroConfiguration(); | | virtual void SetZeroConfiguration(); | |
| | | | |
| protected: | | protected: | |
| /// \brief constructors declared protected so that user always goes thr
ough environment to create bodies | | /// \brief constructors declared protected so that user always goes thr
ough environment to create bodies | |
| KinBody(InterfaceType type, EnvironmentBasePtr penv); | | KinBody(InterfaceType type, EnvironmentBasePtr penv); | |
|
| inline KinBodyPtr shared_kinbody() { return boost::static_pointer_cast< | | inline KinBodyPtr shared_kinbody() { | |
| KinBody>(shared_from_this()); } | | return boost::static_pointer_cast<KinBody>(shared_from_this()); | |
| inline KinBodyConstPtr shared_kinbody_const() const { return boost::sta | | } | |
| tic_pointer_cast<KinBody const>(shared_from_this()); } | | inline KinBodyConstPtr shared_kinbody_const() const { | |
| | | return boost::static_pointer_cast<KinBody const>(shared_from_this() | |
| | | ); | |
| | | } | |
| | | | |
| /// \brief custom data managed by the current active physics engine, sh
ould be set only by PhysicsEngineBase | | /// \brief custom data managed by the current active physics engine, sh
ould be set only by PhysicsEngineBase | |
|
| virtual void SetPhysicsData(UserDataPtr pdata) { _pPhysicsData = pdata; | | virtual void SetPhysicsData(UserDataPtr pdata) { | |
| } | | _pPhysicsData = pdata; | |
| | | } | |
| /// \brief custom data managed by the current active collision checker,
should be set only by CollisionCheckerBase | | /// \brief custom data managed by the current active collision checker,
should be set only by CollisionCheckerBase | |
|
| virtual void SetCollisionData(UserDataPtr pdata) { _pCollisionData = pd | | virtual void SetCollisionData(UserDataPtr pdata) { | |
| ata; } | | _pCollisionData = pdata; | |
| virtual void SetManageData(ManageDataPtr pdata) { _pManageData = pdata; | | } | |
| } | | virtual void SetManageData(ManageDataPtr pdata) { | |
| | | _pManageData = pdata; | |
| | | } | |
| | | | |
| /** \brief Final post-processing stage before a kinematics body can be
used. | | /** \brief Final post-processing stage before a kinematics body can be
used. | |
| | | | |
| This method is called after the body is finished being initialized
with data and before being added to the environment. Also builds the hashes
. Builds the internal hierarchy and kinematic body hash. | | This method is called after the body is finished being initialized
with data and before being added to the environment. Also builds the hashes
. Builds the internal hierarchy and kinematic body hash. | |
| | | | |
| Avoids making specific calls on the collision checker (like CheckCo
llision) or physics engine (like simulating velocities/torques) since this
information can change depending on the attached plugin. | | Avoids making specific calls on the collision checker (like CheckCo
llision) or physics engine (like simulating velocities/torques) since this
information can change depending on the attached plugin. | |
|
| */ | | */ | |
| virtual void _ComputeInternalInformation(); | | virtual void _ComputeInternalInformation(); | |
| | | | |
| /// \brief Called to notify the body that certain groups of parameters
have been changed. | | /// \brief Called to notify the body that certain groups of parameters
have been changed. | |
| /// | | /// | |
| /// This function in calls every registers calledback that is tracking
the changes. It also | | /// This function in calls every registers calledback that is tracking
the changes. It also | |
| /// recomputes the hashes if geometry changed. | | /// recomputes the hashes if geometry changed. | |
| virtual void _ParametersChanged(int parameters); | | virtual void _ParametersChanged(int parameters); | |
| | | | |
| /// \brief Return true if two bodies should be considered as one during
collision (ie one is grabbing the other) | | /// \brief Return true if two bodies should be considered as one during
collision (ie one is grabbing the other) | |
| virtual bool _IsAttached(KinBodyConstPtr body, std::set<KinBodyConstPtr
>& setChecked) const; | | virtual bool _IsAttached(KinBodyConstPtr body, std::set<KinBodyConstPtr
>& setChecked) const; | |
| | | | |
| skipping to change at line 1175 | | skipping to change at line 1324 | |
| /// \return true if body was successfully found and removed | | /// \return true if body was successfully found and removed | |
| virtual bool _RemoveAttachedBody(KinBodyPtr body); | | virtual bool _RemoveAttachedBody(KinBodyPtr body); | |
| | | | |
| /// \brief resets cached information dependent on the collision checker
(usually called when the collision checker is switched or some big mode is
set. | | /// \brief resets cached information dependent on the collision checker
(usually called when the collision checker is switched or some big mode is
set. | |
| virtual void _ResetInternalCollisionCache(); | | virtual void _ResetInternalCollisionCache(); | |
| | | | |
| /// creates the function parser connected to this body's joint values | | /// creates the function parser connected to this body's joint values | |
| virtual boost::shared_ptr<FunctionParserBase<dReal> > _CreateFunctionPa
rser(); | | virtual boost::shared_ptr<FunctionParserBase<dReal> > _CreateFunctionPa
rser(); | |
| | | | |
| std::string _name; ///< name of body | | std::string _name; ///< name of body | |
|
| std::vector<JointPtr> _vecjoints; ///< \see GetJoints | | std::vector<JointPtr> _vecjoints; ///< \see GetJoints | |
| std::vector<JointPtr> _vTopologicallySortedJoints; ///< \see GetDepende
ncyOrderedJoints | | std::vector<JointPtr> _vTopologicallySortedJoints; ///< \see GetDepende
ncyOrderedJoints | |
| std::vector<JointPtr> _vTopologicallySortedJointsAll; ///< Similar to _
vDependencyOrderedJoints except includes _vecjoints and _vPassiveJoints | | std::vector<JointPtr> _vTopologicallySortedJointsAll; ///< Similar to _
vDependencyOrderedJoints except includes _vecjoints and _vPassiveJoints | |
| std::vector<int> _vTopologicallySortedJointIndicesAll; ///< the joint i
ndices of the joints in _vTopologicallySortedJointsAll. Passive joint indic
es have _vecjoints.size() added to them. | | std::vector<int> _vTopologicallySortedJointIndicesAll; ///< the joint i
ndices of the joints in _vTopologicallySortedJointsAll. Passive joint indic
es have _vecjoints.size() added to them. | |
| std::vector<JointPtr> _vDOFOrderedJoints; ///< all joints of the body o
rdered on how they are arranged within the degrees of freedom | | std::vector<JointPtr> _vDOFOrderedJoints; ///< all joints of the body o
rdered on how they are arranged within the degrees of freedom | |
|
| std::vector<LinkPtr> _veclinks; ///< \see GetLinks | | std::vector<LinkPtr> _veclinks; ///< \see GetLinks | |
| std::vector<int> _vDOFIndices; ///< cached start joint indices, indexed
by dof indices | | std::vector<int> _vDOFIndices; ///< cached start joint indices, indexed
by dof indices | |
| std::vector<std::pair<int16_t,int16_t> > _vAllPairsShortestPaths; ///<
all-pairs shortest paths through the link hierarchy. The first value descri
bes the parent link index, and the second value is an index into _vecjoints
or _vPassiveJoints. If the second value is greater or equal to _vecjoints
.size() then it indexes into _vPassiveJoints. | | std::vector<std::pair<int16_t,int16_t> > _vAllPairsShortestPaths; ///<
all-pairs shortest paths through the link hierarchy. The first value descri
bes the parent link index, and the second value is an index into _vecjoints
or _vPassiveJoints. If the second value is greater or equal to _vecjoints
.size() then it indexes into _vPassiveJoints. | |
|
| std::vector<int8_t> _vJointsAffectingLinks; ///< joint x link: (joint
index*_veclinks.size()+linkindex). entry is non-zero if the joint affects t
he link in the forward kinematics. If negative, the partial derivative of d
s/dtheta should be negated. | | std::vector<int8_t> _vJointsAffectingLinks; ///< joint x link: (jointin
dex*_veclinks.size()+linkindex). entry is non-zero if the joint affects the
link in the forward kinematics. If negative, the partial derivative of ds/
dtheta should be negated. | |
| std::vector< std::vector< std::pair<LinkPtr,JointPtr> > > _vClosedLoops
; ///< \see GetClosedLoops | | std::vector< std::vector< std::pair<LinkPtr,JointPtr> > > _vClosedLoops
; ///< \see GetClosedLoops | |
| std::vector< std::vector< std::pair<int16_t,int16_t> > > _vClosedLoopIn
dices; ///< \see GetClosedLoops | | std::vector< std::vector< std::pair<int16_t,int16_t> > > _vClosedLoopIn
dices; ///< \see GetClosedLoops | |
| std::vector<JointPtr> _vPassiveJoints; ///< \see GetPassiveJoints() | | std::vector<JointPtr> _vPassiveJoints; ///< \see GetPassiveJoints() | |
|
| std::set<int> _setAdjacentLinks; ///< a set of which links are c | | std::set<int> _setAdjacentLinks; ///< a set of which links are connecte | |
| onnected to which if link i and j are connected then | | d to which if link i and j are connected then | |
| ///< i|(j<<16) will be in the s | | ///< i|(j<<16) will be in the set wher | |
| et where i<j. | | e i<j. | |
| std::vector< std::pair<std::string, std::string> > _vForcedAdjacentLink
s; ///< internally stores forced adjacent links | | std::vector< std::pair<std::string, std::string> > _vForcedAdjacentLink
s; ///< internally stores forced adjacent links | |
| std::list<KinBodyWeakPtr> _listAttachedBodies; ///< list of bodies that
are directly attached to this body (can have duplicates) | | std::list<KinBodyWeakPtr> _listAttachedBodies; ///< list of bodies that
are directly attached to this body (can have duplicates) | |
| std::list<std::pair<int,boost::function<void()> > > _listRegisteredCall
backs; ///< callbacks to call when particular properties of the body change
. | | std::list<std::pair<int,boost::function<void()> > > _listRegisteredCall
backs; ///< callbacks to call when particular properties of the body change
. | |
| | | | |
|
| mutable boost::array<std::set<int>, 4> _setNonAdjacentLinks; ///< c
ontains cached versions of the non-adjacent links depending on values in Ad
jacentOptions. Declared as mutable since data is cached. | | mutable boost::array<std::set<int>, 4> _setNonAdjacentLinks; ///< conta
ins cached versions of the non-adjacent links depending on values in Adjace
ntOptions. Declared as mutable since data is cached. | |
| mutable int _nNonAdjacentLinkCache; ///< specifies what information is
currently valid in the AdjacentOptions. Declared as mutable since data is
cached. If 0x80000000 (ie < 0), then everything needs to be recomputed incl
uding _setNonAdjacentLinks[0]. | | mutable int _nNonAdjacentLinkCache; ///< specifies what information is
currently valid in the AdjacentOptions. Declared as mutable since data is
cached. If 0x80000000 (ie < 0), then everything needs to be recomputed incl
uding _setNonAdjacentLinks[0]. | |
| std::vector<Transform> _vInitialLinkTransformations; ///< the initial t
ransformations of each link specifying at least one pose where the robot is
collision free | | std::vector<Transform> _vInitialLinkTransformations; ///< the initial t
ransformations of each link specifying at least one pose where the robot is
collision free | |
| | | | |
| int _environmentid; ///< \see GetEnvironmentId | | int _environmentid; ///< \see GetEnvironmentId | |
| mutable int _nUpdateStampId; ///< \see GetUpdateStamp | | mutable int _nUpdateStampId; ///< \see GetUpdateStamp | |
| int _nParametersChanged; ///< set of parameters that changed and need c
allbacks | | int _nParametersChanged; ///< set of parameters that changed and need c
allbacks | |
| UserDataPtr _pGuiData; ///< \see SetGuiData | | UserDataPtr _pGuiData; ///< \see SetGuiData | |
| UserDataPtr _pPhysicsData; ///< \see SetPhysicsData | | UserDataPtr _pPhysicsData; ///< \see SetPhysicsData | |
| UserDataPtr _pCollisionData; ///< \see SetCollisionData | | UserDataPtr _pCollisionData; ///< \see SetCollisionData | |
| ManageDataPtr _pManageData; | | ManageDataPtr _pManageData; | |
| uint32_t _nHierarchyComputed; ///< true if the joint heirarchy and othe
r cached information is computed | | uint32_t _nHierarchyComputed; ///< true if the joint heirarchy and othe
r cached information is computed | |
| bool _bMakeJoinedLinksAdjacent; | | bool _bMakeJoinedLinksAdjacent; | |
| private: | | private: | |
| mutable std::string __hashkinematics; | | mutable std::string __hashkinematics; | |
| mutable std::vector<dReal> _vTempJoints; | | mutable std::vector<dReal> _vTempJoints; | |
|
| virtual const char* GetHash() const { return OPENRAVE_KINBODY_HASH; } | | virtual const char* GetHash() const { | |
| | | return OPENRAVE_KINBODY_HASH; | |
| | | } | |
| | | | |
| static void __erase_iterator(KinBodyWeakPtr pweakbody, std::list<std::p
air<int,boost::function<void()> > >::iterator* pit); | | static void __erase_iterator(KinBodyWeakPtr pweakbody, std::list<std::p
air<int,boost::function<void()> > >::iterator* pit); | |
| | | | |
| #ifdef RAVE_PRIVATE | | #ifdef RAVE_PRIVATE | |
| #ifdef _MSC_VER | | #ifdef _MSC_VER | |
| friend class Environment; | | friend class Environment; | |
| friend class ColladaReader; | | friend class ColladaReader; | |
| friend class ColladaWriter; | | friend class ColladaWriter; | |
| friend class OpenRAVEXMLParser::KinBodyXMLReader; | | friend class OpenRAVEXMLParser::KinBodyXMLReader; | |
| friend class OpenRAVEXMLParser::JointXMLReader; | | friend class OpenRAVEXMLParser::JointXMLReader; | |
| | | | |
End of changes. 109 change blocks. |
| 286 lines changed or deleted | | 418 lines changed or added | |
|
| mathextra.h | | mathextra.h | |
|
| // Copyright (C) 2006-2010 Rosen Diankov (rosen.diankov@gmail.com) | | // -*- coding: utf-8 -*- | |
| | | // Copyright (C) 2006-2011 Rosen Diankov <rosen.diankov@gmail.com> | |
| // | | // | |
| // This file is part of OpenRAVE. | | // This file is part of OpenRAVE. | |
| // OpenRAVE is free software: you can redistribute it and/or modify | | // OpenRAVE is free software: you can redistribute it and/or modify | |
| // it under the terms of the GNU Lesser General Public License as published
by | | // it under the terms of the GNU Lesser General Public License as published
by | |
| // the Free Software Foundation, either version 3 of the License, or | | // the Free Software Foundation, either version 3 of the License, or | |
| // at your option) any later version. | | // at your option) any later version. | |
| // | | // | |
| // This program is distributed in the hope that it will be useful, | | // This program is distributed in the hope that it will be useful, | |
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| | | | |
| skipping to change at line 41 | | skipping to change at line 42 | |
| #endif | | #endif | |
| | | | |
| #include <cmath> | | #include <cmath> | |
| #include <climits> | | #include <climits> | |
| | | | |
| namespace OpenRAVE { | | namespace OpenRAVE { | |
| | | | |
| /// Extra math routines that are useful to have but don't really belong any
where. | | /// Extra math routines that are useful to have but don't really belong any
where. | |
| namespace mathextra { | | namespace mathextra { | |
| | | | |
|
| #define distinctRoots 0 // roots r0 < r1 < r2 | | #define distinctRoots 0 // roots r0 < r1 < r2 | |
| #define singleRoot 1 // root r0 | | #define singleRoot 1 // root r0 | |
| #define floatRoot01 2 // roots r0 = r1 < r | | #define floatRoot01 2 // roots r0 = r1 < r2 | |
| 2 | | #define floatRoot12 4 // roots r0 < r1 = r2 | |
| #define floatRoot12 4 // roots r0 < r1 = r | | #define tripleRoot 6 // roots r0 = r1 = r2 | |
| 2 | | | |
| #define tripleRoot 6 // roots r0 = r1 = r | | | |
| 2 | | | |
| | | | |
| // multiplies 4x4 matrices | | // multiplies 4x4 matrices | |
| inline float* mult4(float* pfres, const float* pf1, const float* pf2); | | inline float* mult4(float* pfres, const float* pf1, const float* pf2); | |
| | | | |
| // pf1^T * pf2 | | // pf1^T * pf2 | |
| inline float* multtrans3(float* pfres, const float* pf1, const float* pf2); | | inline float* multtrans3(float* pfres, const float* pf1, const float* pf2); | |
| inline float* multtrans4(float* pfres, const float* pf1, const float* pf2); | | inline float* multtrans4(float* pfres, const float* pf1, const float* pf2); | |
| inline float* transnorm3(float* pfout, const float* pfmat, const float* pf)
; | | inline float* transnorm3(float* pfout, const float* pfmat, const float* pf)
; | |
| | | | |
| inline float* transpose3(const float* pf, float* pfres); | | inline float* transpose3(const float* pf, float* pfres); | |
| | | | |
| skipping to change at line 153 | | skipping to change at line 154 | |
| /// SVD of a 3x3 matrix A such that A = U*diag(D)*V' | | /// SVD of a 3x3 matrix A such that A = U*diag(D)*V' | |
| /// The row stride for all matrices is 3*sizeof(T) bytes | | /// The row stride for all matrices is 3*sizeof(T) bytes | |
| /// \param[in] A 3x3 matrix | | /// \param[in] A 3x3 matrix | |
| /// \param[out] U 3x3 matrix | | /// \param[out] U 3x3 matrix | |
| /// \param[out] D 3x1 matrix | | /// \param[out] D 3x1 matrix | |
| /// \param[out] V 3x3 matrix | | /// \param[out] V 3x3 matrix | |
| template <typename T> inline void svd3(const T* A, T* U, T* D, T* V); | | template <typename T> inline void svd3(const T* A, T* U, T* D, T* V); | |
| | | | |
| template <typename T> inline void mult(T* pf, T fa, int r) | | template <typename T> inline void mult(T* pf, T fa, int r) | |
| { | | { | |
|
| MATH_ASSERT( pf != NULL ); | | MATH_ASSERT( pf != NULL ); | |
| while(r > 0) { | | while(r > 0) { | |
| --r; | | --r; | |
| pf[r] *= fa; | | pf[r] *= fa; | |
| } | | } | |
| } | | } | |
| | | | |
| template <typename T> int Min(T* pts, int stride, int numPts); // returns t
he index, stride in units of T | | template <typename T> int Min(T* pts, int stride, int numPts); // returns t
he index, stride in units of T | |
| template <typename T> int Max(T* pts, int stride, int numPts); // returns t
he index | | template <typename T> int Max(T* pts, int stride, int numPts); // returns t
he index | |
| | | | |
| // multiplies a matrix by a scalar | | // multiplies a matrix by a scalar | |
| template <typename T> inline void mult(T* pf, T fa, int r); | | template <typename T> inline void mult(T* pf, T fa, int r); | |
| | | | |
| // multiplies a r1xc1 by c1xc2 matrix into pfres, if badd is true adds the
result to pfres | | // multiplies a r1xc1 by c1xc2 matrix into pfres, if badd is true adds the
result to pfres | |
| // does not handle cases where pfres is equal to pf1 or pf2, use multtox fo
r those cases | | // does not handle cases where pfres is equal to pf1 or pf2, use multtox fo
r those cases | |
| | | | |
| skipping to change at line 271 | | skipping to change at line 272 | |
| return 1; | | return 1; | |
| } | | } | |
| // two roots | | // two roots | |
| d = sqrt(d); | | d = sqrt(d); | |
| r1 = (-b+d)/(2*a); | | r1 = (-b+d)/(2*a); | |
| r2 = c/(a*r1); | | r2 = c/(a*r1); | |
| return 2; | | return 2; | |
| } | | } | |
| | | | |
| #define MULT3(stride) { \ | | #define MULT3(stride) { \ | |
|
| pfres2[0*stride+0] = pf1[0*stride+0]*pf2[0*stride+0]+pf1[0*stride+1] | | pfres2[0*stride+0] = pf1[0*stride+0]*pf2[0*stride+0]+pf1[0*stride+1 | |
| *pf2[1*stride+0]+pf1[0*stride+2]*pf2[2*stride+0]; \ | | ]*pf2[1*stride+0]+pf1[0*stride+2]*pf2[2*stride+0]; \ | |
| pfres2[0*stride+1] = pf1[0*stride+0]*pf2[0*stride+1]+pf1[0*stride+1] | | pfres2[0*stride+1] = pf1[0*stride+0]*pf2[0*stride+1]+pf1[0*stride+1 | |
| *pf2[1*stride+1]+pf1[0*stride+2]*pf2[2*stride+1]; \ | | ]*pf2[1*stride+1]+pf1[0*stride+2]*pf2[2*stride+1]; \ | |
| pfres2[0*stride+2] = pf1[0*stride+0]*pf2[0*stride+2]+pf1[0*stride+1] | | pfres2[0*stride+2] = pf1[0*stride+0]*pf2[0*stride+2]+pf1[0*stride+1 | |
| *pf2[1*stride+2]+pf1[0*stride+2]*pf2[2*stride+2]; \ | | ]*pf2[1*stride+2]+pf1[0*stride+2]*pf2[2*stride+2]; \ | |
| pfres2[1*stride+0] = pf1[1*stride+0]*pf2[0*stride+0]+pf1[1*stride+1] | | pfres2[1*stride+0] = pf1[1*stride+0]*pf2[0*stride+0]+pf1[1*stride+1 | |
| *pf2[1*stride+0]+pf1[1*stride+2]*pf2[2*stride+0]; \ | | ]*pf2[1*stride+0]+pf1[1*stride+2]*pf2[2*stride+0]; \ | |
| pfres2[1*stride+1] = pf1[1*stride+0]*pf2[0*stride+1]+pf1[1*stride+1] | | pfres2[1*stride+1] = pf1[1*stride+0]*pf2[0*stride+1]+pf1[1*stride+1 | |
| *pf2[1*stride+1]+pf1[1*stride+2]*pf2[2*stride+1]; \ | | ]*pf2[1*stride+1]+pf1[1*stride+2]*pf2[2*stride+1]; \ | |
| pfres2[1*stride+2] = pf1[1*stride+0]*pf2[0*stride+2]+pf1[1*stride+1] | | pfres2[1*stride+2] = pf1[1*stride+0]*pf2[0*stride+2]+pf1[1*stride+1 | |
| *pf2[1*stride+2]+pf1[1*stride+2]*pf2[2*stride+2]; \ | | ]*pf2[1*stride+2]+pf1[1*stride+2]*pf2[2*stride+2]; \ | |
| pfres2[2*stride+0] = pf1[2*stride+0]*pf2[0*stride+0]+pf1[2*stride+1] | | pfres2[2*stride+0] = pf1[2*stride+0]*pf2[0*stride+0]+pf1[2*stride+1 | |
| *pf2[1*stride+0]+pf1[2*stride+2]*pf2[2*stride+0]; \ | | ]*pf2[1*stride+0]+pf1[2*stride+2]*pf2[2*stride+0]; \ | |
| pfres2[2*stride+1] = pf1[2*stride+0]*pf2[0*stride+1]+pf1[2*stride+1] | | pfres2[2*stride+1] = pf1[2*stride+0]*pf2[0*stride+1]+pf1[2*stride+1 | |
| *pf2[1*stride+1]+pf1[2*stride+2]*pf2[2*stride+1]; \ | | ]*pf2[1*stride+1]+pf1[2*stride+2]*pf2[2*stride+1]; \ | |
| pfres2[2*stride+2] = pf1[2*stride+0]*pf2[0*stride+2]+pf1[2*stride+1] | | pfres2[2*stride+2] = pf1[2*stride+0]*pf2[0*stride+2]+pf1[2*stride+1 | |
| *pf2[1*stride+2]+pf1[2*stride+2]*pf2[2*stride+2]; \ | | ]*pf2[1*stride+2]+pf1[2*stride+2]*pf2[2*stride+2]; \ | |
| } | | } | |
| | | | |
| /// mult3 with a 3x3 matrix whose row stride is 16 bytes | | /// mult3 with a 3x3 matrix whose row stride is 16 bytes | |
| template <typename T> | | template <typename T> | |
| inline T* _mult3_s4(T* pfres, const T* pf1, const T* pf2) | | inline T* _mult3_s4(T* pfres, const T* pf1, const T* pf2) | |
| { | | { | |
| MATH_ASSERT( pf1 != NULL && pf2 != NULL && pfres != NULL ); | | MATH_ASSERT( pf1 != NULL && pf2 != NULL && pfres != NULL ); | |
| | | | |
| T* pfres2; | | T* pfres2; | |
|
| if( pfres == pf1 || pfres == pf2 ) pfres2 = (T*)alloca(12 * sizeof(T)); | | if((pfres == pf1)||(pfres == pf2)) pfres2 = (T*)alloca(12 * sizeof(T)); | |
| else pfres2 = pfres; | | else pfres2 = pfres; | |
| | | | |
| MULT3(4); | | MULT3(4); | |
| if( pfres2 != pfres ) memcpy(pfres, pfres2, 12*sizeof(T)); | | if( pfres2 != pfres ) memcpy(pfres, pfres2, 12*sizeof(T)); | |
| return pfres; | | return pfres; | |
| } | | } | |
| | | | |
| /// mult3 with a 3x3 matrix whose row stride is 12 bytes | | /// mult3 with a 3x3 matrix whose row stride is 12 bytes | |
| template <typename T> | | template <typename T> | |
| inline T* _mult3_s3(T* pfres, const T* pf1, const T* pf2) | | inline T* _mult3_s3(T* pfres, const T* pf1, const T* pf2) | |
| { | | { | |
| MATH_ASSERT( pf1 != NULL && pf2 != NULL && pfres != NULL ); | | MATH_ASSERT( pf1 != NULL && pf2 != NULL && pfres != NULL ); | |
| | | | |
| T* pfres2; | | T* pfres2; | |
|
| if( pfres == pf1 || pfres == pf2 ) pfres2 = (T*)alloca(9 * sizeof(T)); | | if((pfres == pf1)||(pfres == pf2)) pfres2 = (T*)alloca(9 * sizeof(T)); | |
| else pfres2 = pfres; | | else pfres2 = pfres; | |
| | | | |
| MULT3(3); | | MULT3(3); | |
| | | | |
| if( pfres2 != pfres ) memcpy(pfres, pfres2, 9*sizeof(T)); | | if( pfres2 != pfres ) memcpy(pfres, pfres2, 9*sizeof(T)); | |
| | | | |
| return pfres; | | return pfres; | |
| } | | } | |
| | | | |
| // mult4 | | // mult4 | |
| template <typename T> | | template <typename T> | |
| inline T* _mult4(T* pfres, const T* p1, const T* p2) | | inline T* _mult4(T* pfres, const T* p1, const T* p2) | |
| { | | { | |
| MATH_ASSERT( pfres != NULL && p1 != NULL && p2 != NULL ); | | MATH_ASSERT( pfres != NULL && p1 != NULL && p2 != NULL ); | |
| | | | |
| T* pfres2; | | T* pfres2; | |
|
| if( pfres == p1 || pfres == p2 ) pfres2 = (T*)alloca(16 * sizeof(T)); | | if((pfres == p1)||(pfres == p2)) pfres2 = (T*)alloca(16 * sizeof(T)); | |
| else pfres2 = pfres; | | else pfres2 = pfres; | |
| | | | |
| pfres2[0*4+0] = p1[0*4+0]*p2[0*4+0] + p1[0*4+1]*p2[1*4+0] + p1[0*4+2]*p
2[2*4+0] + p1[0*4+3]*p2[3*4+0]; | | pfres2[0*4+0] = p1[0*4+0]*p2[0*4+0] + p1[0*4+1]*p2[1*4+0] + p1[0*4+2]*p
2[2*4+0] + p1[0*4+3]*p2[3*4+0]; | |
| pfres2[0*4+1] = p1[0*4+0]*p2[0*4+1] + p1[0*4+1]*p2[1*4+1] + p1[0*4+2]*p
2[2*4+1] + p1[0*4+3]*p2[3*4+1]; | | pfres2[0*4+1] = p1[0*4+0]*p2[0*4+1] + p1[0*4+1]*p2[1*4+1] + p1[0*4+2]*p
2[2*4+1] + p1[0*4+3]*p2[3*4+1]; | |
| pfres2[0*4+2] = p1[0*4+0]*p2[0*4+2] + p1[0*4+1]*p2[1*4+2] + p1[0*4+2]*p
2[2*4+2] + p1[0*4+3]*p2[3*4+2]; | | pfres2[0*4+2] = p1[0*4+0]*p2[0*4+2] + p1[0*4+1]*p2[1*4+2] + p1[0*4+2]*p
2[2*4+2] + p1[0*4+3]*p2[3*4+2]; | |
| pfres2[0*4+3] = p1[0*4+0]*p2[0*4+3] + p1[0*4+1]*p2[1*4+3] + p1[0*4+2]*p
2[2*4+3] + p1[0*4+3]*p2[3*4+3]; | | pfres2[0*4+3] = p1[0*4+0]*p2[0*4+3] + p1[0*4+1]*p2[1*4+3] + p1[0*4+2]*p
2[2*4+3] + p1[0*4+3]*p2[3*4+3]; | |
| | | | |
| pfres2[1*4+0] = p1[1*4+0]*p2[0*4+0] + p1[1*4+1]*p2[1*4+0] + p1[1*4+2]*p
2[2*4+0] + p1[1*4+3]*p2[3*4+0]; | | pfres2[1*4+0] = p1[1*4+0]*p2[0*4+0] + p1[1*4+1]*p2[1*4+0] + p1[1*4+2]*p
2[2*4+0] + p1[1*4+3]*p2[3*4+0]; | |
| pfres2[1*4+1] = p1[1*4+0]*p2[0*4+1] + p1[1*4+1]*p2[1*4+1] + p1[1*4+2]*p
2[2*4+1] + p1[1*4+3]*p2[3*4+1]; | | pfres2[1*4+1] = p1[1*4+0]*p2[0*4+1] + p1[1*4+1]*p2[1*4+1] + p1[1*4+2]*p
2[2*4+1] + p1[1*4+3]*p2[3*4+1]; | |
| pfres2[1*4+2] = p1[1*4+0]*p2[0*4+2] + p1[1*4+1]*p2[1*4+2] + p1[1*4+2]*p
2[2*4+2] + p1[1*4+3]*p2[3*4+2]; | | pfres2[1*4+2] = p1[1*4+0]*p2[0*4+2] + p1[1*4+1]*p2[1*4+2] + p1[1*4+2]*p
2[2*4+2] + p1[1*4+3]*p2[3*4+2]; | |
| | | | |
| skipping to change at line 392 | | skipping to change at line 393 | |
| } | | } | |
| } | | } | |
| | | | |
| return pfres; | | return pfres; | |
| } | | } | |
| | | | |
| /// \brief Compute the determinant of a 3x3 matrix whose row stride stride
elements. | | /// \brief Compute the determinant of a 3x3 matrix whose row stride stride
elements. | |
| template <typename T> inline T matrixdet3(const T* pf, int stride) | | template <typename T> inline T matrixdet3(const T* pf, int stride) | |
| { | | { | |
| return pf[0*stride+2] * (pf[1*stride + 0] * pf[2*stride + 1] - pf[1*str
ide + 1] * pf[2*stride + 0]) + | | return pf[0*stride+2] * (pf[1*stride + 0] * pf[2*stride + 1] - pf[1*str
ide + 1] * pf[2*stride + 0]) + | |
|
| pf[1*stride+2] * (pf[0*stride + 1] * pf[2*stride + 0] - pf[0*stride | | pf[1*stride+2] * (pf[0*stride + 1] * pf[2*stride + 0] - pf[0*str | |
| + 0] * pf[2*stride + 1]) + | | ide + 0] * pf[2*stride + 1]) + | |
| pf[2*stride+2] * (pf[0*stride + 0] * pf[1*stride + 1] - pf[0*stride | | pf[2*stride+2] * (pf[0*stride + 0] * pf[1*stride + 1] - pf[0*str | |
| + 1] * pf[1*stride + 0]); | | ide + 1] * pf[1*stride + 0]); | |
| } | | } | |
| | | | |
| /** \brief 3x3 matrix inverse. | | /** \brief 3x3 matrix inverse. | |
| | | | |
| \param[in] pf the input 3x3 matrix | | \param[in] pf the input 3x3 matrix | |
| \param[out] pf the result of the operation, can be the same matrix as p
f | | \param[out] pf the result of the operation, can be the same matrix as p
f | |
| \param[out] pfdet if not NULL, fills it with the determinant of the sou
rce matrix | | \param[out] pfdet if not NULL, fills it with the determinant of the sou
rce matrix | |
| \param[in] stride the stride in elements between elements. | | \param[in] stride the stride in elements between elements. | |
|
| */ | | */ | |
| template <typename T> | | template <typename T> | |
| inline T* _inv3(const T* pf, T* pfres, T* pfdet, int stride) | | inline T* _inv3(const T* pf, T* pfres, T* pfdet, int stride) | |
| { | | { | |
|
| T* pfres2; | | T* pfres2; | |
| if( pfres == pf ) pfres2 = (T*)alloca(3 * stride * sizeof(T)); | | if( pfres == pf ) pfres2 = (T*)alloca(3 * stride * sizeof(T)); | |
| else pfres2 = pfres; | | else pfres2 = pfres; | |
| | | | |
|
| // inverse = C^t / det(pf) where C is the matrix of coefficients | | // inverse = C^t / det(pf) where C is the matrix of coefficients | |
| | | | |
|
| // calc C^t | | // calc C^t | |
| pfres2[0*stride + 0] = pf[1*stride + 1] * pf[2*stride + 2] - pf[1*st | | pfres2[0*stride + 0] = pf[1*stride + 1] * pf[2*stride + 2] - pf[1*strid | |
| ride + 2] * pf[2*stride + 1]; | | e + 2] * pf[2*stride + 1]; | |
| pfres2[0*stride + 1] = pf[0*stride + 2] * pf[2*stride + 1] - pf[0*st | | pfres2[0*stride + 1] = pf[0*stride + 2] * pf[2*stride + 1] - pf[0*strid | |
| ride + 1] * pf[2*stride + 2]; | | e + 1] * pf[2*stride + 2]; | |
| pfres2[0*stride + 2] = pf[0*stride + 1] * pf[1*stride + 2] - pf[0*st | | pfres2[0*stride + 2] = pf[0*stride + 1] * pf[1*stride + 2] - pf[0*strid | |
| ride + 2] * pf[1*stride + 1]; | | e + 2] * pf[1*stride + 1]; | |
| pfres2[1*stride + 0] = pf[1*stride + 2] * pf[2*stride + 0] - pf[1*st | | pfres2[1*stride + 0] = pf[1*stride + 2] * pf[2*stride + 0] - pf[1*strid | |
| ride + 0] * pf[2*stride + 2]; | | e + 0] * pf[2*stride + 2]; | |
| pfres2[1*stride + 1] = pf[0*stride + 0] * pf[2*stride + 2] - pf[0*st | | pfres2[1*stride + 1] = pf[0*stride + 0] * pf[2*stride + 2] - pf[0*strid | |
| ride + 2] * pf[2*stride + 0]; | | e + 2] * pf[2*stride + 0]; | |
| pfres2[1*stride + 2] = pf[0*stride + 2] * pf[1*stride + 0] - pf[0*st | | pfres2[1*stride + 2] = pf[0*stride + 2] * pf[1*stride + 0] - pf[0*strid | |
| ride + 0] * pf[1*stride + 2]; | | e + 0] * pf[1*stride + 2]; | |
| pfres2[2*stride + 0] = pf[1*stride + 0] * pf[2*stride + 1] - pf[1*st | | pfres2[2*stride + 0] = pf[1*stride + 0] * pf[2*stride + 1] - pf[1*strid | |
| ride + 1] * pf[2*stride + 0]; | | e + 1] * pf[2*stride + 0]; | |
| pfres2[2*stride + 1] = pf[0*stride + 1] * pf[2*stride + 0] - pf[0*st | | pfres2[2*stride + 1] = pf[0*stride + 1] * pf[2*stride + 0] - pf[0*strid | |
| ride + 0] * pf[2*stride + 1]; | | e + 0] * pf[2*stride + 1]; | |
| pfres2[2*stride + 2] = pf[0*stride + 0] * pf[1*stride + 1] - pf[0*st | | pfres2[2*stride + 2] = pf[0*stride + 0] * pf[1*stride + 1] - pf[0*strid | |
| ride + 1] * pf[1*stride + 0]; | | e + 1] * pf[1*stride + 0]; | |
| | | | |
|
| T fdet = pf[0*stride + 2] * pfres2[2*stride + 0] + pf[1*stride + 2] | | T fdet = pf[0*stride + 2] * pfres2[2*stride + 0] + pf[1*stride + 2] * p | |
| * pfres2[2*stride + 1] + | | fres2[2*stride + 1] + | |
| pf[2*stride + 2] * pfres2[2*stride + 2]; | | pf[2*stride + 2] * pfres2[2*stride + 2]; | |
| | | | |
|
| if( pfdet != NULL ) | | if( pfdet != NULL ) | |
| pfdet[0] = fdet; | | pfdet[0] = fdet; | |
| | | | |
| if( fabs(fdet) < 1e-12 ) { | | if( fabs(fdet) < 1e-12 ) { | |
| return NULL; | | return NULL; | |
| } | | } | |
| | | | |
|
| fdet = 1 / fdet; | | fdet = 1 / fdet; | |
| //if( pfdet != NULL ) *pfdet = fdet; | | //if( pfdet != NULL ) *pfdet = fdet; | |
| | | | |
|
| if( pfres != pf ) { | | if( pfres != pf ) { | |
| pfres[0*stride+0] *= fdet; pfres[0*stride+1] *= | | pfres[0*stride+0] *= fdet; pfres[0*stride+1] *= fdet; | |
| fdet; pfres[0*stride+2] *= fdet; | | pfres[0*stride+2] *= fdet; | |
| pfres[1*stride+0] *= fdet; pfres[1*stride+1] *= | | pfres[1*stride+0] *= fdet; pfres[1*stride+1] *= fdet; | |
| fdet; pfres[1*stride+2] *= fdet; | | pfres[1*stride+2] *= fdet; | |
| pfres[2*stride+0] *= fdet; pfres[2*stride+1] *= | | pfres[2*stride+0] *= fdet; pfres[2*stride+1] *= fdet; | |
| fdet; pfres[2*stride+2] *= fdet; | | pfres[2*stride+2] *= fdet; | |
| return pfres; | | return pfres; | |
| } | | } | |
| | | | |
|
| pfres[0*stride+0] = pfres2[0*stride+0] * fdet; | | pfres[0*stride+0] = pfres2[0*stride+0] * fdet; | |
| pfres[0*stride+1] = pfres2[0*stride+1] * fdet; | | pfres[0*stride+1] = pfres2[0*stride+1] * fdet; | |
| pfres[0*stride+2] = pfres2[0*stride+2] * fdet; | | pfres[0*stride+2] = pfres2[0*stride+2] * fdet; | |
| pfres[1*stride+0] = pfres2[1*stride+0] * fdet; | | pfres[1*stride+0] = pfres2[1*stride+0] * fdet; | |
| pfres[1*stride+1] = pfres2[1*stride+1] * fdet; | | pfres[1*stride+1] = pfres2[1*stride+1] * fdet; | |
| pfres[1*stride+2] = pfres2[1*stride+2] * fdet; | | pfres[1*stride+2] = pfres2[1*stride+2] * fdet; | |
| pfres[2*stride+0] = pfres2[2*stride+0] * fdet; | | pfres[2*stride+0] = pfres2[2*stride+0] * fdet; | |
| pfres[2*stride+1] = pfres2[2*stride+1] * fdet; | | pfres[2*stride+1] = pfres2[2*stride+1] * fdet; | |
| pfres[2*stride+2] = pfres2[2*stride+2] * fdet; | | pfres[2*stride+2] = pfres2[2*stride+2] * fdet; | |
| return pfres; | | return pfres; | |
| } | | } | |
| | | | |
| /// \brief 4x4 matrix inverse. | | /// \brief 4x4 matrix inverse. | |
| template <typename T> | | template <typename T> | |
| inline T* _inv4(const T* pf, T* pfres) | | inline T* _inv4(const T* pf, T* pfres) | |
| { | | { | |
|
| T* pfres2; | | T* pfres2; | |
| if( pfres == pf ) pfres2 = (T*)alloca(16 * sizeof(T)); | | if( pfres == pf ) pfres2 = (T*)alloca(16 * sizeof(T)); | |
| else pfres2 = pfres; | | else pfres2 = pfres; | |
| | | | |
|
| // inverse = C^t / det(pf) where C is the matrix of coefficients | | // inverse = C^t / det(pf) where C is the matrix of coefficients | |
| | | | |
|
| // calc C^t | | // calc C^t | |
| | | | |
|
| // determinants of all possibel 2x2 submatrices formed by last two r | | // determinants of all possibel 2x2 submatrices formed by last two rows | |
| ows | | T fd0, fd1, fd2; | |
| T fd0, fd1, fd2; | | T f1, f2, f3; | |
| T f1, f2, f3; | | fd0 = pf[2*4 + 0] * pf[3*4 + 1] - pf[2*4 + 1] * pf[3*4 + 0]; | |
| fd0 = pf[2*4 + 0] * pf[3*4 + 1] - pf[2*4 + 1] * pf[3*4 + 0]; | | fd1 = pf[2*4 + 1] * pf[3*4 + 2] - pf[2*4 + 2] * pf[3*4 + 1]; | |
| fd1 = pf[2*4 + 1] * pf[3*4 + 2] - pf[2*4 + 2] * pf[3*4 + 1]; | | fd2 = pf[2*4 + 2] * pf[3*4 + 3] - pf[2*4 + 3] * pf[3*4 + 2]; | |
| fd2 = pf[2*4 + 2] * pf[3*4 + 3] - pf[2*4 + 3] * pf[3*4 + 2]; | | | |
| | | | |
|
| f1 = pf[2*4 + 1] * pf[3*4 + 3] - pf[2*4 + 3] * pf[3*4 + 1]; | | f1 = pf[2*4 + 1] * pf[3*4 + 3] - pf[2*4 + 3] * pf[3*4 + 1]; | |
| f2 = pf[2*4 + 0] * pf[3*4 + 3] - pf[2*4 + 3] * pf[3*4 + 0]; | | f2 = pf[2*4 + 0] * pf[3*4 + 3] - pf[2*4 + 3] * pf[3*4 + 0]; | |
| f3 = pf[2*4 + 0] * pf[3*4 + 2] - pf[2*4 + 2] * pf[3*4 + 0]; | | f3 = pf[2*4 + 0] * pf[3*4 + 2] - pf[2*4 + 2] * pf[3*4 + 0]; | |
| | | | |
|
| pfres2[0*4 + 0] = pf[1*4 + 1] * fd2 - pf[1*4 + 2] * f1 + pf[1*4 + | | pfres2[0*4 + 0] = pf[1*4 + 1] * fd2 - pf[1*4 + 2] * f1 + pf[1*4 + 3] | |
| 3] * fd1; | | * fd1; | |
| pfres2[0*4 + 1] = -(pf[0*4 + 1] * fd2 - pf[0*4 + 2] * f1 + pf[0*4 + | | pfres2[0*4 + 1] = -(pf[0*4 + 1] * fd2 - pf[0*4 + 2] * f1 + pf[0*4 + 3] | |
| 3] * fd1); | | * fd1); | |
| | | | |
|
| pfres2[1*4 + 0] = -(pf[1*4 + 0] * fd2 - pf[1*4 + 2] * f2 + pf[1*4 + | | pfres2[1*4 + 0] = -(pf[1*4 + 0] * fd2 - pf[1*4 + 2] * f2 + pf[1*4 + 3] | |
| 3] * f3); | | * f3); | |
| pfres2[1*4 + 1] = pf[0*4 + 0] * fd2 - pf[0*4 + 2] * f2 + pf[0*4 + | | pfres2[1*4 + 1] = pf[0*4 + 0] * fd2 - pf[0*4 + 2] * f2 + pf[0*4 + 3] | |
| 3] * f3; | | * f3; | |
| | | | |
|
| pfres2[2*4 + 0] = pf[1*4 + 0] * f1 - pf[1*4 + 1] * f2 + pf[1*4 + | | pfres2[2*4 + 0] = pf[1*4 + 0] * f1 - pf[1*4 + 1] * f2 + pf[1*4 + 3] | |
| 3] * fd0; | | * fd0; | |
| pfres2[2*4 + 1] = -(pf[0*4 + 0] * f1 - pf[0*4 + 1] * f2 + pf[0*4 + | | pfres2[2*4 + 1] = -(pf[0*4 + 0] * f1 - pf[0*4 + 1] * f2 + pf[0*4 + 3] | |
| 3] * fd0); | | * fd0); | |
| | | | |
|
| pfres2[3*4 + 0] = -(pf[1*4 + 0] * fd1 - pf[1*4 + 1] * f3 + pf[1*4 + | | pfres2[3*4 + 0] = -(pf[1*4 + 0] * fd1 - pf[1*4 + 1] * f3 + pf[1*4 + 2] | |
| 2] * fd0); | | * fd0); | |
| pfres2[3*4 + 1] = pf[0*4 + 0] * fd1 - pf[0*4 + 1] * f3 + pf[0*4 + | | pfres2[3*4 + 1] = pf[0*4 + 0] * fd1 - pf[0*4 + 1] * f3 + pf[0*4 + 2] | |
| 2] * fd0; | | * fd0; | |
| | | | |
|
| // determinants of first 2 rows of 4x4 matrix | | // determinants of first 2 rows of 4x4 matrix | |
| fd0 = pf[0*4 + 0] * pf[1*4 + 1] - pf[0*4 + 1] * pf[1*4 + 0]; | | fd0 = pf[0*4 + 0] * pf[1*4 + 1] - pf[0*4 + 1] * pf[1*4 + 0]; | |
| fd1 = pf[0*4 + 1] * pf[1*4 + 2] - pf[0*4 + 2] * pf[1*4 + 1]; | | fd1 = pf[0*4 + 1] * pf[1*4 + 2] - pf[0*4 + 2] * pf[1*4 + 1]; | |
| fd2 = pf[0*4 + 2] * pf[1*4 + 3] - pf[0*4 + 3] * pf[1*4 + 2]; | | fd2 = pf[0*4 + 2] * pf[1*4 + 3] - pf[0*4 + 3] * pf[1*4 + 2]; | |
| | | | |
|
| f1 = pf[0*4 + 1] * pf[1*4 + 3] - pf[0*4 + 3] * pf[1*4 + 1]; | | f1 = pf[0*4 + 1] * pf[1*4 + 3] - pf[0*4 + 3] * pf[1*4 + 1]; | |
| f2 = pf[0*4 + 0] * pf[1*4 + 3] - pf[0*4 + 3] * pf[1*4 + 0]; | | f2 = pf[0*4 + 0] * pf[1*4 + 3] - pf[0*4 + 3] * pf[1*4 + 0]; | |
| f3 = pf[0*4 + 0] * pf[1*4 + 2] - pf[0*4 + 2] * pf[1*4 + 0]; | | f3 = pf[0*4 + 0] * pf[1*4 + 2] - pf[0*4 + 2] * pf[1*4 + 0]; | |
| | | | |
|
| pfres2[0*4 + 2] = pf[3*4 + 1] * fd2 - pf[3*4 + 2] * f1 + pf[3*4 + | | pfres2[0*4 + 2] = pf[3*4 + 1] * fd2 - pf[3*4 + 2] * f1 + pf[3*4 + 3] | |
| 3] * fd1; | | * fd1; | |
| pfres2[0*4 + 3] = -(pf[2*4 + 1] * fd2 - pf[2*4 + 2] * f1 + pf[2*4 + | | pfres2[0*4 + 3] = -(pf[2*4 + 1] * fd2 - pf[2*4 + 2] * f1 + pf[2*4 + 3] | |
| 3] * fd1); | | * fd1); | |
| | | | |
|
| pfres2[1*4 + 2] = -(pf[3*4 + 0] * fd2 - pf[3*4 + 2] * f2 + pf[3*4 + | | pfres2[1*4 + 2] = -(pf[3*4 + 0] * fd2 - pf[3*4 + 2] * f2 + pf[3*4 + 3] | |
| 3] * f3); | | * f3); | |
| pfres2[1*4 + 3] = pf[2*4 + 0] * fd2 - pf[2*4 + 2] * f2 + pf[2*4 + | | pfres2[1*4 + 3] = pf[2*4 + 0] * fd2 - pf[2*4 + 2] * f2 + pf[2*4 + 3] | |
| 3] * f3; | | * f3; | |
| | | | |
|
| pfres2[2*4 + 2] = pf[3*4 + 0] * f1 - pf[3*4 + 1] * f2 + pf[3*4 + | | pfres2[2*4 + 2] = pf[3*4 + 0] * f1 - pf[3*4 + 1] * f2 + pf[3*4 + 3] | |
| 3] * fd0; | | * fd0; | |
| pfres2[2*4 + 3] = -(pf[2*4 + 0] * f1 - pf[2*4 + 1] * f2 + pf[2*4 + | | pfres2[2*4 + 3] = -(pf[2*4 + 0] * f1 - pf[2*4 + 1] * f2 + pf[2*4 + 3] | |
| 3] * fd0); | | * fd0); | |
| | | | |
|
| pfres2[3*4 + 2] = -(pf[3*4 + 0] * fd1 - pf[3*4 + 1] * f3 + pf[3*4 + | | pfres2[3*4 + 2] = -(pf[3*4 + 0] * fd1 - pf[3*4 + 1] * f3 + pf[3*4 + 2] | |
| 2] * fd0); | | * fd0); | |
| pfres2[3*4 + 3] = pf[2*4 + 0] * fd1 - pf[2*4 + 1] * f3 + pf[2*4 + | | pfres2[3*4 + 3] = pf[2*4 + 0] * fd1 - pf[2*4 + 1] * f3 + pf[2*4 + 2] | |
| 2] * fd0; | | * fd0; | |
| | | | |
|
| T fdet = pf[0*4 + 3] * pfres2[3*4 + 0] + pf[1*4 + 3] * pfres2[3*4 + | | T fdet = pf[0*4 + 3] * pfres2[3*4 + 0] + pf[1*4 + 3] * pfres2[3*4 + 1] | |
| 1] + | | + | |
| pf[2*4 + 3] * pfres2[3*4 + 2] + pf[3*4 + 3] * pfres2 | | pf[2*4 + 3] * pfres2[3*4 + 2] + pf[3*4 + 3] * pfres2[3*4 + 3]; | |
| [3*4 + 3]; | | | |
| | | | |
|
| if( fabs(fdet) < 1e-9) return NULL; | | if( fabs(fdet) < 1e-9) return NULL; | |
| | | | |
|
| fdet = 1 / fdet; | | fdet = 1 / fdet; | |
| //if( pfdet != NULL ) *pfdet = fdet; | | //if( pfdet != NULL ) *pfdet = fdet; | |
| | | | |
|
| if( pfres2 == pfres ) { | | if( pfres2 == pfres ) { | |
| mult(pfres, fdet, 16); | | mult(pfres, fdet, 16); | |
| return pfres; | | return pfres; | |
| } | | } | |
| | | | |
|
| int i = 0; | | int i = 0; | |
| while(i < 16) { | | while(i < 16) { | |
| pfres[i] = pfres2[i] * fdet; | | pfres[i] = pfres2[i] * fdet; | |
| ++i; | | ++i; | |
| } | | } | |
| | | | |
|
| return pfres; | | return pfres; | |
| } | | } | |
| | | | |
| /// \brief Transpose a 3x3 matrix. | | /// \brief Transpose a 3x3 matrix. | |
| template <typename T> | | template <typename T> | |
| inline T* _transpose3(const T* pf, T* pfres) | | inline T* _transpose3(const T* pf, T* pfres) | |
| { | | { | |
|
| MATH_ASSERT( pf != NULL && pfres != NULL ); | | MATH_ASSERT( pf != NULL && pfres != NULL ); | |
| | | | |
|
| if( pf == pfres ) { | | if( pf == pfres ) { | |
| std::swap(pfres[1], pfres[3]); | | std::swap(pfres[1], pfres[3]); | |
|
| std::swap(pfres[2], pfres[6]); | | std::swap(pfres[2], pfres[6]); | |
| std::swap(pfres[5], pfres[7]); | | std::swap(pfres[5], pfres[7]); | |
| return pfres; | | return pfres; | |
| } | | } | |
| | | | |
|
| pfres[0] = pf[0]; pfres[1] = pf[3]; pfres[2] = pf[6]; | | pfres[0] = pf[0]; pfres[1] = pf[3]; pfres[2] = pf[6]; | |
| pfres[3] = pf[1]; pfres[4] = pf[4]; pfres[5] = pf[7]; | | pfres[3] = pf[1]; pfres[4] = pf[4]; pfres[5] = pf[7]; | |
| pfres[6] = pf[2]; pfres[7] = pf[5]; pfres[8] = pf[8]; | | pfres[6] = pf[2]; pfres[7] = pf[5]; pfres[8] = pf[8]; | |
| | | | |
|
| return pfres; | | return pfres; | |
| } | | } | |
| | | | |
| /// \brief Transpose a 4x4 matrix. | | /// \brief Transpose a 4x4 matrix. | |
| template <typename T> | | template <typename T> | |
| inline T* _transpose4(const T* pf, T* pfres) | | inline T* _transpose4(const T* pf, T* pfres) | |
| { | | { | |
|
| MATH_ASSERT( pf != NULL && pfres != NULL ); | | MATH_ASSERT( pf != NULL && pfres != NULL ); | |
| | | | |
|
| if( pf == pfres ) { | | if( pf == pfres ) { | |
| std::swap(pfres[1], pfres[4]); | | std::swap(pfres[1], pfres[4]); | |
| std::swap(pfres[2], pfres[8]); | | std::swap(pfres[2], pfres[8]); | |
| std::swap(pfres[3], pfres[12]); | | std::swap(pfres[3], pfres[12]); | |
| std::swap(pfres[6], pfres[9]); | | std::swap(pfres[6], pfres[9]); | |
| std::swap(pfres[7], pfres[13]); | | std::swap(pfres[7], pfres[13]); | |
| std::swap(pfres[11], pfres[15]); | | std::swap(pfres[11], pfres[15]); | |
| return pfres; | | return pfres; | |
| } | | } | |
| | | | |
|
| pfres[0] = pf[0]; pfres[1] = pf[4]; pfres[2] = pf[8]; | | pfres[0] = pf[0]; pfres[1] = pf[4]; pfres[2] = pf[8]; | |
| pfres[3] = pf[12]; | | pfres[3] = pf[12]; | |
| pfres[4] = pf[1]; pfres[5] = pf[5]; pfres[6] = pf[9]; | | pfres[4] = pf[1]; pfres[5] = pf[5]; pfres[6] = pf[9]; | |
| pfres[7] = pf[13]; | | pfres[7] = pf[13]; | |
| pfres[8] = pf[2]; pfres[9] = pf[6]; pfres[10] = pf[10]; | | pfres[8] = pf[2]; pfres[9] = pf[6]; pfres[10] = pf[10]; | |
| pfres[11] = pf[14]; | | pfres[11] = pf[14]; | |
| pfres[12] = pf[3]; pfres[13] = pf[7]; pfres[14] = pf[11]; | | pfres[12] = pf[3]; pfres[13] = pf[7]; pfres[14] = pf[11]; | |
| pfres[15] = pf[15]; | | pfres[15] = pf[15]; | |
| return pfres; | | return pfres; | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| inline T _dot2(const T* pf1, const T* pf2) | | inline T _dot2(const T* pf1, const T* pf2) | |
| { | | { | |
|
| MATH_ASSERT( pf1 != NULL && pf2 != NULL ); | | MATH_ASSERT( pf1 != NULL && pf2 != NULL ); | |
| return pf1[0]*pf2[0] + pf1[1]*pf2[1]; | | return pf1[0]*pf2[0] + pf1[1]*pf2[1]; | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| inline T _dot3(const T* pf1, const T* pf2) | | inline T _dot3(const T* pf1, const T* pf2) | |
| { | | { | |
|
| MATH_ASSERT( pf1 != NULL && pf2 != NULL ); | | MATH_ASSERT( pf1 != NULL && pf2 != NULL ); | |
| return pf1[0]*pf2[0] + pf1[1]*pf2[1] + pf1[2]*pf2[2]; | | return pf1[0]*pf2[0] + pf1[1]*pf2[1] + pf1[2]*pf2[2]; | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| inline T _dot4(const T* pf1, const T* pf2) | | inline T _dot4(const T* pf1, const T* pf2) | |
| { | | { | |
|
| MATH_ASSERT( pf1 != NULL && pf2 != NULL ); | | MATH_ASSERT( pf1 != NULL && pf2 != NULL ); | |
| return pf1[0]*pf2[0] + pf1[1]*pf2[1] + pf1[2]*pf2[2] + pf1[3] * pf2[ | | return pf1[0]*pf2[0] + pf1[1]*pf2[1] + pf1[2]*pf2[2] + pf1[3] * pf2[3]; | |
| 3]; | | | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| inline T _lengthsqr2(const T* pf) | | inline T _lengthsqr2(const T* pf) | |
| { | | { | |
|
| MATH_ASSERT( pf != NULL ); | | MATH_ASSERT( pf != NULL ); | |
| return pf[0] * pf[0] + pf[1] * pf[1]; | | return pf[0] * pf[0] + pf[1] * pf[1]; | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| inline T _lengthsqr3(const T* pf) | | inline T _lengthsqr3(const T* pf) | |
| { | | { | |
|
| MATH_ASSERT( pf != NULL ); | | MATH_ASSERT( pf != NULL ); | |
| return pf[0] * pf[0] + pf[1] * pf[1] + pf[2] * pf[2]; | | return pf[0] * pf[0] + pf[1] * pf[1] + pf[2] * pf[2]; | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| inline T _lengthsqr4(const T* pf) | | inline T _lengthsqr4(const T* pf) | |
| { | | { | |
|
| MATH_ASSERT( pf != NULL ); | | MATH_ASSERT( pf != NULL ); | |
| return pf[0] * pf[0] + pf[1] * pf[1] + pf[2] * pf[2] + pf[3] * pf[3] | | return pf[0] * pf[0] + pf[1] * pf[1] + pf[2] * pf[2] + pf[3] * pf[3]; | |
| ; | | | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| inline T* _normalize2(T* pfout, const T* pf) | | inline T* _normalize2(T* pfout, const T* pf) | |
| { | | { | |
|
| MATH_ASSERT(pf != NULL); | | MATH_ASSERT(pf != NULL); | |
| | | | |
|
| T f = pf[0]*pf[0] + pf[1]*pf[1]; | | T f = pf[0]*pf[0] + pf[1]*pf[1]; | |
| f = 1 / sqrt(f); | | f = 1 / sqrt(f); | |
| pfout[0] = pf[0] * f; | | pfout[0] = pf[0] * f; | |
| pfout[1] = pf[1] * f; | | pfout[1] = pf[1] * f; | |
| | | | |
|
| return pfout; | | return pfout; | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| inline T* _normalize3(T* pfout, const T* pf) | | inline T* _normalize3(T* pfout, const T* pf) | |
| { | | { | |
|
| MATH_ASSERT(pf != NULL); | | MATH_ASSERT(pf != NULL); | |
| | | | |
|
| T f = pf[0]*pf[0] + pf[1]*pf[1] + pf[2]*pf[2]; | | T f = pf[0]*pf[0] + pf[1]*pf[1] + pf[2]*pf[2]; | |
| | | | |
|
| f = 1 / sqrt(f); | | f = 1 / sqrt(f); | |
| pfout[0] = pf[0] * f; | | pfout[0] = pf[0] * f; | |
| pfout[1] = pf[1] * f; | | pfout[1] = pf[1] * f; | |
| pfout[2] = pf[2] * f; | | pfout[2] = pf[2] * f; | |
| | | | |
|
| return pfout; | | return pfout; | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| inline T* _normalize4(T* pfout, const T* pf) | | inline T* _normalize4(T* pfout, const T* pf) | |
| { | | { | |
|
| MATH_ASSERT(pf != NULL); | | MATH_ASSERT(pf != NULL); | |
| | | | |
|
| T f = pf[0]*pf[0] + pf[1]*pf[1] + pf[2]*pf[2] + pf[3]*pf[3]; | | T f = pf[0]*pf[0] + pf[1]*pf[1] + pf[2]*pf[2] + pf[3]*pf[3]; | |
| | | | |
|
| f = 1 / sqrt(f); | | f = 1 / sqrt(f); | |
| pfout[0] = pf[0] * f; | | pfout[0] = pf[0] * f; | |
| pfout[1] = pf[1] * f; | | pfout[1] = pf[1] * f; | |
| pfout[2] = pf[2] * f; | | pfout[2] = pf[2] * f; | |
| pfout[3] = pf[3] * f; | | pfout[3] = pf[3] * f; | |
| | | | |
|
| return pfout; | | return pfout; | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| inline T* _cross3(T* pfout, const T* pf1, const T* pf2) | | inline T* _cross3(T* pfout, const T* pf1, const T* pf2) | |
| { | | { | |
|
| MATH_ASSERT( pfout != NULL && pf1 != NULL && pf2 != NULL ); | | MATH_ASSERT( pfout != NULL && pf1 != NULL && pf2 != NULL ); | |
| | | | |
| T temp[3]; | | T temp[3]; | |
|
| temp[0] = pf1[1] * pf2[2] - pf1[2] * pf2[1]; | | temp[0] = pf1[1] * pf2[2] - pf1[2] * pf2[1]; | |
| temp[1] = pf1[2] * pf2[0] - pf1[0] * pf2[2]; | | temp[1] = pf1[2] * pf2[0] - pf1[0] * pf2[2]; | |
| temp[2] = pf1[0] * pf2[1] - pf1[1] * pf2[0]; | | temp[2] = pf1[0] * pf2[1] - pf1[1] * pf2[0]; | |
| | | | |
|
| pfout[0] = temp[0]; pfout[1] = temp[1]; pfout[2] = temp[2]; | | pfout[0] = temp[0]; pfout[1] = temp[1]; pfout[2] = temp[2]; | |
| return pfout; | | return pfout; | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| inline T* _transnorm3(T* pfout, const T* pfmat, const T* pf) | | inline T* _transnorm3(T* pfout, const T* pfmat, const T* pf) | |
| { | | { | |
|
| MATH_ASSERT( pfout != NULL && pf != NULL && pfmat != NULL ); | | MATH_ASSERT( pfout != NULL && pf != NULL && pfmat != NULL ); | |
| | | | |
| T dummy[3]; | | T dummy[3]; | |
|
| T* pfreal = (pfout == pf) ? dummy : pfout; | | T* pfreal = (pfout == pf) ? dummy : pfout; | |
| | | | |
|
| pfreal[0] = pf[0] * pfmat[0] + pf[1] * pfmat[1] + pf[2] * pfmat[2]; | | pfreal[0] = pf[0] * pfmat[0] + pf[1] * pfmat[1] + pf[2] * pfmat[2]; | |
| pfreal[1] = pf[0] * pfmat[3] + pf[1] * pfmat[4] + pf[2] * pfmat[5]; | | pfreal[1] = pf[0] * pfmat[3] + pf[1] * pfmat[4] + pf[2] * pfmat[5]; | |
| pfreal[2] = pf[0] * pfmat[6] + pf[1] * pfmat[7] + pf[2] * pfmat[8]; | | pfreal[2] = pf[0] * pfmat[6] + pf[1] * pfmat[7] + pf[2] * pfmat[8]; | |
| | | | |
| if( pfout ==pf ) { | | if( pfout ==pf ) { | |
| pfout[0] = pfreal[0]; | | pfout[0] = pfreal[0]; | |
| pfout[1] = pfreal[1]; | | pfout[1] = pfreal[1]; | |
| pfout[2] = pfreal[2]; | | pfout[2] = pfreal[2]; | |
| } | | } | |
| | | | |
|
| return pfout; | | return pfout; | |
| } | | } | |
| | | | |
|
| inline float* mult4(float* pfres, const float* pf1, const float* pf2) { ret | | inline float* mult4(float* pfres, const float* pf1, const float* pf2) { | |
| urn _mult4<float>(pfres, pf1, pf2); } | | return _mult4<float>(pfres, pf1, pf2); | |
| | | } | |
| // pf1^T * pf2 | | // pf1^T * pf2 | |
|
| inline float* multtrans3(float* pfres, const float* pf1, const float* pf2) | | inline float* multtrans3(float* pfres, const float* pf1, const float* pf2) | |
| { return _multtrans3<float>(pfres, pf1, pf2); } | | { | |
| inline float* multtrans4(float* pfres, const float* pf1, const float* pf2) | | return _multtrans3<float>(pfres, pf1, pf2); | |
| { return _multtrans4<float>(pfres, pf1, pf2); } | | } | |
| inline float* transnorm3(float* pfout, const float* pfmat, const float* pf) | | inline float* multtrans4(float* pfres, const float* pf1, const float* pf2) | |
| { return _transnorm3<float>(pfout, pfmat, pf); } | | { | |
| | | return _multtrans4<float>(pfres, pf1, pf2); | |
| | | } | |
| | | inline float* transnorm3(float* pfout, const float* pfmat, const float* pf) | |
| | | { | |
| | | return _transnorm3<float>(pfout, pfmat, pf); | |
| | | } | |
| | | | |
|
| inline float* transpose3(const float* pf, float* pfres) { return _transpose | | inline float* transpose3(const float* pf, float* pfres) { | |
| 3<float>(pf, pfres); } | | return _transpose3<float>(pf, pfres); | |
| inline float* transpose4(const float* pf, float* pfres) { return _transpose | | } | |
| 4<float>(pf, pfres); } | | inline float* transpose4(const float* pf, float* pfres) { | |
| | | return _transpose4<float>(pf, pfres); | |
| | | } | |
| | | | |
|
| inline float dot2(const float* pf1, const float* pf2) { return _dot2<float> | | inline float dot2(const float* pf1, const float* pf2) { | |
| (pf1, pf2); } | | return _dot2<float>(pf1, pf2); | |
| inline float dot3(const float* pf1, const float* pf2) { return _dot3<float> | | } | |
| (pf1, pf2); } | | inline float dot3(const float* pf1, const float* pf2) { | |
| inline float dot4(const float* pf1, const float* pf2) { return _dot4<float> | | return _dot3<float>(pf1, pf2); | |
| (pf1, pf2); } | | } | |
| | | inline float dot4(const float* pf1, const float* pf2) { | |
| | | return _dot4<float>(pf1, pf2); | |
| | | } | |
| | | | |
|
| inline float lengthsqr2(const float* pf) { return _lengthsqr2<float>(pf); } | | inline float lengthsqr2(const float* pf) { | |
| inline float lengthsqr3(const float* pf) { return _lengthsqr3<float>(pf); } | | return _lengthsqr2<float>(pf); | |
| inline float lengthsqr4(const float* pf) { return _lengthsqr4<float>(pf); } | | } | |
| | | inline float lengthsqr3(const float* pf) { | |
| | | return _lengthsqr3<float>(pf); | |
| | | } | |
| | | inline float lengthsqr4(const float* pf) { | |
| | | return _lengthsqr4<float>(pf); | |
| | | } | |
| | | | |
|
| inline float* normalize2(float* pfout, const float* pf) { return _normalize | | inline float* normalize2(float* pfout, const float* pf) { | |
| 2<float>(pfout, pf); } | | return _normalize2<float>(pfout, pf); | |
| inline float* normalize3(float* pfout, const float* pf) { return _normalize | | } | |
| 3<float>(pfout, pf); } | | inline float* normalize3(float* pfout, const float* pf) { | |
| inline float* normalize4(float* pfout, const float* pf) { return _normalize | | return _normalize3<float>(pfout, pf); | |
| 4<float>(pfout, pf); } | | } | |
| | | inline float* normalize4(float* pfout, const float* pf) { | |
| | | return _normalize4<float>(pfout, pf); | |
| | | } | |
| | | | |
|
| inline float* cross3(float* pfout, const float* pf1, const float* pf2) { re | | inline float* cross3(float* pfout, const float* pf1, const float* pf2) { | |
| turn _cross3<float>(pfout, pf1, pf2); } | | return _cross3<float>(pfout, pf1, pf2); | |
| | | } | |
| | | | |
| // multiplies 3x3 matrices | | // multiplies 3x3 matrices | |
|
| inline float* mult3_s4(float* pfres, const float* pf1, const float* pf2) { | | inline float* mult3_s4(float* pfres, const float* pf1, const float* pf2) { | |
| return _mult3_s4<float>(pfres, pf1, pf2); } | | return _mult3_s4<float>(pfres, pf1, pf2); | |
| inline float* mult3_s3(float* pfres, const float* pf1, const float* pf2) { | | } | |
| return _mult3_s3<float>(pfres, pf1, pf2); } | | inline float* mult3_s3(float* pfres, const float* pf1, const float* pf2) { | |
| | | return _mult3_s3<float>(pfres, pf1, pf2); | |
| | | } | |
| | | | |
|
| inline float* inv3(const float* pf, float* pfres, float* pfdet, int stride) | | inline float* inv3(const float* pf, float* pfres, float* pfdet, int stride) | |
| { return _inv3<float>(pf, pfres, pfdet, stride); } | | { | |
| inline float* inv4(const float* pf, float* pfres) { return _inv4<float>(pf, | | return _inv3<float>(pf, pfres, pfdet, stride); | |
| pfres); } | | } | |
| | | inline float* inv4(const float* pf, float* pfres) { | |
| | | return _inv4<float>(pf, pfres); | |
| | | } | |
| | | | |
|
| inline double* mult4(double* pfres, const double* pf1, const double* pf2) { | | inline double* mult4(double* pfres, const double* pf1, const double* pf2) { | |
| return _mult4<double>(pfres, pf1, pf2); } | | return _mult4<double>(pfres, pf1, pf2); | |
| | | } | |
| // pf1^T * pf2 | | // pf1^T * pf2 | |
|
| inline double* multtrans3(double* pfres, const double* pf1, const double* p | | inline double* multtrans3(double* pfres, const double* pf1, const double* p | |
| f2) { return _multtrans3<double>(pfres, pf1, pf2); } | | f2) { | |
| inline double* multtrans4(double* pfres, const double* pf1, const double* p | | return _multtrans3<double>(pfres, pf1, pf2); | |
| f2) { return _multtrans4<double>(pfres, pf1, pf2); } | | } | |
| inline double* transnorm3(double* pfout, const double* pfmat, const double* | | inline double* multtrans4(double* pfres, const double* pf1, const double* p | |
| pf) { return _transnorm3<double>(pfout, pfmat, pf); } | | f2) { | |
| | | return _multtrans4<double>(pfres, pf1, pf2); | |
| | | } | |
| | | inline double* transnorm3(double* pfout, const double* pfmat, const double* | |
| | | pf) { | |
| | | return _transnorm3<double>(pfout, pfmat, pf); | |
| | | } | |
| | | | |
|
| inline double* transpose3(const double* pf, double* pfres) { return _transp | | inline double* transpose3(const double* pf, double* pfres) { | |
| ose3<double>(pf, pfres); } | | return _transpose3<double>(pf, pfres); | |
| inline double* transpose4(const double* pf, double* pfres) { return _transp | | } | |
| ose4<double>(pf, pfres); } | | inline double* transpose4(const double* pf, double* pfres) { | |
| | | return _transpose4<double>(pf, pfres); | |
| | | } | |
| | | | |
|
| inline double dot2(const double* pf1, const double* pf2) { return _dot2<dou | | inline double dot2(const double* pf1, const double* pf2) { | |
| ble>(pf1, pf2); } | | return _dot2<double>(pf1, pf2); | |
| inline double dot3(const double* pf1, const double* pf2) { return _dot3<dou | | } | |
| ble>(pf1, pf2); } | | inline double dot3(const double* pf1, const double* pf2) { | |
| inline double dot4(const double* pf1, const double* pf2) { return _dot4<dou | | return _dot3<double>(pf1, pf2); | |
| ble>(pf1, pf2); } | | } | |
| | | inline double dot4(const double* pf1, const double* pf2) { | |
| | | return _dot4<double>(pf1, pf2); | |
| | | } | |
| | | | |
|
| inline double lengthsqr2(const double* pf) { return _lengthsqr2<double>(pf) | | inline double lengthsqr2(const double* pf) { | |
| ; } | | return _lengthsqr2<double>(pf); | |
| inline double lengthsqr3(const double* pf) { return _lengthsqr3<double>(pf) | | } | |
| ; } | | inline double lengthsqr3(const double* pf) { | |
| inline double lengthsqr4(const double* pf) { return _lengthsqr4<double>(pf) | | return _lengthsqr3<double>(pf); | |
| ; } | | } | |
| | | inline double lengthsqr4(const double* pf) { | |
| | | return _lengthsqr4<double>(pf); | |
| | | } | |
| | | | |
|
| inline double* normalize2(double* pfout, const double* pf) { return _normal | | inline double* normalize2(double* pfout, const double* pf) { | |
| ize2<double>(pfout, pf); } | | return _normalize2<double>(pfout, pf); | |
| inline double* normalize3(double* pfout, const double* pf) { return _normal | | } | |
| ize3<double>(pfout, pf); } | | inline double* normalize3(double* pfout, const double* pf) { | |
| inline double* normalize4(double* pfout, const double* pf) { return _normal | | return _normalize3<double>(pfout, pf); | |
| ize4<double>(pfout, pf); } | | } | |
| | | inline double* normalize4(double* pfout, const double* pf) { | |
| | | return _normalize4<double>(pfout, pf); | |
| | | } | |
| | | | |
|
| inline double* cross3(double* pfout, const double* pf1, const double* pf2) | | inline double* cross3(double* pfout, const double* pf1, const double* pf2) | |
| { return _cross3<double>(pfout, pf1, pf2); } | | { | |
| | | return _cross3<double>(pfout, pf1, pf2); | |
| | | } | |
| | | | |
| // multiplies 3x3 matrices | | // multiplies 3x3 matrices | |
|
| inline double* mult3_s4(double* pfres, const double* pf1, const double* pf2 | | inline double* mult3_s4(double* pfres, const double* pf1, const double* pf2 | |
| ) { return _mult3_s4<double>(pfres, pf1, pf2); } | | ) { | |
| inline double* mult3_s3(double* pfres, const double* pf1, const double* pf2 | | return _mult3_s4<double>(pfres, pf1, pf2); | |
| ) { return _mult3_s3<double>(pfres, pf1, pf2); } | | } | |
| | | inline double* mult3_s3(double* pfres, const double* pf1, const double* pf2 | |
| | | ) { | |
| | | return _mult3_s3<double>(pfres, pf1, pf2); | |
| | | } | |
| | | | |
|
| inline double* inv3(const double* pf, double* pfres, double* pfdet, int str | | inline double* inv3(const double* pf, double* pfres, double* pfdet, int str | |
| ide) { return _inv3<double>(pf, pfres, pfdet, stride); } | | ide) { | |
| inline double* inv4(const double* pf, double* pfres) { return _inv4<double> | | return _inv3<double>(pf, pfres, pfdet, stride); | |
| (pf, pfres); } | | } | |
| | | inline double* inv4(const double* pf, double* pfres) { | |
| | | return _inv4<double>(pf, pfres); | |
| | | } | |
| | | | |
| template <typename T, typename R, typename S> | | template <typename T, typename R, typename S> | |
| inline S* mult(T* pf1, R* pf2, int r1, int c1, int c2, S* pfres, bool badd) | | inline S* mult(T* pf1, R* pf2, int r1, int c1, int c2, S* pfres, bool badd) | |
| { | | { | |
|
| MATH_ASSERT( pf1 != NULL && pf2 != NULL && pfres != NULL); | | MATH_ASSERT( pf1 != NULL && pf2 != NULL && pfres != NULL); | |
| int j, k; | | int j, k; | |
| | | | |
|
| if( !badd ) memset(pfres, 0, sizeof(S) * r1 * c2); | | if( !badd ) memset(pfres, 0, sizeof(S) * r1 * c2); | |
| | | | |
|
| while(r1 > 0) { | | while(r1 > 0) { | |
| --r1; | | --r1; | |
| | | | |
|
| j = 0; | | j = 0; | |
| while(j < c2) { | | while(j < c2) { | |
| k = 0; | | k = 0; | |
| while(k < c1) { | | while(k < c1) { | |
| pfres[j] += (S)(pf1[k] * pf2[k*c2 + j]); | | pfres[j] += (S)(pf1[k] * pf2[k*c2 + j]); | |
| ++k; | | ++k; | |
| } | | } | |
| ++j; | | ++j; | |
| } | | } | |
| | | | |
|
| pf1 += c1; | | pf1 += c1; | |
| pfres += c2; | | pfres += c2; | |
| } | | } | |
| | | | |
|
| return pfres; | | return pfres; | |
| } | | } | |
| | | | |
| template <typename T, typename R, typename S> | | template <typename T, typename R, typename S> | |
| inline S* multtrans(T* pf1, R* pf2, int r1, int c1, int c2, S* pfres, bool
badd) | | inline S* multtrans(T* pf1, R* pf2, int r1, int c1, int c2, S* pfres, bool
badd) | |
| { | | { | |
|
| MATH_ASSERT( pf1 != NULL && pf2 != NULL && pfres != NULL); | | MATH_ASSERT( pf1 != NULL && pf2 != NULL && pfres != NULL); | |
| int i, j, k; | | int i, j, k; | |
| | | | |
|
| if( !badd ) memset(pfres, 0, sizeof(S) * c1 * c2); | | if( !badd ) memset(pfres, 0, sizeof(S) * c1 * c2); | |
| | | | |
|
| i = 0; | | i = 0; | |
| while(i < c1) { | | while(i < c1) { | |
| | | | |
|
| j = 0; | | j = 0; | |
| while(j < c2) { | | while(j < c2) { | |
| | | | |
|
| k = 0; | | k = 0; | |
| while(k < r1) { | | while(k < r1) { | |
| pfres[j] += (S)(pf1[k*c1] * pf2[k*c2 + j]); | | pfres[j] += (S)(pf1[k*c1] * pf2[k*c2 + j]); | |
| ++k; | | ++k; | |
| } | | } | |
| ++j; | | ++j; | |
| } | | } | |
| | | | |
|
| pfres += c2; | | pfres += c2; | |
| ++pf1; | | ++pf1; | |
| | | | |
|
| ++i; | | ++i; | |
| } | | } | |
| | | | |
|
| return pfres; | | return pfres; | |
| } | | } | |
| | | | |
| template <typename T, typename R, typename S> | | template <typename T, typename R, typename S> | |
| inline S* multtrans_to2(T* pf1, R* pf2, int r1, int c1, int r2, S* pfres, b
ool badd) | | inline S* multtrans_to2(T* pf1, R* pf2, int r1, int c1, int r2, S* pfres, b
ool badd) | |
| { | | { | |
|
| MATH_ASSERT( pf1 != NULL && pf2 != NULL && pfres != NULL); | | MATH_ASSERT( pf1 != NULL && pf2 != NULL && pfres != NULL); | |
| int j, k; | | int j, k; | |
| | | | |
|
| if( !badd ) memset(pfres, 0, sizeof(S) * r1 * r2); | | if( !badd ) memset(pfres, 0, sizeof(S) * r1 * r2); | |
| | | | |
|
| while(r1 > 0) { | | while(r1 > 0) { | |
| --r1; | | --r1; | |
| | | | |
|
| j = 0; | | j = 0; | |
| while(j < r2) { | | while(j < r2) { | |
| k = 0; | | k = 0; | |
| while(k < c1) { | | while(k < c1) { | |
| pfres[j] += (S)(pf1[k] * pf2[j*c1 + k]); | | pfres[j] += (S)(pf1[k] * pf2[j*c1 + k]); | |
| ++k; | | ++k; | |
| } | | } | |
| ++j; | | ++j; | |
| } | | } | |
| | | | |
|
| pf1 += c1; | | pf1 += c1; | |
| pfres += r2; | | pfres += r2; | |
|
| } | | } | |
| | | | |
|
| return pfres; | | return pfres; | |
| } | | } | |
| | | | |
| template <typename T> inline T* multto1(T* pf1, T* pf2, int r, int c, T* pf
temp) | | template <typename T> inline T* multto1(T* pf1, T* pf2, int r, int c, T* pf
temp) | |
| { | | { | |
|
| MATH_ASSERT( pf1 != NULL && pf2 != NULL ); | | MATH_ASSERT( pf1 != NULL && pf2 != NULL ); | |
| | | | |
|
| int j, k; | | int j, k; | |
| bool bdel = false; | | bool bdel = false; | |
| | | | |
|
| if( pftemp == NULL ) { | | if( pftemp == NULL ) { | |
| pftemp = new T[c]; | | pftemp = new T[c]; | |
| bdel = true; | | bdel = true; | |
| } | | } | |
| | | | |
|
| while(r > 0) { | | while(r > 0) { | |
| --r; | | --r; | |
| | | | |
|
| j = 0; | | j = 0; | |
| while(j < c) { | | while(j < c) { | |
| | | | |
|
| pftemp[j] = 0.0; | | pftemp[j] = 0.0; | |
| | | | |
|
| k = 0; | | k = 0; | |
| while(k < c) { | | while(k < c) { | |
| pftemp[j] += pf1[k] * pf2[k*c + j]; | | pftemp[j] += pf1[k] * pf2[k*c + j]; | |
| ++k; | | ++k; | |
| } | | } | |
| ++j; | | ++j; | |
| } | | } | |
| | | | |
|
| memcpy(pf1, pftemp, c * sizeof(T)); | | memcpy(pf1, pftemp, c * sizeof(T)); | |
| pf1 += c; | | pf1 += c; | |
| } | | } | |
| | | | |
|
| if( bdel ) delete[] pftemp; | | if( bdel ) delete[] pftemp; | |
| | | | |
|
| return pf1; | | return pf1; | |
| } | | } | |
| | | | |
| template <typename T, typename S> inline T* multto2(T* pf1, S* pf2, int r2,
int c2, S* pftemp) | | template <typename T, typename S> inline T* multto2(T* pf1, S* pf2, int r2,
int c2, S* pftemp) | |
| { | | { | |
|
| MATH_ASSERT( pf1 != NULL && pf2 != NULL ); | | MATH_ASSERT( pf1 != NULL && pf2 != NULL ); | |
| | | | |
|
| int i, j, k; | | int i, j, k; | |
| bool bdel = false; | | bool bdel = false; | |
| | | | |
|
| if( pftemp == NULL ) { | | if( pftemp == NULL ) { | |
| pftemp = new S[r2]; | | pftemp = new S[r2]; | |
| bdel = true; | | bdel = true; | |
| } | | } | |
| | | | |
|
| // do columns first | | // do columns first | |
| j = 0; | | j = 0; | |
| while(j < c2) { | | while(j < c2) { | |
| i = 0; | | i = 0; | |
| while(i < r2) { | | while(i < r2) { | |
| | | | |
|
| pftemp[i] = 0.0; | | pftemp[i] = 0.0; | |
| | | | |
|
| k = 0; | | k = 0; | |
| while(k < r2) { | | while(k < r2) { | |
| pftemp[i] += pf1[i*r2 + k] * pf2[k*c2 + j]; | | pftemp[i] += pf1[i*r2 + k] * pf2[k*c2 + j]; | |
| ++k; | | ++k; | |
| } | | } | |
| ++i; | | ++i; | |
| } | | } | |
| | | | |
|
| i = 0; | | i = 0; | |
| while(i < r2) { | | while(i < r2) { | |
| *(pf2+i*c2+j) = pftemp[i]; | | *(pf2+i*c2+j) = pftemp[i]; | |
| ++i; | | ++i; | |
| } | | } | |
| | | | |
|
| ++j; | | ++j; | |
| } | | } | |
| | | | |
|
| if( bdel ) delete[] pftemp; | | if( bdel ) delete[] pftemp; | |
| | | | |
|
| return pf1; | | return pf1; | |
| } | | } | |
| | | | |
| template <typename T> inline void add(T* pf1, T* pf2, int r) | | template <typename T> inline void add(T* pf1, T* pf2, int r) | |
| { | | { | |
|
| MATH_ASSERT( pf1 != NULL && pf2 != NULL); | | MATH_ASSERT( pf1 != NULL && pf2 != NULL); | |
| | | | |
|
| while(r > 0) { | | while(r > 0) { | |
| --r; | | --r; | |
| pf1[r] += pf2[r]; | | pf1[r] += pf2[r]; | |
| } | | } | |
| } | | } | |
| | | | |
| template <typename T> inline void sub(T* pf1, T* pf2, int r) | | template <typename T> inline void sub(T* pf1, T* pf2, int r) | |
| { | | { | |
|
| MATH_ASSERT( pf1 != NULL && pf2 != NULL); | | MATH_ASSERT( pf1 != NULL && pf2 != NULL); | |
| | | | |
|
| while(r > 0) { | | while(r > 0) { | |
| --r; | | --r; | |
| pf1[r] -= pf2[r]; | | pf1[r] -= pf2[r]; | |
| } | | } | |
| } | | } | |
| | | | |
| template <typename T> inline T normsqr(const T* pf1, int r) | | template <typename T> inline T normsqr(const T* pf1, int r) | |
| { | | { | |
|
| MATH_ASSERT( pf1 != NULL ); | | MATH_ASSERT( pf1 != NULL ); | |
| | | | |
|
| T d = 0.0; | | T d = 0.0; | |
| while(r > 0) { | | while(r > 0) { | |
| --r; | | --r; | |
| d += pf1[r] * pf1[r]; | | d += pf1[r] * pf1[r]; | |
| } | | } | |
| | | | |
|
| return d; | | return d; | |
| } | | } | |
| | | | |
| template <typename T> inline T lengthsqr(const T* pf1, const T* pf2, int le
ngth) | | template <typename T> inline T lengthsqr(const T* pf1, const T* pf2, int le
ngth) | |
| { | | { | |
|
| T d = 0; | | T d = 0; | |
| while(length > 0) { | | while(length > 0) { | |
| --length; | | --length; | |
| T t = pf1[length] - pf2[length]; | | T t = pf1[length] - pf2[length]; | |
|
| d += t * t; | | d += t * t; | |
| } | | } | |
| | | | |
|
| return d; | | return d; | |
| } | | } | |
| | | | |
| template <typename T> inline T dot(T* pf1, T* pf2, int length) | | template <typename T> inline T dot(T* pf1, T* pf2, int length) | |
| { | | { | |
|
| T d = 0; | | T d = 0; | |
| while(length > 0) { | | while(length > 0) { | |
| --length; | | --length; | |
| d += pf1[length] * pf2[length]; | | d += pf1[length] * pf2[length]; | |
| } | | } | |
| | | | |
|
| return d; | | return d; | |
| } | | } | |
| | | | |
| template <typename T> inline T sum(T* pf, int length) | | template <typename T> inline T sum(T* pf, int length) | |
| { | | { | |
|
| T d = 0; | | T d = 0; | |
| while(length > 0) { | | while(length > 0) { | |
| --length; | | --length; | |
| d += pf[length]; | | d += pf[length]; | |
| } | | } | |
| | | | |
|
| return d; | | return d; | |
| } | | } | |
| | | | |
| template <typename T> inline bool inv2(T* pf, T* pfres) | | template <typename T> inline bool inv2(T* pf, T* pfres) | |
| { | | { | |
|
| T fdet = pf[0] * pf[3] - pf[1] * pf[2]; | | T fdet = pf[0] * pf[3] - pf[1] * pf[2]; | |
| | | | |
|
| if( fabs(fdet) < 1e-16 ) return false; | | if( fabs(fdet) < 1e-16 ) return false; | |
| | | | |
|
| fdet = 1 / fdet; | | fdet = 1 / fdet; | |
| //if( pfdet != NULL ) *pfdet = fdet; | | //if( pfdet != NULL ) *pfdet = fdet; | |
| | | | |
|
| if( pfres != pf ) { | | if( pfres != pf ) { | |
| pfres[0] = fdet * pf[3]; pfres[1] = -fdet * p | | pfres[0] = fdet * pf[3]; pfres[1] = -fdet * pf[1]; | |
| f[1]; | | pfres[2] = -fdet * pf[2]; pfres[3] = fdet * pf[0]; | |
| pfres[2] = -fdet * pf[2]; pfres[3] = fdet * pf | | return true; | |
| [0]; | | } | |
| return true; | | | |
| } | | | |
| | | | |
|
| T ftemp = pf[0]; | | T ftemp = pf[0]; | |
| pfres[0] = pf[3] * fdet; | | pfres[0] = pf[3] * fdet; | |
| pfres[1] *= -fdet; | | pfres[1] *= -fdet; | |
| pfres[2] *= -fdet; | | pfres[2] *= -fdet; | |
| pfres[3] = ftemp * pf[0]; | | pfres[3] = ftemp * pf[0]; | |
| | | | |
|
| return true; | | return true; | |
| } | | } | |
| | | | |
| template <typename T, typename S> | | template <typename T, typename S> | |
| void Tridiagonal3 (S* mat, T* diag, T* subd) | | void Tridiagonal3 (S* mat, T* diag, T* subd) | |
| { | | { | |
| T a, b, c, d, e, f, ell, q; | | T a, b, c, d, e, f, ell, q; | |
| | | | |
| a = mat[0*3+0]; | | a = mat[0*3+0]; | |
| b = mat[0*3+1]; | | b = mat[0*3+1]; | |
| c = mat[0*3+2]; | | c = mat[0*3+2]; | |
| d = mat[1*3+1]; | | d = mat[1*3+1]; | |
| e = mat[1*3+2]; | | e = mat[1*3+2]; | |
| f = mat[2*3+2]; | | f = mat[2*3+2]; | |
| | | | |
|
| subd[2] = 0.0; | | subd[2] = 0.0; | |
| diag[0] = a; | | diag[0] = a; | |
| if ( fabs(c) >= g_fEpsilon ) { | | if ( fabs(c) >= g_fEpsilon ) { | |
| ell = (T)sqrt(b*b+c*c); | | ell = (T)sqrt(b*b+c*c); | |
| b /= ell; | | b /= ell; | |
| c /= ell; | | c /= ell; | |
| q = 2*b*e+c*(f-d); | | q = 2*b*e+c*(f-d); | |
| diag[1] = d+c*q; | | diag[1] = d+c*q; | |
| diag[2] = f-c*q; | | diag[2] = f-c*q; | |
| subd[0] = ell; | | subd[0] = ell; | |
| subd[1] = e-b*q; | | subd[1] = e-b*q; | |
| | | | |
End of changes. 150 change blocks. |
| 471 lines changed or deleted | | 517 lines changed or added | |
|
| openrave.h | | openrave.h | |
| | | | |
| skipping to change at line 19 | | skipping to change at line 19 | |
| // | | // | |
| // This program is distributed in the hope that it will be useful, | | // This program is distributed in the hope that it will be useful, | |
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| // GNU Lesser General Public License for more details. | | // GNU Lesser General Public License for more details. | |
| // | | // | |
| // You should have received a copy of the GNU Lesser General Public License | | // You should have received a copy of the GNU Lesser General Public License | |
| // along with this program. If not, see <http://www.gnu.org/licenses/>. | | // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| /** \file openrave.h | | /** \file openrave.h | |
| \brief Defines the public headers that every plugin must include in or
der to use openrave properly. | | \brief Defines the public headers that every plugin must include in or
der to use openrave properly. | |
|
| */ | | */ | |
| #ifndef OPENRAVE_H | | #ifndef OPENRAVE_H | |
| #define OPENRAVE_H | | #define OPENRAVE_H | |
| | | | |
| #ifndef RAVE_DISABLE_ASSERT_HANDLER | | #ifndef RAVE_DISABLE_ASSERT_HANDLER | |
| #define BOOST_ENABLE_ASSERT_HANDLER | | #define BOOST_ENABLE_ASSERT_HANDLER | |
| #endif | | #endif | |
| | | | |
| #include <cstdio> | | #include <cstdio> | |
| #include <stdarg.h> | | #include <stdarg.h> | |
| #include <cstring> | | #include <cstring> | |
| | | | |
| skipping to change at line 154 | | skipping to change at line 154 | |
| ORE_InvalidPlugin=5, ///< shared object is not a valid plugin | | ORE_InvalidPlugin=5, ///< shared object is not a valid plugin | |
| ORE_InvalidInterfaceHash=6, ///< interface hashes do not match between
plugins | | ORE_InvalidInterfaceHash=6, ///< interface hashes do not match between
plugins | |
| ORE_NotImplemented=7, ///< function is not implemented by the interface
. | | ORE_NotImplemented=7, ///< function is not implemented by the interface
. | |
| ORE_InconsistentConstraints=8, ///< return solutions or trajectories do
not follow the constraints of the planner/module | | ORE_InconsistentConstraints=8, ///< return solutions or trajectories do
not follow the constraints of the planner/module | |
| }; | | }; | |
| | | | |
| /// \brief Exception that all OpenRAVE internal methods throw; the error co
des are held in \ref OpenRAVEErrorCode. | | /// \brief Exception that all OpenRAVE internal methods throw; the error co
des are held in \ref OpenRAVEErrorCode. | |
| class OPENRAVE_API openrave_exception : public std::exception | | class OPENRAVE_API openrave_exception : public std::exception | |
| { | | { | |
| public: | | public: | |
|
| openrave_exception() : std::exception(), _s("unknown exception"), _erro | | openrave_exception() : std::exception(), _s("unknown exception"), _erro | |
| r(ORE_Failed) {} | | r(ORE_Failed) { | |
| | | } | |
| openrave_exception(const std::string& s, OpenRAVEErrorCode error=ORE_Fa
iled) : std::exception() { | | openrave_exception(const std::string& s, OpenRAVEErrorCode error=ORE_Fa
iled) : std::exception() { | |
| _error = error; | | _error = error; | |
| _s = "openrave ("; | | _s = "openrave ("; | |
| switch(_error) { | | switch(_error) { | |
| case ORE_Failed: _s += "Failed"; break; | | case ORE_Failed: _s += "Failed"; break; | |
| case ORE_InvalidArguments: _s += "InvalidArguments"; break; | | case ORE_InvalidArguments: _s += "InvalidArguments"; break; | |
| case ORE_EnvironmentNotLocked: _s += "EnvironmentNotLocked"; break; | | case ORE_EnvironmentNotLocked: _s += "EnvironmentNotLocked"; break; | |
| case ORE_CommandNotSupported: _s += "CommandNotSupported"; break; | | case ORE_CommandNotSupported: _s += "CommandNotSupported"; break; | |
| case ORE_Assert: _s += "Assert"; break; | | case ORE_Assert: _s += "Assert"; break; | |
| case ORE_InvalidPlugin: _s += "InvalidPlugin"; break; | | case ORE_InvalidPlugin: _s += "InvalidPlugin"; break; | |
| case ORE_InvalidInterfaceHash: _s += "InvalidInterfaceHash"; break; | | case ORE_InvalidInterfaceHash: _s += "InvalidInterfaceHash"; break; | |
| case ORE_NotImplemented: _s += "NotImplemented"; break; | | case ORE_NotImplemented: _s += "NotImplemented"; break; | |
| default: | | default: | |
| _s += boost::str(boost::format("%8.8x")%static_cast<int>(_error
)); | | _s += boost::str(boost::format("%8.8x")%static_cast<int>(_error
)); | |
| break; | | break; | |
| } | | } | |
| _s += "): "; | | _s += "): "; | |
| _s += s; | | _s += s; | |
| } | | } | |
|
| virtual ~openrave_exception() throw() {} | | virtual ~openrave_exception() throw() { | |
| char const* what() const throw() { return _s.c_str(); } | | } | |
| const std::string& message() const { return _s; } | | char const* what() const throw() { | |
| OpenRAVEErrorCode GetCode() const { return _error; } | | return _s.c_str(); | |
| | | } | |
| | | const std::string& message() const { | |
| | | return _s; | |
| | | } | |
| | | OpenRAVEErrorCode GetCode() const { | |
| | | return _error; | |
| | | } | |
| private: | | private: | |
| std::string _s; | | std::string _s; | |
| OpenRAVEErrorCode _error; | | OpenRAVEErrorCode _error; | |
| }; | | }; | |
| | | | |
| class OPENRAVE_LOCAL CaseInsensitiveCompare | | class OPENRAVE_LOCAL CaseInsensitiveCompare | |
| { | | { | |
| public: | | public: | |
|
| bool operator()(const std::string & s1, const std::string& s2) const | | bool operator() (const std::string & s1, const std::string& s2) const | |
| { | | { | |
| std::string::const_iterator it1=s1.begin(); | | std::string::const_iterator it1=s1.begin(); | |
| std::string::const_iterator it2=s2.begin(); | | std::string::const_iterator it2=s2.begin(); | |
| | | | |
| //has the end of at least one of the strings been reached? | | //has the end of at least one of the strings been reached? | |
| while ( (it1!=s1.end()) && (it2!=s2.end()) ) { | | while ( (it1!=s1.end()) && (it2!=s2.end()) ) { | |
|
| if(::toupper(*it1) != ::toupper(*it2)) { //letters differ? | | if(::toupper(*it1) != ::toupper(*it2)) { //letters differ? | |
| // return -1 to indicate 'smaller than', 1 otherwise | | // return -1 to indicate 'smaller than', 1 otherwise | |
| return ::toupper(*it1) < ::toupper(*it2); | | return ::toupper(*it1) < ::toupper(*it2); | |
| } | | } | |
| //proceed to the next character in each string | | //proceed to the next character in each string | |
| ++it1; | | ++it1; | |
| ++it2; | | ++it2; | |
| } | | } | |
|
| std::size_t size1=s1.size(), size2=s2.size();// cache lengths | | std::size_t size1=s1.size(), size2=s2.size(); // cache lengths | |
| //return -1,0 or 1 according to strings' lengths | | //return -1,0 or 1 according to strings' lengths | |
| if (size1==size2) { | | if (size1==size2) { | |
| return 0; | | return 0; | |
| } | | } | |
| return size1<size2; | | return size1<size2; | |
| } | | } | |
| }; | | }; | |
| | | | |
| /// \brief base class for all user data | | /// \brief base class for all user data | |
| class OPENRAVE_API UserData | | class OPENRAVE_API UserData | |
| { | | { | |
|
| public: | | public: | |
| virtual ~UserData() {} | | virtual ~UserData() { | |
| | | } | |
| }; | | }; | |
| typedef boost::shared_ptr<UserData> UserDataPtr; | | typedef boost::shared_ptr<UserData> UserDataPtr; | |
| | | | |
| // terminal attributes | | // terminal attributes | |
| //#define RESET 0 | | //#define RESET 0 | |
| //#define BRIGHT 1 | | //#define BRIGHT 1 | |
| //#define DIM 2 | | //#define DIM 2 | |
| //#define UNDERLINE 3 | | //#define UNDERLINE 3 | |
| //#define BLINK 4 | | //#define BLINK 4 | |
| //#define REVERSE 7 | | //#define REVERSE 7 | |
| | | | |
| skipping to change at line 337 | | skipping to change at line 346 | |
| const char* p = p0 > p1 ? p0 : p1; | | const char* p = p0 > p1 ? p0 : p1; | |
| if( p == NULL ) { | | if( p == NULL ) { | |
| return pfilename; | | return pfilename; | |
| } | | } | |
| return p+1; | | return p+1; | |
| } | | } | |
| | | | |
| #ifdef _WIN32 | | #ifdef _WIN32 | |
| | | | |
| #define DefineRavePrintfW(LEVEL) \ | | #define DefineRavePrintfW(LEVEL) \ | |
|
| inline int RavePrintfW##LEVEL(const wchar_t *fmt, ...) \ | | inline int RavePrintfW ## LEVEL(const wchar_t *fmt, ...) \ | |
| { \ | | { \ | |
| /*ChangeTextColor (stdout, 0, OPENRAVECOLOR##LEVEL);*/ \ | | /*ChangeTextColor (stdout, 0, OPENRAVECOLOR##LEVEL);*/ \ | |
| va_list list; \ | | va_list list; \ | |
|
| va_start(list,fmt); \ | | va_start(list,fmt); \ | |
| int r = vwprintf(OpenRAVE::RavePrintTransformString(fmt).c_str(), l
ist); \ | | int r = vwprintf(OpenRAVE::RavePrintTransformString(fmt).c_str(), l
ist); \ | |
| va_end(list); \ | | va_end(list); \ | |
| /*ResetTextColor (stdout);*/ \ | | /*ResetTextColor (stdout);*/ \ | |
| return r; \ | | return r; \ | |
| } | | } | |
| | | | |
| #define DefineRavePrintfA(LEVEL) \ | | #define DefineRavePrintfA(LEVEL) \ | |
|
| inline int RavePrintfA##LEVEL(const std::string& s) \ | | inline int RavePrintfA ## LEVEL(const std::string& s) \ | |
| { \ | | { \ | |
|
| if( s.size() == 0 || s[s.size()-1] != '\n' ) { \ | | if((s.size() == 0)||(s[s.size()-1] != '\n')) { \ | |
| printf("%s\n", s.c_str()); \ | | printf("%s\n", s.c_str()); \ | |
| } \ | | } \ | |
| else { \ | | else { \ | |
| printf ("%s", s.c_str()); \ | | printf ("%s", s.c_str()); \ | |
| } \ | | } \ | |
| return s.size(); \ | | return s.size(); \ | |
| } \ | | } \ | |
| \ | | \ | |
|
| inline int RavePrintfA##LEVEL(const char *fmt, ...) \ | | inline int RavePrintfA ## LEVEL(const char *fmt, ...) \ | |
| { \ | | { \ | |
| /*ChangeTextColor (stdout, 0, OPENRAVECOLOR##LEVEL);*/ \ | | /*ChangeTextColor (stdout, 0, OPENRAVECOLOR##LEVEL);*/ \ | |
| va_list list; \ | | va_list list; \ | |
| va_start(list,fmt); \ | | va_start(list,fmt); \ | |
| int r = vprintf(fmt, list); \ | | int r = vprintf(fmt, list); \ | |
| va_end(list); \ | | va_end(list); \ | |
| /*if( fmt[0] != '\n' ) { printf("\n"); }*/ \ | | /*if( fmt[0] != '\n' ) { printf("\n"); }*/ \ | |
| /*ResetTextColor(stdout);*/ \ | | /*ResetTextColor(stdout);*/ \ | |
| return r; \ | | return r; \ | |
| } | | } | |
| | | | |
| inline int RavePrintfA(const std::string& s, uint32_t level) | | inline int RavePrintfA(const std::string& s, uint32_t level) | |
| { | | { | |
|
| if( s.size() == 0 || s[s.size()-1] != '\n' ) { // automatically add a n
ew line | | if((s.size() == 0)||(s[s.size()-1] != '\n')) { // automatically add a n
ew line | |
| printf("%s\n", s.c_str()); | | printf("%s\n", s.c_str()); | |
| } | | } | |
| else { | | else { | |
| printf ("%s", s.c_str()); | | printf ("%s", s.c_str()); | |
| } | | } | |
| return s.size(); | | return s.size(); | |
| } | | } | |
| | | | |
| DefineRavePrintfW(_INFOLEVEL) | | DefineRavePrintfW(_INFOLEVEL) | |
| DefineRavePrintfA(_INFOLEVEL) | | DefineRavePrintfA(_INFOLEVEL) | |
| | | | |
| #else | | #else | |
| | | | |
| #define DefineRavePrintfW(LEVEL) \ | | #define DefineRavePrintfW(LEVEL) \ | |
|
| inline int RavePrintfW##LEVEL(const wchar_t *wfmt, ...) \ | | inline int RavePrintfW ## LEVEL(const wchar_t *wfmt, ...) \ | |
| { \ | | { \ | |
| va_list list; \ | | va_list list; \ | |
| va_start(list,wfmt); \ | | va_start(list,wfmt); \ | |
| /* Allocate memory on the stack to avoid heap fragmentation */ \ | | /* Allocate memory on the stack to avoid heap fragmentation */ \ | |
| size_t allocsize = wcstombs(NULL, wfmt, 0)+32; \ | | size_t allocsize = wcstombs(NULL, wfmt, 0)+32; \ | |
| char* fmt = (char*)alloca(allocsize); \ | | char* fmt = (char*)alloca(allocsize); \ | |
|
| strcpy(fmt, ChangeTextColor(0, OPENRAVECOLOR##LEVEL,8).c_str()); \ | | strcpy(fmt, ChangeTextColor(0, OPENRAVECOLOR ## LEVEL,8).c_str());
\ | |
| snprintf(fmt+strlen(fmt),allocsize-16,"%S",wfmt); \ | | snprintf(fmt+strlen(fmt),allocsize-16,"%S",wfmt); \ | |
| strcat(fmt, ResetTextColor().c_str()); \ | | strcat(fmt, ResetTextColor().c_str()); \ | |
| int r = vprintf(fmt, list); \ | | int r = vprintf(fmt, list); \ | |
| va_end(list); \ | | va_end(list); \ | |
| return r; \ | | return r; \ | |
| } | | } | |
| | | | |
| // In linux, only wprintf will succeed, due to the fwide() call in main, so | | // In linux, only wprintf will succeed, due to the fwide() call in main, so | |
| // for programmers who want to use regular format strings without | | // for programmers who want to use regular format strings without | |
| // the L in front, we will take their regular string and widen it | | // the L in front, we will take their regular string and widen it | |
| // for them. | | // for them. | |
|
| inline int RavePrintfA_INFOLEVEL(const std::string& s) | | inline int RavePrintfA_INFOLEVEL(const std::string& s) | |
| { | | { | |
| if( s.size() == 0 || s[s.size()-1] != '\n' ) { // automatically add | | if((s.size() == 0)||(s[s.size()-1] != '\n')) { // automatically add | |
| a new line | | a new line | |
| printf("%s\n", s.c_str()); | | printf("%s\n", s.c_str()); | |
| } | | | |
| else { | | | |
| printf ("%s", s.c_str()); | | | |
| } | | | |
| return s.size(); | | | |
| } | | } | |
|
| | | else { | |
| inline int RavePrintfA_INFOLEVEL(const char *fmt, ...) | | printf ("%s", s.c_str()); | |
| { | | | |
| va_list list; | | | |
| va_start(list,fmt); | | | |
| int r = vprintf(fmt, list); | | | |
| va_end(list); | | | |
| //if( fmt[0] != '\n' ) { printf("\n"); } | | | |
| return r; | | | |
| } | | } | |
|
| | | return s.size(); | |
| | | } | |
| | | | |
| | | inline int RavePrintfA_INFOLEVEL(const char *fmt, ...) | |
| | | { | |
| | | va_list list; | |
| | | va_start(list,fmt); | |
| | | int r = vprintf(fmt, list); | |
| | | va_end(list); | |
| | | //if( fmt[0] != '\n' ) { printf("\n"); } | |
| | | return r; | |
| | | } | |
| | | | |
| #define DefineRavePrintfA(LEVEL) \ | | #define DefineRavePrintfA(LEVEL) \ | |
|
| inline int RavePrintfA##LEVEL(const std::string& s) \ | | inline int RavePrintfA ## LEVEL(const std::string& s) \ | |
| { \ | | { \ | |
|
| if( s.size() == 0 || s[s.size()-1] != '\n' ) { \ | | if((s.size() == 0)||(s[s.size()-1] != '\n')) { \ | |
| printf ("%c[0;%d;%dm%s%c[m\n", 0x1B, OPENRAVECOLOR##LEVEL + 30, | | printf ("%c[0;%d;%dm%s%c[m\n", 0x1B, OPENRAVECOLOR ## LEVEL + 3 | |
| 8+40,s.c_str(),0x1B); \ | | 0,8+40,s.c_str(),0x1B); \ | |
| } \ | | } \ | |
| else { \ | | else { \ | |
|
| printf ("%c[0;%d;%dm%s%c[m", 0x1B, OPENRAVECOLOR##LEVEL + 30,8+
40,s.c_str(),0x1B); \ | | printf ("%c[0;%d;%dm%s%c[m", 0x1B, OPENRAVECOLOR ## LEVEL + 30,
8+40,s.c_str(),0x1B); \ | |
| } \ | | } \ | |
| return s.size(); \ | | return s.size(); \ | |
| } \ | | } \ | |
| \ | | \ | |
|
| inline int RavePrintfA##LEVEL(const char *fmt, ...) \ | | inline int RavePrintfA ## LEVEL(const char *fmt, ...) \ | |
| { \ | | { \ | |
| va_list list; \ | | va_list list; \ | |
|
| va_start(list,fmt); \ | | va_start(list,fmt); \ | |
| int r = vprintf((ChangeTextColor(0, OPENRAVECOLOR##LEVEL,8) + std:: | | int r = vprintf((ChangeTextColor(0, OPENRAVECOLOR ## LEVEL,8) + std | |
| string(fmt) + ResetTextColor()).c_str(), list); \ | | ::string(fmt) + ResetTextColor()).c_str(), list); \ | |
| va_end(list); \ | | va_end(list); \ | |
| /*if( fmt[0] != '\n' ) { printf("\n"); } */ \ | | /*if( fmt[0] != '\n' ) { printf("\n"); } */ \ | |
| return r; \ | | return r; \ | |
| } \ | | } \ | |
| | | | |
| inline int RavePrintfA(const std::string& s, uint32_t level) | | inline int RavePrintfA(const std::string& s, uint32_t level) | |
| { | | { | |
| if( (OpenRAVE::RaveGetDebugLevel()&OpenRAVE::Level_OutputMask)>=level )
{ | | if( (OpenRAVE::RaveGetDebugLevel()&OpenRAVE::Level_OutputMask)>=level )
{ | |
| int color = 0; | | int color = 0; | |
| switch(level) { | | switch(level) { | |
| case Level_Fatal: color = OPENRAVECOLOR_FATALLEVEL; break; | | case Level_Fatal: color = OPENRAVECOLOR_FATALLEVEL; break; | |
| case Level_Error: color = OPENRAVECOLOR_ERRORLEVEL; break; | | case Level_Error: color = OPENRAVECOLOR_ERRORLEVEL; break; | |
| case Level_Warn: color = OPENRAVECOLOR_WARNLEVEL; break; | | case Level_Warn: color = OPENRAVECOLOR_WARNLEVEL; break; | |
| case Level_Info: // print regular | | case Level_Info: // print regular | |
|
| if( s.size() == 0 || s[s.size()-1] != '\n' ) { // automatically
add a new line | | if((s.size() == 0)||(s[s.size()-1] != '\n')) { // automatically
add a new line | |
| printf ("%s\n",s.c_str()); | | printf ("%s\n",s.c_str()); | |
| } | | } | |
| else { | | else { | |
| printf ("%s",s.c_str()); | | printf ("%s",s.c_str()); | |
| } | | } | |
| return s.size(); | | return s.size(); | |
| case Level_Debug: color = OPENRAVECOLOR_DEBUGLEVEL; break; | | case Level_Debug: color = OPENRAVECOLOR_DEBUGLEVEL; break; | |
| case Level_Verbose: color = OPENRAVECOLOR_VERBOSELEVEL; break; | | case Level_Verbose: color = OPENRAVECOLOR_VERBOSELEVEL; break; | |
| } | | } | |
|
| if( s.size() == 0 || s[s.size()-1] != '\n' ) { // automatically add
a new line | | if((s.size() == 0)||(s[s.size()-1] != '\n')) { // automatically add
a new line | |
| printf ("%c[0;%d;%dm%s%c[0;38;48m\n", 0x1B, color + 30,8+40,s.c
_str(),0x1B); | | printf ("%c[0;%d;%dm%s%c[0;38;48m\n", 0x1B, color + 30,8+40,s.c
_str(),0x1B); | |
| } | | } | |
| else { | | else { | |
| printf ("%c[0;%d;%dm%s%c[0;38;48m", 0x1B, color + 30,8+40,s.c_s
tr(),0x1B); | | printf ("%c[0;%d;%dm%s%c[0;38;48m", 0x1B, color + 30,8+40,s.c_s
tr(),0x1B); | |
| } | | } | |
| return s.size(); | | return s.size(); | |
| } | | } | |
| return 0; | | return 0; | |
| } | | } | |
| | | | |
| | | | |
| skipping to change at line 497 | | skipping to change at line 506 | |
| DefineRavePrintfW(_DEBUGLEVEL) | | DefineRavePrintfW(_DEBUGLEVEL) | |
| DefineRavePrintfW(_VERBOSELEVEL) | | DefineRavePrintfW(_VERBOSELEVEL) | |
| | | | |
| DefineRavePrintfA(_FATALLEVEL) | | DefineRavePrintfA(_FATALLEVEL) | |
| DefineRavePrintfA(_ERRORLEVEL) | | DefineRavePrintfA(_ERRORLEVEL) | |
| DefineRavePrintfA(_WARNLEVEL) | | DefineRavePrintfA(_WARNLEVEL) | |
| //DefineRavePrintfA(_INFOLEVEL) | | //DefineRavePrintfA(_INFOLEVEL) | |
| DefineRavePrintfA(_DEBUGLEVEL) | | DefineRavePrintfA(_DEBUGLEVEL) | |
| DefineRavePrintfA(_VERBOSELEVEL) | | DefineRavePrintfA(_VERBOSELEVEL) | |
| | | | |
|
| #define RAVEPRINTHEADER(LEVEL) OpenRAVE::RavePrintfA##LEVEL("[%s:%d] ", Ope
nRAVE::RaveGetSourceFilename(__FILE__), __LINE__) | | #define RAVEPRINTHEADER(LEVEL) OpenRAVE::RavePrintfA ## LEVEL("[%s:%d] ", O
penRAVE::RaveGetSourceFilename(__FILE__), __LINE__) | |
| | | | |
| // different logging levels. The higher the suffix number, the less importa
nt the information is. | | // different logging levels. The higher the suffix number, the less importa
nt the information is. | |
| // 0 log level logs all the time. OpenRAVE starts up with a log level of 0. | | // 0 log level logs all the time. OpenRAVE starts up with a log level of 0. | |
|
| #define RAVELOG_LEVELW(LEVEL,level) (OpenRAVE::RaveGetDebugLevel()&OpenRAVE | | #define RAVELOG_LEVELW(LEVEL,level) (OpenRAVE::RaveGetDebugLevel()&OpenRAVE | |
| ::Level_OutputMask)>=(level)&&(RAVEPRINTHEADER(LEVEL)>0)&&OpenRAVE::RavePri | | ::Level_OutputMask)>=(level)&&(RAVEPRINTHEADER(LEVEL)>0)&&OpenRAVE::RavePri | |
| ntfW##LEVEL | | ntfW ## LEVEL | |
| #define RAVELOG_LEVELA(LEVEL,level) (OpenRAVE::RaveGetDebugLevel()&OpenRAVE | | #define RAVELOG_LEVELA(LEVEL,level) (OpenRAVE::RaveGetDebugLevel()&OpenRAVE | |
| ::Level_OutputMask)>=(level)&&(RAVEPRINTHEADER(LEVEL)>0)&&OpenRAVE::RavePri | | ::Level_OutputMask)>=(level)&&(RAVEPRINTHEADER(LEVEL)>0)&&OpenRAVE::RavePri | |
| ntfA##LEVEL | | ntfA ## LEVEL | |
| | | | |
| // define log4cxx equivalents (eventually OpenRAVE will move to log4cxx log
ging) | | // define log4cxx equivalents (eventually OpenRAVE will move to log4cxx log
ging) | |
| #define RAVELOG_FATALW RAVELOG_LEVELW(_FATALLEVEL,OpenRAVE::Level_Fatal) | | #define RAVELOG_FATALW RAVELOG_LEVELW(_FATALLEVEL,OpenRAVE::Level_Fatal) | |
| #define RAVELOG_FATALA RAVELOG_LEVELA(_FATALLEVEL,OpenRAVE::Level_Fatal) | | #define RAVELOG_FATALA RAVELOG_LEVELA(_FATALLEVEL,OpenRAVE::Level_Fatal) | |
| #define RAVELOG_FATAL RAVELOG_FATALA | | #define RAVELOG_FATAL RAVELOG_FATALA | |
| #define RAVELOG_ERRORW RAVELOG_LEVELW(_ERRORLEVEL,OpenRAVE::Level_Error) | | #define RAVELOG_ERRORW RAVELOG_LEVELW(_ERRORLEVEL,OpenRAVE::Level_Error) | |
| #define RAVELOG_ERRORA RAVELOG_LEVELA(_ERRORLEVEL,OpenRAVE::Level_Error) | | #define RAVELOG_ERRORA RAVELOG_LEVELA(_ERRORLEVEL,OpenRAVE::Level_Error) | |
| #define RAVELOG_ERROR RAVELOG_ERRORA | | #define RAVELOG_ERROR RAVELOG_ERRORA | |
| #define RAVELOG_WARNW RAVELOG_LEVELW(_WARNLEVEL,OpenRAVE::Level_Warn) | | #define RAVELOG_WARNW RAVELOG_LEVELW(_WARNLEVEL,OpenRAVE::Level_Warn) | |
| #define RAVELOG_WARNA RAVELOG_LEVELA(_WARNLEVEL,OpenRAVE::Level_Warn) | | #define RAVELOG_WARNA RAVELOG_LEVELA(_WARNLEVEL,OpenRAVE::Level_Warn) | |
| | | | |
| skipping to change at line 526 | | skipping to change at line 535 | |
| #define RAVELOG_INFO RAVELOG_INFOA | | #define RAVELOG_INFO RAVELOG_INFOA | |
| #define RAVELOG_DEBUGW RAVELOG_LEVELW(_DEBUGLEVEL,OpenRAVE::Level_Debug) | | #define RAVELOG_DEBUGW RAVELOG_LEVELW(_DEBUGLEVEL,OpenRAVE::Level_Debug) | |
| #define RAVELOG_DEBUGA RAVELOG_LEVELA(_DEBUGLEVEL,OpenRAVE::Level_Debug) | | #define RAVELOG_DEBUGA RAVELOG_LEVELA(_DEBUGLEVEL,OpenRAVE::Level_Debug) | |
| #define RAVELOG_DEBUG RAVELOG_DEBUGA | | #define RAVELOG_DEBUG RAVELOG_DEBUGA | |
| #define RAVELOG_VERBOSEW RAVELOG_LEVELW(_VERBOSELEVEL,OpenRAVE::Level_Verbo
se) | | #define RAVELOG_VERBOSEW RAVELOG_LEVELW(_VERBOSELEVEL,OpenRAVE::Level_Verbo
se) | |
| #define RAVELOG_VERBOSEA RAVELOG_LEVELA(_VERBOSELEVEL,OpenRAVE::Level_Verbo
se) | | #define RAVELOG_VERBOSEA RAVELOG_LEVELA(_VERBOSELEVEL,OpenRAVE::Level_Verbo
se) | |
| #define RAVELOG_VERBOSE RAVELOG_VERBOSEA | | #define RAVELOG_VERBOSE RAVELOG_VERBOSEA | |
| | | | |
| #define IS_DEBUGLEVEL(level) ((OpenRAVE::RaveGetDebugLevel()&OpenRAVE::Leve
l_OutputMask)>=(level)) | | #define IS_DEBUGLEVEL(level) ((OpenRAVE::RaveGetDebugLevel()&OpenRAVE::Leve
l_OutputMask)>=(level)) | |
| | | | |
|
| #define OPENRAVE_EXCEPTION_FORMAT0(s, errorcode) OpenRAVE::openrave_excepti
on(boost::str(boost::format("[%s:%d] "s)%(__PRETTY_FUNCTION__)%(__LINE__)),
errorcode) | | #define OPENRAVE_EXCEPTION_FORMAT0(s, errorcode) OpenRAVE::openrave_excepti
on(boost::str(boost::format("[%s:%d] " s)%(__PRETTY_FUNCTION__)%(__LINE__))
,errorcode) | |
| | | | |
| /// adds the function name and line number to an openrave exception | | /// adds the function name and line number to an openrave exception | |
|
| #define OPENRAVE_EXCEPTION_FORMAT(s, args,errorcode) OpenRAVE::openrave_exc
eption(boost::str(boost::format("[%s:%d] "s)%(__PRETTY_FUNCTION__)%(__LINE_
_)%args),errorcode) | | #define OPENRAVE_EXCEPTION_FORMAT(s, args,errorcode) OpenRAVE::openrave_exc
eption(boost::str(boost::format("[%s:%d] " s)%(__PRETTY_FUNCTION__)%(__LINE
__)%args),errorcode) | |
| | | | |
| #define OPENRAVE_DUMMY_IMPLEMENTATION { throw OPENRAVE_EXCEPTION_FORMAT0("n
ot implemented",ORE_NotImplemented); } | | #define OPENRAVE_DUMMY_IMPLEMENTATION { throw OPENRAVE_EXCEPTION_FORMAT0("n
ot implemented",ORE_NotImplemented); } | |
| | | | |
| /// \brief Enumeration of all the interfaces. | | /// \brief Enumeration of all the interfaces. | |
| enum InterfaceType | | enum InterfaceType | |
| { | | { | |
| PT_Planner=1, ///< describes \ref PlannerBase interface | | PT_Planner=1, ///< describes \ref PlannerBase interface | |
| PT_Robot=2, ///< describes \ref RobotBase interface | | PT_Robot=2, ///< describes \ref RobotBase interface | |
| PT_SensorSystem=3, ///< describes \ref SensorSystemBase interface | | PT_SensorSystem=3, ///< describes \ref SensorSystemBase interface | |
| PT_Controller=4, ///< describes \ref ControllerBase interface | | PT_Controller=4, ///< describes \ref ControllerBase interface | |
| PT_Module=5, ///< describes \ref ModuleBase interface | | PT_Module=5, ///< describes \ref ModuleBase interface | |
| PT_ProblemInstance=5, ///< describes \ref ModuleBase interface | | PT_ProblemInstance=5, ///< describes \ref ModuleBase interface | |
| PT_IkSolver=6, ///< describes \ref IkSolverBase interface | | PT_IkSolver=6, ///< describes \ref IkSolverBase interface | |
| PT_InverseKinematicsSolver=6, ///< describes \ref IkSolverBase interfac
e | | PT_InverseKinematicsSolver=6, ///< describes \ref IkSolverBase interfac
e | |
| PT_KinBody=7, ///< describes \ref KinBody | | PT_KinBody=7, ///< describes \ref KinBody | |
| PT_PhysicsEngine=8, ///< describes \ref PhysicsEngineBase | | PT_PhysicsEngine=8, ///< describes \ref PhysicsEngineBase | |
| PT_Sensor=9, ///< describes \ref SensorBase | | PT_Sensor=9, ///< describes \ref SensorBase | |
| PT_CollisionChecker=10, ///< describes \ref CollisionCheckerBase | | PT_CollisionChecker=10, ///< describes \ref CollisionCheckerBase | |
| PT_Trajectory=11, ///< describes \ref TrajectoryBase | | PT_Trajectory=11, ///< describes \ref TrajectoryBase | |
|
| PT_Viewer=12,///< describes \ref ViewerBase | | PT_Viewer=12, ///< describes \ref ViewerBase | |
| PT_SpaceSampler=13, ///< describes \ref SamplerBase | | PT_SpaceSampler=13, ///< describes \ref SamplerBase | |
| PT_NumberOfInterfaces=13 ///< number of interfaces, do not forget to up
date | | PT_NumberOfInterfaces=13 ///< number of interfaces, do not forget to up
date | |
| }; | | }; | |
| | | | |
| class CollisionReport; | | class CollisionReport; | |
| class InterfaceBase; | | class InterfaceBase; | |
| class IkSolverBase; | | class IkSolverBase; | |
| class TrajectoryBase; | | class TrajectoryBase; | |
| class ControllerBase; | | class ControllerBase; | |
| class PlannerBase; | | class PlannerBase; | |
| | | | |
| skipping to change at line 633 | | skipping to change at line 642 | |
| Clone_Viewer = 2, ///< clone the viewer type, although figures won't be
copied, new viewer does try to match views | | Clone_Viewer = 2, ///< clone the viewer type, although figures won't be
copied, new viewer does try to match views | |
| Clone_Simulation = 4, ///< clone the physics engine and simulation stat
e (ie, timesteps, gravity) | | Clone_Simulation = 4, ///< clone the physics engine and simulation stat
e (ie, timesteps, gravity) | |
| Clone_RealControllers = 8, ///< if specified, will clone the real contr
ollers of all the robots, otherwise each robot gets ideal controller | | Clone_RealControllers = 8, ///< if specified, will clone the real contr
ollers of all the robots, otherwise each robot gets ideal controller | |
| Clone_Sensors = 16, ///< if specified, will clone the sensors attached
to the robot and added to the environment | | Clone_Sensors = 16, ///< if specified, will clone the sensors attached
to the robot and added to the environment | |
| }; | | }; | |
| | | | |
| /// base class for readable interfaces | | /// base class for readable interfaces | |
| class OPENRAVE_API XMLReadable | | class OPENRAVE_API XMLReadable | |
| { | | { | |
| public: | | public: | |
|
| XMLReadable(const std::string& xmlid) : __xmlid(xmlid) {} | | XMLReadable(const std::string& xmlid) : __xmlid(xmlid) { | |
| virtual ~XMLReadable() {} | | } | |
| virtual const std::string& GetXMLId() const { return __xmlid; } | | virtual ~XMLReadable() { | |
| | | } | |
| | | virtual const std::string& GetXMLId() const { | |
| | | return __xmlid; | |
| | | } | |
| private: | | private: | |
| std::string __xmlid; | | std::string __xmlid; | |
| }; | | }; | |
| | | | |
| typedef boost::shared_ptr<XMLReadable> XMLReadablePtr; | | typedef boost::shared_ptr<XMLReadable> XMLReadablePtr; | |
| typedef boost::shared_ptr<XMLReadable const> XMLReadableConstPtr; | | typedef boost::shared_ptr<XMLReadable const> XMLReadableConstPtr; | |
| typedef std::list<std::pair<std::string,std::string> > AttributesList; | | typedef std::list<std::pair<std::string,std::string> > AttributesList; | |
| /// \deprecated (11/02/18) | | /// \deprecated (11/02/18) | |
| typedef AttributesList XMLAttributesList RAVE_DEPRECATED; | | typedef AttributesList XMLAttributesList RAVE_DEPRECATED; | |
| | | | |
| /// base class for all xml readers. XMLReaders are used to process data fro
m | | /// base class for all xml readers. XMLReaders are used to process data fro
m | |
| /// xml files. Custom readers can be registered through EnvironmentBase. | | /// xml files. Custom readers can be registered through EnvironmentBase. | |
| /// By default it can record all data that is encountered inside the xml re
ader | | /// By default it can record all data that is encountered inside the xml re
ader | |
| class OPENRAVE_API BaseXMLReader : public boost::enable_shared_from_this<Ba
seXMLReader> | | class OPENRAVE_API BaseXMLReader : public boost::enable_shared_from_this<Ba
seXMLReader> | |
| { | | { | |
| public: | | public: | |
| enum ProcessElement | | enum ProcessElement | |
| { | | { | |
|
| PE_Pass=0, ///< current tag was not supported, so pass onto another | | PE_Pass=0, ///< current tag was not supported, so pass onto ano | |
| class | | ther class | |
| PE_Support=1, ///< current tag will be processed by this class | | PE_Support=1, ///< current tag will be processed by this class | |
| PE_Ignore=2, ///< current tag and all its children should be ignore | | PE_Ignore=2, ///< current tag and all its children should be ig | |
| d | | nored | |
| }; | | }; | |
|
| BaseXMLReader() {} | | BaseXMLReader() { | |
| virtual ~BaseXMLReader() {} | | } | |
| | | virtual ~BaseXMLReader() { | |
| | | } | |
| | | | |
| /// a readable interface that stores the information processsed for the
current tag | | /// a readable interface that stores the information processsed for the
current tag | |
| /// This pointer is used to the InterfaceBase class registered readers | | /// This pointer is used to the InterfaceBase class registered readers | |
|
| virtual XMLReadablePtr GetReadable() { return XMLReadablePtr(); } | | virtual XMLReadablePtr GetReadable() { | |
| | | return XMLReadablePtr(); | |
| | | } | |
| | | | |
| /// Gets called in the beginning of each "<type>" expression. In this c
ase, name is "type" | | /// Gets called in the beginning of each "<type>" expression. In this c
ase, name is "type" | |
| /// \param name of the tag, will be always lower case | | /// \param name of the tag, will be always lower case | |
| /// \param atts string of attributes where the first std::string is the
attribute name and second is the value | | /// \param atts string of attributes where the first std::string is the
attribute name and second is the value | |
| /// \return true if tag is accepted and this class will process it, oth
erwise false | | /// \return true if tag is accepted and this class will process it, oth
erwise false | |
| virtual ProcessElement startElement(const std::string& name, const Attr
ibutesList& atts) = 0; | | virtual ProcessElement startElement(const std::string& name, const Attr
ibutesList& atts) = 0; | |
| | | | |
| /// Gets called at the end of each "</type>" expression. In this case,
name is "type" | | /// Gets called at the end of each "</type>" expression. In this case,
name is "type" | |
| /// \param name of the tag, will be always lower case | | /// \param name of the tag, will be always lower case | |
| /// \return true if XMLReader has finished parsing (one condition is th
at name==_fieldname) , otherwise false | | /// \return true if XMLReader has finished parsing (one condition is th
at name==_fieldname) , otherwise false | |
| | | | |
| skipping to change at line 697 | | skipping to change at line 714 | |
| typedef boost::function<BaseXMLReaderPtr(InterfaceBasePtr, const Attributes
List&)> CreateXMLReaderFn; | | typedef boost::function<BaseXMLReaderPtr(InterfaceBasePtr, const Attributes
List&)> CreateXMLReaderFn; | |
| | | | |
| /// reads until the tag ends | | /// reads until the tag ends | |
| class OPENRAVE_API DummyXMLReader : public BaseXMLReader | | class OPENRAVE_API DummyXMLReader : public BaseXMLReader | |
| { | | { | |
| public: | | public: | |
| DummyXMLReader(const std::string& pfieldname, const std::string& pparen
tname, boost::shared_ptr<std::ostream> osrecord = boost::shared_ptr<std::os
tream>()); | | DummyXMLReader(const std::string& pfieldname, const std::string& pparen
tname, boost::shared_ptr<std::ostream> osrecord = boost::shared_ptr<std::os
tream>()); | |
| virtual ProcessElement startElement(const std::string& name, const Attr
ibutesList& atts); | | virtual ProcessElement startElement(const std::string& name, const Attr
ibutesList& atts); | |
| virtual bool endElement(const std::string& name); | | virtual bool endElement(const std::string& name); | |
| virtual void characters(const std::string& ch); | | virtual void characters(const std::string& ch); | |
|
| const std::string& GetFieldName() const { return _fieldname; } | | const std::string& GetFieldName() const { | |
| | | return _fieldname; | |
| | | } | |
| private: | | private: | |
|
| std::string _parentname; /// XML filename | | std::string _parentname; /// XML filename | |
| std::string _fieldname; | | std::string _fieldname; | |
|
| boost::shared_ptr<std::ostream> _osrecord; ///< used to store the xml d
ata | | boost::shared_ptr<std::ostream> _osrecord; ///< used to store the x
ml data | |
| boost::shared_ptr<BaseXMLReader> _pcurreader; | | boost::shared_ptr<BaseXMLReader> _pcurreader; | |
| }; | | }; | |
| | | | |
| } // end namespace OpenRAVE | | } // end namespace OpenRAVE | |
| | | | |
| // define the math functions | | // define the math functions | |
| #define MATH_EXP RaveExp | | #define MATH_EXP RaveExp | |
| #define MATH_LOG RaveLog | | #define MATH_LOG RaveLog | |
| #define MATH_COS RaveCos | | #define MATH_COS RaveCos | |
| #define MATH_SIN RaveSin | | #define MATH_SIN RaveSin | |
| | | | |
| skipping to change at line 726 | | skipping to change at line 745 | |
| #define MATH_ASIN RaveAsin | | #define MATH_ASIN RaveAsin | |
| #define MATH_ATAN2 RaveAtan2 | | #define MATH_ATAN2 RaveAtan2 | |
| #define MATH_POW RavePow | | #define MATH_POW RavePow | |
| #define MATH_SQRT RaveSqrt | | #define MATH_SQRT RaveSqrt | |
| #define MATH_FABS RaveFabs | | #define MATH_FABS RaveFabs | |
| | | | |
| #include <openrave/geometry.h> | | #include <openrave/geometry.h> | |
| #include <openrave/mathextra.h> | | #include <openrave/mathextra.h> | |
| | | | |
| namespace OpenRAVE { | | namespace OpenRAVE { | |
|
| using geometry::RaveVector; | | using geometry::RaveVector; | |
| using geometry::RaveTransform; | | using geometry::RaveTransform; | |
| using geometry::RaveTransformMatrix; | | using geometry::RaveTransformMatrix; | |
| typedef RaveVector<dReal> Vector; | | typedef RaveVector<dReal> Vector; | |
| typedef RaveTransform<dReal> Transform; | | typedef RaveTransform<dReal> Transform; | |
| typedef boost::shared_ptr< RaveTransform<dReal> > TransformPtr; | | typedef boost::shared_ptr< RaveTransform<dReal> > TransformPtr; | |
| typedef boost::shared_ptr< RaveTransform<dReal> const > TransformConstP | | typedef boost::shared_ptr< RaveTransform<dReal> const > TransformConstPtr; | |
| tr; | | typedef RaveTransformMatrix<dReal> TransformMatrix; | |
| typedef RaveTransformMatrix<dReal> TransformMatrix; | | typedef boost::shared_ptr< RaveTransformMatrix<dReal> > TransformMatrixPtr; | |
| typedef boost::shared_ptr< RaveTransformMatrix<dReal> > TransformMatrix | | typedef boost::shared_ptr< RaveTransformMatrix<dReal> const > TransformMatr | |
| Ptr; | | ixConstPtr; | |
| typedef boost::shared_ptr< RaveTransformMatrix<dReal> const > Transform | | typedef geometry::obb<dReal> OBB; | |
| MatrixConstPtr; | | typedef geometry::aabb<dReal> AABB; | |
| typedef geometry::obb<dReal> OBB; | | typedef geometry::ray<dReal> RAY; | |
| typedef geometry::aabb<dReal> AABB; | | | |
| typedef geometry::ray<dReal> RAY; | | | |
| | | | |
|
| // for compatibility | | // for compatibility | |
| //@{ | | //@{ | |
| using mathextra::dot2; | | using mathextra::dot2; | |
| using mathextra::dot3; | | using mathextra::dot3; | |
| using mathextra::dot4; | | using mathextra::dot4; | |
| using mathextra::normalize2; | | using mathextra::normalize2; | |
| using mathextra::normalize3; | | using mathextra::normalize3; | |
| using mathextra::normalize4; | | using mathextra::normalize4; | |
| using mathextra::cross3; | | using mathextra::cross3; | |
| using mathextra::inv3; | | using mathextra::inv3; | |
| using mathextra::inv4; | | using mathextra::inv4; | |
| using mathextra::lengthsqr2; | | using mathextra::lengthsqr2; | |
| using mathextra::lengthsqr3; | | using mathextra::lengthsqr3; | |
| using mathextra::lengthsqr4; | | using mathextra::lengthsqr4; | |
| using mathextra::mult4; | | using mathextra::mult4; | |
| //@} | | //@} | |
| | | | |
| /** \brief Parameterization of basic primitives for querying inverse-kinema
tics solutions. | | /** \brief Parameterization of basic primitives for querying inverse-kinema
tics solutions. | |
| | | | |
| Holds the parameterization of a geometric primitive useful for autonomo
us manipulation scenarios like: | | Holds the parameterization of a geometric primitive useful for autonomo
us manipulation scenarios like: | |
| 6D pose, 3D translation, 3D rotation, 3D look at direction, and ray loo
k at direction. | | 6D pose, 3D translation, 3D rotation, 3D look at direction, and ray loo
k at direction. | |
|
| */ | | */ | |
| class OPENRAVE_API IkParameterization | | class OPENRAVE_API IkParameterization | |
| { | | { | |
| public: | | public: | |
| /// \brief The types of inverse kinematics parameterizations supported. | | /// \brief The types of inverse kinematics parameterizations supported. | |
| /// | | /// | |
| /// The minimum degree of freedoms required is set in the upper 4 bits
of each type. | | /// The minimum degree of freedoms required is set in the upper 4 bits
of each type. | |
| /// The number of values used to represent the parameterization ( >= do
f ) is the next 4 bits. | | /// The number of values used to represent the parameterization ( >= do
f ) is the next 4 bits. | |
| /// The lower bits contain a unique id of the type. | | /// The lower bits contain a unique id of the type. | |
| enum Type { | | enum Type { | |
| Type_None=0, | | Type_None=0, | |
|
| Type_Transform6D=0x67000001, ///< end effector reaches desired 6D t | | Type_Transform6D=0x67000001, ///< end effector reaches desired | |
| ransformation | | 6D transformation | |
| Type_Rotation3D=0x34000002, ///< end effector reaches desired 3D ro | | Type_Rotation3D=0x34000002, ///< end effector reaches desired 3 | |
| tation | | D rotation | |
| Type_Translation3D=0x33000003, ///< end effector origin reaches des | | Type_Translation3D=0x33000003, ///< end effector origin reaches | |
| ired 3D translation | | desired 3D translation | |
| Type_Direction3D=0x23000004, ///< direction on end effector coordin | | Type_Direction3D=0x23000004, ///< direction on end effector coo | |
| ate system reaches desired direction | | rdinate system reaches desired direction | |
| Type_Ray4D=0x46000005, ///< ray on end effector coordinate system r | | Type_Ray4D=0x46000005, ///< ray on end effector coordinate syst | |
| eaches desired global ray | | em reaches desired global ray | |
| Type_Lookat3D=0x23000006, ///< direction on end effector coordinate | | Type_Lookat3D=0x23000006, ///< direction on end effector coordi | |
| system points to desired 3D position | | nate system points to desired 3D position | |
| Type_TranslationDirection5D=0x56000007, ///< end effector origin an | | Type_TranslationDirection5D=0x56000007, ///< end effector origi | |
| d direction reaches desired 3D translation and direction. Can be thought of | | n and direction reaches desired 3D translation and direction. Can be though | |
| as Ray IK where the origin of the ray must coincide. | | t of as Ray IK where the origin of the ray must coincide. | |
| Type_TranslationXY2D=0x22000008, ///< 2D translation along XY plane | | Type_TranslationXY2D=0x22000008, ///< 2D translation along XY p | |
| Type_TranslationXYOrientation3D=0x33000009, ///< 2D translation alo | | lane | |
| ng XY plane and 1D rotation around Z axis. The offset of the rotation is me | | Type_TranslationXYOrientation3D=0x33000009, ///< 2D translation | |
| asured starting at +X, so at +X is it 0, at +Y it is pi/2. | | along XY plane and 1D rotation around Z axis. The offset of the rotation i | |
| Type_TranslationLocalGlobal6D=0x3600000a, ///< local point on end e | | s measured starting at +X, so at +X is it 0, at +Y it is pi/2. | |
| ffector origin reaches desired 3D global point | | Type_TranslationLocalGlobal6D=0x3600000a, ///< local point on e | |
| Type_NumberOfParameterizations=10, ///< number of parameterizations | | nd effector origin reaches desired 3D global point | |
| (does not count Type_None) | | Type_NumberOfParameterizations=10, ///< number of parameterizat | |
| | | ions (does not count Type_None) | |
| }; | | }; | |
| | | | |
|
| IkParameterization() : _type(Type_None) {} | | IkParameterization() : _type(Type_None) { | |
| | | } | |
| /// \brief sets a 6D transform parameterization | | /// \brief sets a 6D transform parameterization | |
|
| IkParameterization(const Transform& t) { SetTransform6D(t); } | | IkParameterization(const Transform &t) { | |
| | | SetTransform6D(t); | |
| | | } | |
| /// \brief sets a ray parameterization | | /// \brief sets a ray parameterization | |
|
| IkParameterization(const RAY& r) { SetRay4D(r); } | | IkParameterization(const RAY &r) { | |
| | | SetRay4D(r); | |
| | | } | |
| /// \brief set a custom parameterization using a transform as the sourc
e of the data. Not all types are supported with this method. | | /// \brief set a custom parameterization using a transform as the sourc
e of the data. Not all types are supported with this method. | |
|
| IkParameterization(const Transform& t, Type type) { | | IkParameterization(const Transform &t, Type type) { | |
| _type=type; | | _type=type; | |
| switch(_type) { | | switch(_type) { | |
| case Type_Transform6D: SetTransform6D(t); break; | | case Type_Transform6D: SetTransform6D(t); break; | |
| case Type_Rotation3D: SetRotation3D(t.rot); break; | | case Type_Rotation3D: SetRotation3D(t.rot); break; | |
| case Type_Translation3D: SetTranslation3D(t.trans); break; | | case Type_Translation3D: SetTranslation3D(t.trans); break; | |
| case Type_Lookat3D: SetLookat3D(t.trans); break; | | case Type_Lookat3D: SetLookat3D(t.trans); break; | |
| default: | | default: | |
| throw openrave_exception(str(boost::format("IkParameterization
constructor does not support type 0x%x")%_type)); | | throw openrave_exception(str(boost::format("IkParameterization
constructor does not support type 0x%x")%_type)); | |
| } | | } | |
| } | | } | |
| | | | |
|
| inline Type GetType() const { return _type; } | | inline Type GetType() const { | |
| | | return _type; | |
| | | } | |
| inline const std::string& GetName() const; | | inline const std::string& GetName() const; | |
| | | | |
| /// \brief Returns the minimum degree of freedoms required for the IK t
ype. | | /// \brief Returns the minimum degree of freedoms required for the IK t
ype. | |
|
| static int GetDOF(Type type) { return (type>>28)&0xf; } | | static int GetDOF(Type type) { | |
| | | return (type>>28)&0xf; | |
| | | } | |
| /// \brief Returns the minimum degree of freedoms required for the IK t
ype. | | /// \brief Returns the minimum degree of freedoms required for the IK t
ype. | |
|
| inline int GetDOF() const { return (_type>>28)&0xf; } | | inline int GetDOF() const { | |
| | | return (_type>>28)&0xf; | |
| | | } | |
| | | | |
| /// \brief Returns the number of values used to represent the parameter
ization ( >= dof ). The number of values serialized is this number plus 1 f
or the iktype. | | /// \brief Returns the number of values used to represent the parameter
ization ( >= dof ). The number of values serialized is this number plus 1 f
or the iktype. | |
|
| static int GetNumberOfValues(Type type) { return (type>>24)&0xf; } | | static int GetNumberOfValues(Type type) { | |
| | | return (type>>24)&0xf; | |
| | | } | |
| /// \brief Returns the number of values used to represent the parameter
ization ( >= dof ). The number of values serialized is this number plus 1 f
or the iktype. | | /// \brief Returns the number of values used to represent the parameter
ization ( >= dof ). The number of values serialized is this number plus 1 f
or the iktype. | |
|
| inline int GetNumberOfValues() const { return (_type>>24)&0xf; } | | inline int GetNumberOfValues() const { | |
| | | return (_type>>24)&0xf; | |
| | | } | |
| | | | |
|
| inline void SetTransform6D(const Transform& t) { _type = Type_Transform | | inline void SetTransform6D(const Transform& t) { | |
| 6D; _transform = t; } | | _type = Type_Transform6D; _transform = t; | |
| inline void SetRotation3D(const Vector& quaternion) { _type = Type_Rota | | } | |
| tion3D; _transform.rot = quaternion; } | | inline void SetRotation3D(const Vector& quaternion) { | |
| inline void SetTranslation3D(const Vector& trans) { _type = Type_Transl | | _type = Type_Rotation3D; _transform.rot = quaternion; | |
| ation3D; _transform.trans = trans; } | | } | |
| inline void SetDirection3D(const Vector& dir) { _type = Type_Direction3 | | inline void SetTranslation3D(const Vector& trans) { | |
| D; _transform.rot = dir; } | | _type = Type_Translation3D; _transform.trans = trans; | |
| inline void SetRay4D(const RAY& ray) { _type = Type_Ray4D; _transform.t | | } | |
| rans = ray.pos; _transform.rot = ray.dir; } | | inline void SetDirection3D(const Vector& dir) { | |
| inline void SetLookat3D(const Vector& trans) { _type = Type_Lookat3D; _ | | _type = Type_Direction3D; _transform.rot = dir; | |
| transform.trans = trans; } | | } | |
| | | inline void SetRay4D(const RAY& ray) { | |
| | | _type = Type_Ray4D; _transform.trans = ray.pos; _transform.rot = ra | |
| | | y.dir; | |
| | | } | |
| | | inline void SetLookat3D(const Vector& trans) { | |
| | | _type = Type_Lookat3D; _transform.trans = trans; | |
| | | } | |
| /// \brief the ray direction is not used for IK, however it is needed i
n order to compute the error | | /// \brief the ray direction is not used for IK, however it is needed i
n order to compute the error | |
|
| inline void SetLookat3D(const RAY& ray) { _type = Type_Lookat3D; _trans | | inline void SetLookat3D(const RAY& ray) { | |
| form.trans = ray.pos; _transform.rot = ray.dir; } | | _type = Type_Lookat3D; _transform.trans = ray.pos; _transform.rot = | |
| inline void SetTranslationDirection5D(const RAY& ray) { _type = Type_Tr | | ray.dir; | |
| anslationDirection5D; _transform.trans = ray.pos; _transform.rot = ray.dir; | | } | |
| } | | inline void SetTranslationDirection5D(const RAY& ray) { | |
| inline void SetTranslationXY2D(const Vector& trans) { _type = Type_Tran | | _type = Type_TranslationDirection5D; _transform.trans = ray.pos; _t | |
| slationXY2D; _transform.trans.x = trans.x; _transform.trans.y = trans.y; _t | | ransform.rot = ray.dir; | |
| ransform.trans.z = 0; _transform.trans.w = 0; } | | } | |
| inline void SetTranslationXYOrientation3D(const Vector& trans) { _type | | inline void SetTranslationXY2D(const Vector& trans) { | |
| = Type_TranslationXYOrientation3D; _transform.trans.x = trans.x; _transform | | _type = Type_TranslationXY2D; _transform.trans.x = trans.x; _transf | |
| .trans.y = trans.y; _transform.trans.z = trans.z; _transform.trans.w = 0; } | | orm.trans.y = trans.y; _transform.trans.z = 0; _transform.trans.w = 0; | |
| inline void SetTranslationLocalGlobal6D(const Vector& localtrans, const | | } | |
| Vector& trans) { _type = Type_TranslationLocalGlobal6D; _transform.rot.x = | | inline void SetTranslationXYOrientation3D(const Vector& trans) { | |
| localtrans.x; _transform.rot.y = localtrans.y; _transform.rot.z = localtra | | _type = Type_TranslationXYOrientation3D; _transform.trans.x = trans | |
| ns.z; _transform.rot.w = 0; _transform.trans.x = trans.x; _transform.trans. | | .x; _transform.trans.y = trans.y; _transform.trans.z = trans.z; _transform. | |
| y = trans.y; _transform.trans.z = trans.z; _transform.trans.w = 0; } | | trans.w = 0; | |
| | | } | |
| | | inline void SetTranslationLocalGlobal6D(const Vector& localtrans, const | |
| | | Vector& trans) { | |
| | | _type = Type_TranslationLocalGlobal6D; _transform.rot.x = localtran | |
| | | s.x; _transform.rot.y = localtrans.y; _transform.rot.z = localtrans.z; _tra | |
| | | nsform.rot.w = 0; _transform.trans.x = trans.x; _transform.trans.y = trans. | |
| | | y; _transform.trans.z = trans.z; _transform.trans.w = 0; | |
| | | } | |
| | | | |
|
| inline const Transform& GetTransform6D() const { return _transform; } | | inline const Transform& GetTransform6D() const { | |
| inline const Vector& GetRotation3D() const { return _transform.rot; } | | return _transform; | |
| inline const Vector& GetTranslation3D() const { return _transform.trans | | } | |
| ; } | | inline const Vector& GetRotation3D() const { | |
| inline const Vector& GetDirection3D() const { return _transform.rot; } | | return _transform.rot; | |
| inline const RAY GetRay4D() const { return RAY(_transform.trans,_transf | | } | |
| orm.rot); } | | inline const Vector& GetTranslation3D() const { | |
| inline const Vector& GetLookat3D() const { return _transform.trans; } | | return _transform.trans; | |
| inline const Vector& GetLookat3DDirection() const { return _transform.r | | } | |
| ot; } | | inline const Vector& GetDirection3D() const { | |
| inline const RAY GetTranslationDirection5D() const { return RAY(_transf | | return _transform.rot; | |
| orm.trans,_transform.rot); } | | } | |
| inline const Vector& GetTranslationXY2D() const { return _transform.tra | | inline const RAY GetRay4D() const { | |
| ns; } | | return RAY(_transform.trans,_transform.rot); | |
| inline const Vector& GetTranslationXYOrientation3D() const { return _tr | | } | |
| ansform.trans; } | | inline const Vector& GetLookat3D() const { | |
| inline std::pair<Vector,Vector> GetTranslationLocalGlobal6D() const { r | | return _transform.trans; | |
| eturn std::make_pair(_transform.rot,_transform.trans); } | | } | |
| | | inline const Vector& GetLookat3DDirection() const { | |
| | | return _transform.rot; | |
| | | } | |
| | | inline const RAY GetTranslationDirection5D() const { | |
| | | return RAY(_transform.trans,_transform.rot); | |
| | | } | |
| | | inline const Vector& GetTranslationXY2D() const { | |
| | | return _transform.trans; | |
| | | } | |
| | | inline const Vector& GetTranslationXYOrientation3D() const { | |
| | | return _transform.trans; | |
| | | } | |
| | | inline std::pair<Vector,Vector> GetTranslationLocalGlobal6D() const { | |
| | | return std::make_pair(_transform.rot,_transform.trans); | |
| | | } | |
| | | | |
| /// \deprecated (11/02/15) | | /// \deprecated (11/02/15) | |
| //@{ | | //@{ | |
|
| inline void SetTransform(const Transform& t) RAVE_DEPRECATED { SetTrans | | inline void SetTransform(const Transform& t) RAVE_DEPRECATED { | |
| form6D(t); } | | SetTransform6D(t); | |
| inline void SetRotation(const Vector& quaternion) RAVE_DEPRECATED { Set | | } | |
| Rotation3D(quaternion); } | | inline void SetRotation(const Vector& quaternion) RAVE_DEPRECATED { | |
| inline void SetTranslation(const Vector& trans) RAVE_DEPRECATED { SetTr | | SetRotation3D(quaternion); | |
| anslation3D(trans); } | | } | |
| inline void SetDirection(const Vector& dir) RAVE_DEPRECATED { SetDirect | | inline void SetTranslation(const Vector& trans) RAVE_DEPRECATED { | |
| ion3D(dir); } | | SetTranslation3D(trans); | |
| inline void SetRay(const RAY& ray) RAVE_DEPRECATED { SetRay4D(ray); } | | } | |
| inline void SetLookat(const Vector& trans) RAVE_DEPRECATED { SetLookat3 | | inline void SetDirection(const Vector& dir) RAVE_DEPRECATED { | |
| D(trans); } | | SetDirection3D(dir); | |
| inline void SetTranslationDirection(const RAY& ray) RAVE_DEPRECATED { S | | } | |
| etTranslationDirection5D(ray); } | | inline void SetRay(const RAY& ray) RAVE_DEPRECATED { | |
| inline const Transform& GetTransform() const RAVE_DEPRECATED { return _ | | SetRay4D(ray); | |
| transform; } | | } | |
| inline const Vector& GetRotation() const RAVE_DEPRECATED { return _tran | | inline void SetLookat(const Vector& trans) RAVE_DEPRECATED { | |
| sform.rot; } | | SetLookat3D(trans); | |
| inline const Vector& GetTranslation() const RAVE_DEPRECATED { return _t | | } | |
| ransform.trans; } | | inline void SetTranslationDirection(const RAY& ray) RAVE_DEPRECATED { | |
| inline const Vector& GetDirection() const RAVE_DEPRECATED { return _tra | | SetTranslationDirection5D(ray); | |
| nsform.rot; } | | } | |
| inline const Vector& GetLookat() const RAVE_DEPRECATED { return _transf | | inline const Transform& GetTransform() const RAVE_DEPRECATED { | |
| orm.trans; } | | return _transform; | |
| inline const RAY GetRay() const RAVE_DEPRECATED { return RAY(_transform | | } | |
| .trans,_transform.rot); } | | inline const Vector& GetRotation() const RAVE_DEPRECATED { | |
| inline const RAY GetTranslationDirection() const RAVE_DEPRECATED { retu | | return _transform.rot; | |
| rn RAY(_transform.trans,_transform.rot); } | | } | |
| | | inline const Vector& GetTranslation() const RAVE_DEPRECATED { | |
| | | return _transform.trans; | |
| | | } | |
| | | inline const Vector& GetDirection() const RAVE_DEPRECATED { | |
| | | return _transform.rot; | |
| | | } | |
| | | inline const Vector& GetLookat() const RAVE_DEPRECATED { | |
| | | return _transform.trans; | |
| | | } | |
| | | inline const RAY GetRay() const RAVE_DEPRECATED { | |
| | | return RAY(_transform.trans,_transform.rot); | |
| | | } | |
| | | inline const RAY GetTranslationDirection() const RAVE_DEPRECATED { | |
| | | return RAY(_transform.trans,_transform.rot); | |
| | | } | |
| //@} | | //@} | |
| | | | |
| /// \brief Computes the distance squared between two IK parmaeterizatio
ns. | | /// \brief Computes the distance squared between two IK parmaeterizatio
ns. | |
| inline dReal ComputeDistanceSqr(const IkParameterization& ikparam) cons
t | | inline dReal ComputeDistanceSqr(const IkParameterization& ikparam) cons
t | |
| { | | { | |
|
| const dReal anglemult = 0.4; // this is a hack that should be remov
ed.... | | const dReal anglemult = 0.4; // this is a hack that should be r
emoved.... | |
| BOOST_ASSERT(_type==ikparam.GetType()); | | BOOST_ASSERT(_type==ikparam.GetType()); | |
| switch(_type) { | | switch(_type) { | |
| case IkParameterization::Type_Transform6D: { | | case IkParameterization::Type_Transform6D: { | |
| Transform t0 = GetTransform6D(), t1 = ikparam.GetTransform6D(); | | Transform t0 = GetTransform6D(), t1 = ikparam.GetTransform6D(); | |
| dReal fcos = RaveFabs(t0.rot.dot(t1.rot)); | | dReal fcos = RaveFabs(t0.rot.dot(t1.rot)); | |
| dReal facos = fcos >= 1 ? 0 : RaveAcos(fcos); | | dReal facos = fcos >= 1 ? 0 : RaveAcos(fcos); | |
| return (t0.trans-t1.trans).lengthsqr3() + anglemult*facos*facos
; | | return (t0.trans-t1.trans).lengthsqr3() + anglemult*facos*facos
; | |
| } | | } | |
| case IkParameterization::Type_Rotation3D: { | | case IkParameterization::Type_Rotation3D: { | |
| dReal fcos = RaveFabs(GetRotation3D().dot(ikparam.GetRotation3D
())); | | dReal fcos = RaveFabs(GetRotation3D().dot(ikparam.GetRotation3D
())); | |
| | | | |
| skipping to change at line 893 | | skipping to change at line 999 | |
| case IkParameterization::Type_Ray4D: { | | case IkParameterization::Type_Ray4D: { | |
| Vector pos0 = GetRay4D().pos - GetRay4D().dir*GetRay4D().dir.do
t(GetRay4D().pos); | | Vector pos0 = GetRay4D().pos - GetRay4D().dir*GetRay4D().dir.do
t(GetRay4D().pos); | |
| Vector pos1 = ikparam.GetRay4D().pos - ikparam.GetRay4D().dir*i
kparam.GetRay4D().dir.dot(ikparam.GetRay4D().pos); | | Vector pos1 = ikparam.GetRay4D().pos - ikparam.GetRay4D().dir*i
kparam.GetRay4D().dir.dot(ikparam.GetRay4D().pos); | |
| dReal fcos = GetRay4D().dir.dot(ikparam.GetRay4D().dir); | | dReal fcos = GetRay4D().dir.dot(ikparam.GetRay4D().dir); | |
| dReal facos = fcos >= 1 ? 0 : RaveAcos(fcos); | | dReal facos = fcos >= 1 ? 0 : RaveAcos(fcos); | |
| return (pos0-pos1).lengthsqr3() + anglemult*facos*facos; | | return (pos0-pos1).lengthsqr3() + anglemult*facos*facos; | |
| } | | } | |
| case IkParameterization::Type_Lookat3D: { | | case IkParameterization::Type_Lookat3D: { | |
| Vector v = GetLookat3D()-ikparam.GetLookat3D(); | | Vector v = GetLookat3D()-ikparam.GetLookat3D(); | |
| dReal s = v.dot3(ikparam.GetLookat3DDirection()); | | dReal s = v.dot3(ikparam.GetLookat3DDirection()); | |
|
| if( s >= -1 ) { // ikparam's lookat is always 1 beyond the orig
in, this is just the convention for testing... | | if( s >= -1 ) { // ikparam's lookat is always 1 beyond the
origin, this is just the convention for testing... | |
| v -= s*ikparam.GetLookat3DDirection(); | | v -= s*ikparam.GetLookat3DDirection(); | |
| } | | } | |
| return v.lengthsqr3(); | | return v.lengthsqr3(); | |
| } | | } | |
| case IkParameterization::Type_TranslationDirection5D: { | | case IkParameterization::Type_TranslationDirection5D: { | |
| dReal fcos = GetTranslationDirection5D().dir.dot(ikparam.GetTra
nslationDirection5D().dir); | | dReal fcos = GetTranslationDirection5D().dir.dot(ikparam.GetTra
nslationDirection5D().dir); | |
| dReal facos = fcos >= 1 ? 0 : RaveAcos(fcos); | | dReal facos = fcos >= 1 ? 0 : RaveAcos(fcos); | |
| return (GetTranslationDirection5D().pos-ikparam.GetTranslationD
irection5D().pos).lengthsqr3() + anglemult*facos*facos; | | return (GetTranslationDirection5D().pos-ikparam.GetTranslationD
irection5D().pos).lengthsqr3() + anglemult*facos*facos; | |
| } | | } | |
| case IkParameterization::Type_TranslationXY2D: { | | case IkParameterization::Type_TranslationXY2D: { | |
| | | | |
| skipping to change at line 936 | | skipping to change at line 1042 | |
| default: | | default: | |
| BOOST_ASSERT(0); | | BOOST_ASSERT(0); | |
| } | | } | |
| return 1e30; | | return 1e30; | |
| } | | } | |
| | | | |
| protected: | | protected: | |
| Transform _transform; | | Transform _transform; | |
| Type _type; | | Type _type; | |
| | | | |
|
| friend IkParameterization operator* (const Transform& t, const IkParame | | friend IkParameterization operator* (const Transform &t, const IkParame | |
| terization& ikparam); | | terization &ikparam); | |
| friend std::ostream& operator<<(std::ostream& O, const IkParameterizati | | friend std::ostream& operator<<(std::ostream& O, const IkParameterizati | |
| on& ikparam); | | on &ikparam); | |
| friend std::istream& operator>>(std::istream& I, IkParameterization& ik
param); | | friend std::istream& operator>>(std::istream& I, IkParameterization& ik
param); | |
| }; | | }; | |
| | | | |
|
| inline IkParameterization operator* (const Transform& t, const IkParameteri
zation& ikparam) | | inline IkParameterization operator* (const Transform &t, const IkParameteri
zation &ikparam) | |
| { | | { | |
| IkParameterization local; | | IkParameterization local; | |
| switch(ikparam.GetType()) { | | switch(ikparam.GetType()) { | |
| case IkParameterization::Type_Transform6D: | | case IkParameterization::Type_Transform6D: | |
| local.SetTransform6D(t * ikparam.GetTransform6D()); | | local.SetTransform6D(t * ikparam.GetTransform6D()); | |
| break; | | break; | |
| case IkParameterization::Type_Rotation3D: | | case IkParameterization::Type_Rotation3D: | |
| local.SetRotation3D(quatMultiply(quatInverse(t.rot),ikparam.GetRota
tion3D())); | | local.SetRotation3D(quatMultiply(quatInverse(t.rot),ikparam.GetRota
tion3D())); | |
| break; | | break; | |
| case IkParameterization::Type_Translation3D: | | case IkParameterization::Type_Translation3D: | |
| | | | |
| skipping to change at line 986 | | skipping to change at line 1092 | |
| } | | } | |
| case IkParameterization::Type_TranslationLocalGlobal6D: | | case IkParameterization::Type_TranslationLocalGlobal6D: | |
| local.SetTranslationLocalGlobal6D(ikparam.GetTranslationLocalGlobal
6D().first, t*ikparam.GetTranslationLocalGlobal6D().second); | | local.SetTranslationLocalGlobal6D(ikparam.GetTranslationLocalGlobal
6D().first, t*ikparam.GetTranslationLocalGlobal6D().second); | |
| break; | | break; | |
| default: | | default: | |
| throw openrave_exception(str(boost::format("does not support parame
terization %d")%ikparam.GetType())); | | throw openrave_exception(str(boost::format("does not support parame
terization %d")%ikparam.GetType())); | |
| } | | } | |
| return local; | | return local; | |
| } | | } | |
| | | | |
|
| inline std::ostream& operator<<(std::ostream& O, const IkParameterization&
ikparam) | | inline std::ostream& operator<<(std::ostream& O, const IkParameterization &
ikparam) | |
| { | | { | |
| O << ikparam._type << " "; | | O << ikparam._type << " "; | |
| switch(ikparam._type) { | | switch(ikparam._type) { | |
| case IkParameterization::Type_Transform6D: | | case IkParameterization::Type_Transform6D: | |
| O << ikparam.GetTransform6D(); | | O << ikparam.GetTransform6D(); | |
| break; | | break; | |
| case IkParameterization::Type_Rotation3D: | | case IkParameterization::Type_Rotation3D: | |
| O << ikparam.GetRotation3D(); | | O << ikparam.GetRotation3D(); | |
| break; | | break; | |
| case IkParameterization::Type_Translation3D: { | | case IkParameterization::Type_Translation3D: { | |
| | | | |
| skipping to change at line 1053 | | skipping to change at line 1159 | |
| ikparam._type = static_cast<IkParameterization::Type>(type); | | ikparam._type = static_cast<IkParameterization::Type>(type); | |
| switch(ikparam._type) { | | switch(ikparam._type) { | |
| case IkParameterization::Type_Transform6D: { Transform t; I >> t; ikpar
am.SetTransform6D(t); break; } | | case IkParameterization::Type_Transform6D: { Transform t; I >> t; ikpar
am.SetTransform6D(t); break; } | |
| case IkParameterization::Type_Rotation3D: { Vector v; I >> v; ikparam.S
etRotation3D(v); break; } | | case IkParameterization::Type_Rotation3D: { Vector v; I >> v; ikparam.S
etRotation3D(v); break; } | |
| case IkParameterization::Type_Translation3D: { Vector v; I >> v.x >> v.
y >> v.z; ikparam.SetTranslation3D(v); break; } | | case IkParameterization::Type_Translation3D: { Vector v; I >> v.x >> v.
y >> v.z; ikparam.SetTranslation3D(v); break; } | |
| case IkParameterization::Type_Direction3D: { Vector v; I >> v.x >> v.y
>> v.z; ikparam.SetDirection3D(v); break; } | | case IkParameterization::Type_Direction3D: { Vector v; I >> v.x >> v.y
>> v.z; ikparam.SetDirection3D(v); break; } | |
| case IkParameterization::Type_Ray4D: { RAY r; I >> r; ikparam.SetRay4D(
r); break; } | | case IkParameterization::Type_Ray4D: { RAY r; I >> r; ikparam.SetRay4D(
r); break; } | |
| case IkParameterization::Type_Lookat3D: { Vector v; I >> v.x >> v.y >>
v.z; ikparam.SetLookat3D(v); break; } | | case IkParameterization::Type_Lookat3D: { Vector v; I >> v.x >> v.y >>
v.z; ikparam.SetLookat3D(v); break; } | |
| case IkParameterization::Type_TranslationDirection5D: { RAY r; I >> r;
ikparam.SetTranslationDirection5D(r); break; } | | case IkParameterization::Type_TranslationDirection5D: { RAY r; I >> r;
ikparam.SetTranslationDirection5D(r); break; } | |
| case IkParameterization::Type_TranslationXY2D: { Vector v; I >> v.y >>
v.y; ikparam.SetTranslationXY2D(v); break; } | | case IkParameterization::Type_TranslationXY2D: { Vector v; I >> v.y >>
v.y; ikparam.SetTranslationXY2D(v); break; } | |
|
| case IkParameterization::Type_TranslationXYOrientation3D: { Vector v;
I >> v.y >> v.y >> v.z; ikparam.SetTranslationXYOrientation3D(v); break; } | | case IkParameterization::Type_TranslationXYOrientation3D: { Vector v; I
>> v.y >> v.y >> v.z; ikparam.SetTranslationXYOrientation3D(v); break; } | |
| case IkParameterization::Type_TranslationLocalGlobal6D: { Vector localt
rans, trans; I >> localtrans.x >> localtrans.y >> localtrans.z >> trans.x >
> trans.y >> trans.z; ikparam.SetTranslationLocalGlobal6D(localtrans,trans)
; break; } | | case IkParameterization::Type_TranslationLocalGlobal6D: { Vector localt
rans, trans; I >> localtrans.x >> localtrans.y >> localtrans.z >> trans.x >
> trans.y >> trans.z; ikparam.SetTranslationLocalGlobal6D(localtrans,trans)
; break; } | |
| default: throw openrave_exception(str(boost::format("does not support p
arameterization %d")%ikparam.GetType())); | | default: throw openrave_exception(str(boost::format("does not support p
arameterization %d")%ikparam.GetType())); | |
| } | | } | |
| return I; | | return I; | |
| } | | } | |
| | | | |
| } | | } | |
| | | | |
| #include <openrave/plugininfo.h> | | #include <openrave/plugininfo.h> | |
| #include <openrave/interface.h> | | #include <openrave/interface.h> | |
| | | | |
| skipping to change at line 1118 | | skipping to change at line 1224 | |
| /// safely casts from the base interface class to an openrave interface usi
ng static_pointer_cast. | | /// safely casts from the base interface class to an openrave interface usi
ng static_pointer_cast. | |
| /// The reason why dynamic_pointer_cast cannot be used is because interface
s might be created by different plugins, and the runtime type information w
ill be different. | | /// The reason why dynamic_pointer_cast cannot be used is because interface
s might be created by different plugins, and the runtime type information w
ill be different. | |
| template <typename T> | | template <typename T> | |
| inline boost::shared_ptr<T> RaveInterfaceCast(InterfaceBasePtr pinterface) | | inline boost::shared_ptr<T> RaveInterfaceCast(InterfaceBasePtr pinterface) | |
| { | | { | |
| if( !!pinterface ) { | | if( !!pinterface ) { | |
| if( pinterface->GetInterfaceType() == T::GetInterfaceTypeStatic() )
{ | | if( pinterface->GetInterfaceType() == T::GetInterfaceTypeStatic() )
{ | |
| return boost::static_pointer_cast<T>(pinterface); | | return boost::static_pointer_cast<T>(pinterface); | |
| } | | } | |
| // encode special cases | | // encode special cases | |
|
| if( pinterface->GetInterfaceType() == PT_Robot && T::GetInterfaceTy
peStatic() == PT_KinBody ) { | | if((pinterface->GetInterfaceType() == PT_Robot)&&(T::GetInterfaceTy
peStatic() == PT_KinBody)) { | |
| return boost::static_pointer_cast<T>(pinterface); | | return boost::static_pointer_cast<T>(pinterface); | |
| } | | } | |
| } | | } | |
| return boost::shared_ptr<T>(); | | return boost::shared_ptr<T>(); | |
| } | | } | |
| | | | |
| /// safely casts from the base interface class to an openrave interface usi
ng static_pointer_cast. | | /// safely casts from the base interface class to an openrave interface usi
ng static_pointer_cast. | |
| /// The reason why dynamic_pointer_cast cannot be used is because interface
s might be created by different plugins, and the runtime type information w
ill be different. | | /// The reason why dynamic_pointer_cast cannot be used is because interface
s might be created by different plugins, and the runtime type information w
ill be different. | |
| template <typename T> | | template <typename T> | |
| inline boost::shared_ptr<T const> RaveInterfaceConstCast(InterfaceBaseConst
Ptr pinterface) | | inline boost::shared_ptr<T const> RaveInterfaceConstCast(InterfaceBaseConst
Ptr pinterface) | |
| { | | { | |
| if( !!pinterface ) { | | if( !!pinterface ) { | |
| if( pinterface->GetInterfaceType() == T::GetInterfaceTypeStatic() )
{ | | if( pinterface->GetInterfaceType() == T::GetInterfaceTypeStatic() )
{ | |
| return boost::static_pointer_cast<T const>(pinterface); | | return boost::static_pointer_cast<T const>(pinterface); | |
| } | | } | |
| // encode special cases | | // encode special cases | |
|
| if( pinterface->GetInterfaceType() == PT_Robot && T::GetInterfaceTy
peStatic() == PT_KinBody ) { | | if((pinterface->GetInterfaceType() == PT_Robot)&&(T::GetInterfaceTy
peStatic() == PT_KinBody)) { | |
| return boost::static_pointer_cast<T const>(pinterface); | | return boost::static_pointer_cast<T const>(pinterface); | |
| } | | } | |
| } | | } | |
| return boost::shared_ptr<T>(); | | return boost::shared_ptr<T>(); | |
| } | | } | |
| | | | |
| /// \brief returns a lower case string of the interface type | | /// \brief returns a lower case string of the interface type | |
| OPENRAVE_API const std::map<InterfaceType,std::string>& RaveGetInterfaceNam
esMap(); | | OPENRAVE_API const std::map<InterfaceType,std::string>& RaveGetInterfaceNam
esMap(); | |
| OPENRAVE_API const std::string& RaveGetInterfaceName(InterfaceType type); | | OPENRAVE_API const std::string& RaveGetInterfaceName(InterfaceType type); | |
| | | | |
| | | | |
| skipping to change at line 1224 | | skipping to change at line 1330 | |
| OPENRAVE_API ControllerBasePtr RaveCreateController(EnvironmentBasePtr penv
, const std::string& name); | | OPENRAVE_API ControllerBasePtr RaveCreateController(EnvironmentBasePtr penv
, const std::string& name); | |
| OPENRAVE_API ModuleBasePtr RaveCreateModule(EnvironmentBasePtr penv, const
std::string& name); | | OPENRAVE_API ModuleBasePtr RaveCreateModule(EnvironmentBasePtr penv, const
std::string& name); | |
| OPENRAVE_API ModuleBasePtr RaveCreateProblem(EnvironmentBasePtr penv, const
std::string& name); | | OPENRAVE_API ModuleBasePtr RaveCreateProblem(EnvironmentBasePtr penv, const
std::string& name); | |
| OPENRAVE_API ModuleBasePtr RaveCreateProblemInstance(EnvironmentBasePtr pen
v, const std::string& name); | | OPENRAVE_API ModuleBasePtr RaveCreateProblemInstance(EnvironmentBasePtr pen
v, const std::string& name); | |
| OPENRAVE_API IkSolverBasePtr RaveCreateIkSolver(EnvironmentBasePtr penv, co
nst std::string& name); | | OPENRAVE_API IkSolverBasePtr RaveCreateIkSolver(EnvironmentBasePtr penv, co
nst std::string& name); | |
| OPENRAVE_API PhysicsEngineBasePtr RaveCreatePhysicsEngine(EnvironmentBasePt
r penv, const std::string& name); | | OPENRAVE_API PhysicsEngineBasePtr RaveCreatePhysicsEngine(EnvironmentBasePt
r penv, const std::string& name); | |
| OPENRAVE_API SensorBasePtr RaveCreateSensor(EnvironmentBasePtr penv, const
std::string& name); | | OPENRAVE_API SensorBasePtr RaveCreateSensor(EnvironmentBasePtr penv, const
std::string& name); | |
| OPENRAVE_API CollisionCheckerBasePtr RaveCreateCollisionChecker(Environment
BasePtr penv, const std::string& name); | | OPENRAVE_API CollisionCheckerBasePtr RaveCreateCollisionChecker(Environment
BasePtr penv, const std::string& name); | |
| OPENRAVE_API ViewerBasePtr RaveCreateViewer(EnvironmentBasePtr penv, const
std::string& name); | | OPENRAVE_API ViewerBasePtr RaveCreateViewer(EnvironmentBasePtr penv, const
std::string& name); | |
| OPENRAVE_API SpaceSamplerBasePtr RaveCreateSpaceSampler(EnvironmentBasePtr
penv, const std::string& name); | | OPENRAVE_API SpaceSamplerBasePtr RaveCreateSpaceSampler(EnvironmentBasePtr
penv, const std::string& name); | |
|
| OPENRAVE_API KinBodyPtr RaveCreateKinBody(EnvironmentBasePtr penv, const s
td::string& name=""); | | OPENRAVE_API KinBodyPtr RaveCreateKinBody(EnvironmentBasePtr penv, const st
d::string& name=""); | |
| /// \brief Return an empty trajectory instance initialized to nDOF degrees
of freedom. Will be deprecated soon | | /// \brief Return an empty trajectory instance initialized to nDOF degrees
of freedom. Will be deprecated soon | |
| OPENRAVE_API TrajectoryBasePtr RaveCreateTrajectory(EnvironmentBasePtr penv
, int nDOF); | | OPENRAVE_API TrajectoryBasePtr RaveCreateTrajectory(EnvironmentBasePtr penv
, int nDOF); | |
| /// \brief Return an empty trajectory instance. | | /// \brief Return an empty trajectory instance. | |
| OPENRAVE_API TrajectoryBasePtr RaveCreateTrajectory(EnvironmentBasePtr penv
, const std::string& name=""); | | OPENRAVE_API TrajectoryBasePtr RaveCreateTrajectory(EnvironmentBasePtr penv
, const std::string& name=""); | |
| | | | |
| /** \brief Registers a function to create an interface, this allows the int
erface to be created by other modules. | | /** \brief Registers a function to create an interface, this allows the int
erface to be created by other modules. | |
| | | | |
| \param type interface type | | \param type interface type | |
| \param name interface name | | \param name interface name | |
| \param interfacehash the hash of the interface being created (use the g
lobal defines OPENRAVE_X_HASH) | | \param interfacehash the hash of the interface being created (use the g
lobal defines OPENRAVE_X_HASH) | |
| | | | |
| skipping to change at line 1249 | | skipping to change at line 1355 | |
| */ | | */ | |
| OPENRAVE_API boost::shared_ptr<void> RaveRegisterInterface(InterfaceType ty
pe, const std::string& name, const char* interfacehash, const char* envhash
, const boost::function<InterfaceBasePtr(EnvironmentBasePtr, std::istream&)
>& createfn); | | OPENRAVE_API boost::shared_ptr<void> RaveRegisterInterface(InterfaceType ty
pe, const std::string& name, const char* interfacehash, const char* envhash
, const boost::function<InterfaceBasePtr(EnvironmentBasePtr, std::istream&)
>& createfn); | |
| | | | |
| /** \brief Registers a custom xml reader for a particular interface. | | /** \brief Registers a custom xml reader for a particular interface. | |
| | | | |
| Once registered, anytime an interface is created through XML and | | Once registered, anytime an interface is created through XML and | |
| the xmltag is seen, the function CreateXMLReaderFn will be called to ge
t a reader for that tag | | the xmltag is seen, the function CreateXMLReaderFn will be called to ge
t a reader for that tag | |
| \param xmltag the tag specified in xmltag is seen in the interface, the
the custom reader will be created. | | \param xmltag the tag specified in xmltag is seen in the interface, the
the custom reader will be created. | |
| \param fn CreateXMLReaderFn(pinterface,atts) - passed in the pointer to
the interface where the tag was seen along with the list of attributes | | \param fn CreateXMLReaderFn(pinterface,atts) - passed in the pointer to
the interface where the tag was seen along with the list of attributes | |
| \return a pointer holding the registration, releasing the pointer will
unregister the XML reader | | \return a pointer holding the registration, releasing the pointer will
unregister the XML reader | |
|
| */ | | */ | |
| OPENRAVE_API boost::shared_ptr<void> RaveRegisterXMLReader(InterfaceType ty
pe, const std::string& xmltag, const CreateXMLReaderFn& fn); | | OPENRAVE_API boost::shared_ptr<void> RaveRegisterXMLReader(InterfaceType ty
pe, const std::string& xmltag, const CreateXMLReaderFn& fn); | |
| | | | |
| /// \brief return the environment's unique id, returns 0 if environment cou
ld not be found or not registered | | /// \brief return the environment's unique id, returns 0 if environment cou
ld not be found or not registered | |
| OPENRAVE_API int RaveGetEnvironmentId(EnvironmentBasePtr penv); | | OPENRAVE_API int RaveGetEnvironmentId(EnvironmentBasePtr penv); | |
| | | | |
| /// \brief get the environment from its unique id | | /// \brief get the environment from its unique id | |
| /// \param id the unique environment id returned by \ref RaveGetEnvironment
Id | | /// \param id the unique environment id returned by \ref RaveGetEnvironment
Id | |
| OPENRAVE_API EnvironmentBasePtr RaveGetEnvironment(int id); | | OPENRAVE_API EnvironmentBasePtr RaveGetEnvironment(int id); | |
| | | | |
| /// \brief Return all the created OpenRAVE environments. | | /// \brief Return all the created OpenRAVE environments. | |
| | | | |
| skipping to change at line 1292 | | skipping to change at line 1398 | |
| if( !pdirs ) { | | if( !pdirs ) { | |
| return false; | | return false; | |
| } | | } | |
| // search for all directories separated by ':' | | // search for all directories separated by ':' | |
| std::string tmp = pdirs; | | std::string tmp = pdirs; | |
| std::string::size_type pos = 0, newpos=0; | | std::string::size_type pos = 0, newpos=0; | |
| while( pos < tmp.size() ) { | | while( pos < tmp.size() ) { | |
| #ifdef _WIN32 | | #ifdef _WIN32 | |
| newpos = tmp.find(';', pos); | | newpos = tmp.find(';', pos); | |
| #else | | #else | |
|
| newpos = tmp.find(':', pos); | | newpos = tmp.find(':', pos); | |
| #endif | | #endif | |
| std::string::size_type n = newpos == std::string::npos ? tmp.size()
-pos : (newpos-pos); | | std::string::size_type n = newpos == std::string::npos ? tmp.size()
-pos : (newpos-pos); | |
| vdirs.push_back(tmp.substr(pos, n)); | | vdirs.push_back(tmp.substr(pos, n)); | |
| if( newpos == std::string::npos ) { | | if( newpos == std::string::npos ) { | |
| break; | | break; | |
| } | | } | |
| pos = newpos+1; | | pos = newpos+1; | |
| } | | } | |
| return true; | | return true; | |
| } | | } | |
| | | | |
End of changes. 65 change blocks. |
| 226 lines changed or deleted | | 304 lines changed or added | |
|
| planner.h | | planner.h | |
| | | | |
| skipping to change at line 19 | | skipping to change at line 19 | |
| // | | // | |
| // This program is distributed in the hope that it will be useful, | | // This program is distributed in the hope that it will be useful, | |
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| // GNU Lesser General Public License for more details. | | // GNU Lesser General Public License for more details. | |
| // | | // | |
| // You should have received a copy of the GNU Lesser General Public License | | // You should have received a copy of the GNU Lesser General Public License | |
| // along with this program. If not, see <http://www.gnu.org/licenses/>. | | // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| /** \file planner.h | | /** \file planner.h | |
| \brief Planning related defintions. | | \brief Planning related defintions. | |
|
| */ | | */ | |
| #ifndef OPENRAVE_PLANNER_H | | #ifndef OPENRAVE_PLANNER_H | |
| #define OPENRAVE_PLANNER_H | | #define OPENRAVE_PLANNER_H | |
| | | | |
| namespace OpenRAVE { | | namespace OpenRAVE { | |
| | | | |
| /** \brief <b>[interface]</b> Planner interface that generates trajectories
for the robot to follow around the environment. See \ref arch_planner. | | /** \brief <b>[interface]</b> Planner interface that generates trajectories
for the robot to follow around the environment. See \ref arch_planner. | |
| \ingroup interfaces | | \ingroup interfaces | |
|
| */ | | */ | |
| class OPENRAVE_API PlannerBase : public InterfaceBase | | class OPENRAVE_API PlannerBase : public InterfaceBase | |
| { | | { | |
| public: | | public: | |
| typedef std::list< std::vector<dReal> > ConfigurationList; | | typedef std::list< std::vector<dReal> > ConfigurationList; | |
| typedef boost::shared_ptr< PlannerBase::ConfigurationList > Configurati
onListPtr; | | typedef boost::shared_ptr< PlannerBase::ConfigurationList > Configurati
onListPtr; | |
| | | | |
| /** \brief Describes a common and serializable interface for planning p
arameters. | | /** \brief Describes a common and serializable interface for planning p
arameters. | |
| | | | |
| The class is serializable to XML, so can be loaded from file or pas
sed around the network. | | The class is serializable to XML, so can be loaded from file or pas
sed around the network. | |
| If extra parameters need to be specified, derive from this class an
d | | If extra parameters need to be specified, derive from this class an
d | |
| - add the extra tags to PlannerParameters::_vXMLParameters | | - add the extra tags to PlannerParameters::_vXMLParameters | |
| - override PlannerParameters::startElement and PlannerParameters::e
ndElement for processing | | - override PlannerParameters::startElement and PlannerParameters::e
ndElement for processing | |
| - possibly override the PlannerParameters::characters | | - possibly override the PlannerParameters::characters | |
| | | | |
| Also allows the parameters and descriptions to be serialized to reS
tructuredText for documentation purposes. | | Also allows the parameters and descriptions to be serialized to reS
tructuredText for documentation purposes. | |
|
| */ | | */ | |
| class OPENRAVE_API PlannerParameters : public BaseXMLReader, public XML
Readable | | class OPENRAVE_API PlannerParameters : public BaseXMLReader, public XML
Readable | |
| { | | { | |
|
| public: | | public: | |
| PlannerParameters(); | | PlannerParameters(); | |
|
| virtual ~PlannerParameters() {} | | virtual ~PlannerParameters() { | |
| | | } | |
| | | | |
| /// tries to copy data from one set of parameters to another in the
safest manner. | | /// tries to copy data from one set of parameters to another in the
safest manner. | |
| /// First serializes the data of the right hand into a string, then
initializes the current parameters via >> | | /// First serializes the data of the right hand into a string, then
initializes the current parameters via >> | |
| /// pointers to functions are copied directly | | /// pointers to functions are copied directly | |
| virtual PlannerParameters& operator=(const PlannerParameters& r); | | virtual PlannerParameters& operator=(const PlannerParameters& r); | |
| virtual void copy(boost::shared_ptr<PlannerParameters const> r); | | virtual void copy(boost::shared_ptr<PlannerParameters const> r); | |
| | | | |
| /// sets up the planner parameters to use the active joints of the
robot | | /// sets up the planner parameters to use the active joints of the
robot | |
| virtual void SetRobotActiveJoints(RobotBasePtr robot); | | virtual void SetRobotActiveJoints(RobotBasePtr robot); | |
| | | | |
| | | | |
| skipping to change at line 94 | | skipping to change at line 95 | |
| | | | |
| When called, q0 is guaranteed to be set on the robot. | | When called, q0 is guaranteed to be set on the robot. | |
| The function returns true if the path to q1 satisfies all the c
onstraints of the planner. | | The function returns true if the path to q1 satisfies all the c
onstraints of the planner. | |
| If q0==q1, and interval==IT_OpenStart or IT_OpenEnd, then only
one configuration should be checked. It is recommended to use IT_OpenStart. | | If q0==q1, and interval==IT_OpenStart or IT_OpenEnd, then only
one configuration should be checked. It is recommended to use IT_OpenStart. | |
| Because this function can internally use neighstatefn, need to
make sure that Q0->Q1 is going from initial to goal direction. | | Because this function can internally use neighstatefn, need to
make sure that Q0->Q1 is going from initial to goal direction. | |
| | | | |
| \param q0 is the configuration the robot is coming from (curren
tly set). | | \param q0 is the configuration the robot is coming from (curren
tly set). | |
| \param q1 is the configuration the robot should move to. | | \param q1 is the configuration the robot should move to. | |
| \param interval Specifies whether to check the end points of th
e interval for constraints | | \param interval Specifies whether to check the end points of th
e interval for constraints | |
| \param configurations Optional argument that will hold the inte
rmediate configuraitons checked between q0 and q1 configurations. The appen
ded configurations will be all valid and in free space. They are appended a
fter the items already stored on the list. | | \param configurations Optional argument that will hold the inte
rmediate configuraitons checked between q0 and q1 configurations. The appen
ded configurations will be all valid and in free space. They are appended a
fter the items already stored on the list. | |
|
| */ | | */ | |
| typedef boost::function<bool(const std::vector<dReal>&, const std:: | | typedef boost::function<bool (const std::vector<dReal>&, const std: | |
| vector<dReal>&, IntervalType, PlannerBase::ConfigurationListPtr)> CheckPath | | :vector<dReal>&, IntervalType, PlannerBase::ConfigurationListPtr)> CheckPat | |
| ConstraintFn; | | hConstraintFn; | |
| CheckPathConstraintFn _checkpathconstraintsfn; | | CheckPathConstraintFn _checkpathconstraintsfn; | |
| | | | |
| /// \brief Samples a random configuration (mandatory) | | /// \brief Samples a random configuration (mandatory) | |
| /// | | /// | |
| /// The dimension of the returned sample is the dimension of the co
nfiguration space. | | /// The dimension of the returned sample is the dimension of the co
nfiguration space. | |
| /// success = samplefn(newsample) | | /// success = samplefn(newsample) | |
|
| typedef boost::function<bool(std::vector<dReal>&)> SampleFn; | | typedef boost::function<bool (std::vector<dReal>&)> SampleFn; | |
| SampleFn _samplefn; | | SampleFn _samplefn; | |
| | | | |
| /// \brief Samples a valid goal configuration (optional). | | /// \brief Samples a valid goal configuration (optional). | |
| /// | | /// | |
| /// If valid, the function should be called | | /// If valid, the function should be called | |
| /// at every iteration. Any type of sampling probabilities and cond
itions can be encoded inside the function. | | /// at every iteration. Any type of sampling probabilities and cond
itions can be encoded inside the function. | |
| /// The dimension of the returned sample is the dimension of the co
nfiguration space. | | /// The dimension of the returned sample is the dimension of the co
nfiguration space. | |
| /// success = samplegoalfn(newsample) | | /// success = samplegoalfn(newsample) | |
|
| typedef boost::function<bool(std::vector<dReal>&)> SampleGoalFn; | | typedef boost::function<bool (std::vector<dReal>&)> SampleGoalFn; | |
| SampleGoalFn _samplegoalfn; | | SampleGoalFn _samplegoalfn; | |
| | | | |
| /// \brief Samples a valid initial configuration (optional). | | /// \brief Samples a valid initial configuration (optional). | |
| /// | | /// | |
| /// If valid, the function should be called | | /// If valid, the function should be called | |
| /// at every iteration. Any type of sampling probabilities and cond
itions can be encoded inside the function. | | /// at every iteration. Any type of sampling probabilities and cond
itions can be encoded inside the function. | |
| /// The dimension of the returned sample is the dimension of the co
nfiguration space. | | /// The dimension of the returned sample is the dimension of the co
nfiguration space. | |
| /// success = sampleinitialfn(newsample) | | /// success = sampleinitialfn(newsample) | |
|
| typedef boost::function<bool(std::vector<dReal>&)> SampleInitialFn; | | typedef boost::function<bool (std::vector<dReal>&)> SampleInitialFn
; | |
| SampleInitialFn _sampleinitialfn; | | SampleInitialFn _sampleinitialfn; | |
| | | | |
| /** \brief Returns a random configuration around a neighborhood (op
tional). | | /** \brief Returns a random configuration around a neighborhood (op
tional). | |
| | | | |
| _sampleneighfn(newsample,pCurSample,fRadius) | | _sampleneighfn(newsample,pCurSample,fRadius) | |
| | | | |
| \param pCurSample - the neighborhood to sample around | | \param pCurSample - the neighborhood to sample around | |
| \param fRadius - specifies the max distance of sampling. The h
igher the value, the farther the samples will go | | \param fRadius - specifies the max distance of sampling. The h
igher the value, the farther the samples will go | |
| The distance metric can be arbitrary, but is
usually PlannerParameters::pdistmetric. | | The distance metric can be arbitrary, but is
usually PlannerParameters::pdistmetric. | |
| \return if sample was successfully generated return true, other
wise false | | \return if sample was successfully generated return true, other
wise false | |
|
| */ | | */ | |
| typedef boost::function<bool(std::vector<dReal>&, const std::vector | | typedef boost::function<bool (std::vector<dReal>&, const std::vecto | |
| <dReal>&, dReal)> SampleNeighFn; | | r<dReal>&, dReal)> SampleNeighFn; | |
| SampleNeighFn _sampleneighfn; | | SampleNeighFn _sampleneighfn; | |
| | | | |
| /// \brief Sets the state of the robot. Default is active robot joi
nts (mandatory). | | /// \brief Sets the state of the robot. Default is active robot joi
nts (mandatory). | |
|
| typedef boost::function<void(const std::vector<dReal>&)> SetStateFn
; | | typedef boost::function<void (const std::vector<dReal>&)> SetStateF
n; | |
| SetStateFn _setstatefn; | | SetStateFn _setstatefn; | |
| /// \brief Gets the state of the robot. Default is active robot joi
nts (mandatory). | | /// \brief Gets the state of the robot. Default is active robot joi
nts (mandatory). | |
|
| typedef boost::function<void(std::vector<dReal>&)> GetStateFn; | | typedef boost::function<void (std::vector<dReal>&)> GetStateFn; | |
| GetStateFn _getstatefn; | | GetStateFn _getstatefn; | |
| | | | |
| /** \brief Computes the difference of two states. | | /** \brief Computes the difference of two states. | |
| | | | |
| _diffstatefn(q1,q2) -> q1 -= q2 | | _diffstatefn(q1,q2) -> q1 -= q2 | |
| | | | |
| An explicit difference function is necessary for correct interp
olation when there are circular joints. | | An explicit difference function is necessary for correct interp
olation when there are circular joints. | |
| Default is regular subtraction. | | Default is regular subtraction. | |
|
| */ | | */ | |
| typedef boost::function<void(std::vector<dReal>&,const std::vector< | | typedef boost::function<void (std::vector<dReal>&,const std::vector | |
| dReal>&)> DiffStateFn; | | <dReal>&)> DiffStateFn; | |
| DiffStateFn _diffstatefn; | | DiffStateFn _diffstatefn; | |
| | | | |
| /** \brief Adds a delta state to a curent state, acting like a next
-nearest-neighbor function along a given direction. | | /** \brief Adds a delta state to a curent state, acting like a next
-nearest-neighbor function along a given direction. | |
| | | | |
| success = _neighstatefn(q,qdelta,fromgoal) -> q = Filter(q+qdel
ta) | | success = _neighstatefn(q,qdelta,fromgoal) -> q = Filter(q+qdel
ta) | |
| \param q the current state | | \param q the current state | |
| \param qdelta the delta to add | | \param qdelta the delta to add | |
| \param fromgoal 1 if q is coming from a goal state, 0 if it is
coming from an initial state | | \param fromgoal 1 if q is coming from a goal state, 0 if it is
coming from an initial state | |
| | | | |
| In RRTs this is used for the extension operation. The new state
is stored in the first parameter q. | | In RRTs this is used for the extension operation. The new state
is stored in the first parameter q. | |
| Note that the function can also add a filter to the final desti
nation (like projecting onto a constraint manifold). | | Note that the function can also add a filter to the final desti
nation (like projecting onto a constraint manifold). | |
|
| */ | | */ | |
| typedef boost::function<bool(std::vector<dReal>&,const std::vector< | | typedef boost::function<bool (std::vector<dReal>&,const std::vector | |
| dReal>&, int)> NeighStateFn; | | <dReal>&, int)> NeighStateFn; | |
| NeighStateFn _neighstatefn; | | NeighStateFn _neighstatefn; | |
| | | | |
| /// to specify multiple initial or goal configurations, put them in
to the vector in series | | /// to specify multiple initial or goal configurations, put them in
to the vector in series | |
| /// (note: not all planners support multiple goals) | | /// (note: not all planners support multiple goals) | |
| std::vector<dReal> vinitialconfig, vgoalconfig; | | std::vector<dReal> vinitialconfig, vgoalconfig; | |
| | | | |
| /// \brief the absolute limits of the configuration space. | | /// \brief the absolute limits of the configuration space. | |
| std::vector<dReal> _vConfigLowerLimit, _vConfigUpperLimit; | | std::vector<dReal> _vConfigLowerLimit, _vConfigUpperLimit; | |
| | | | |
| /// \brief the discretization resolution of each dimension of the c
onfiguration space | | /// \brief the discretization resolution of each dimension of the c
onfiguration space | |
| std::vector<dReal> _vConfigResolution; | | std::vector<dReal> _vConfigResolution; | |
| | | | |
| /** \brief a discretization between the path that connects two conf
igurations | | /** \brief a discretization between the path that connects two conf
igurations | |
| | | | |
| This length represents how dense the samples get distributed ac
ross the configuration space. | | This length represents how dense the samples get distributed ac
ross the configuration space. | |
| It represents the maximum distance between neighbors when addin
g new configuraitons. | | It represents the maximum distance between neighbors when addin
g new configuraitons. | |
| If 0 or less, planner chooses best step length. | | If 0 or less, planner chooses best step length. | |
|
| */ | | */ | |
| dReal _fStepLength; | | dReal _fStepLength; | |
| | | | |
| /// \brief maximum number of iterations before the planner gives up
. If 0 or less, planner chooses best iterations. | | /// \brief maximum number of iterations before the planner gives up
. If 0 or less, planner chooses best iterations. | |
| int _nMaxIterations; | | int _nMaxIterations; | |
| | | | |
| /// \brief Specifies the planner that will perform the post-process
ing path smoothing before returning. | | /// \brief Specifies the planner that will perform the post-process
ing path smoothing before returning. | |
| /// | | /// | |
| /// If empty, will not path smooth the returned trajectories (used
to measure algorithm time) | | /// If empty, will not path smooth the returned trajectories (used
to measure algorithm time) | |
| std::string _sPathOptimizationPlanner; | | std::string _sPathOptimizationPlanner; | |
| | | | |
| /// \brief The serialized planner parameters to pass to the path op
timizer. | | /// \brief The serialized planner parameters to pass to the path op
timizer. | |
| /// | | /// | |
| /// For example: std::stringstream(_sPathOptimizationParameters) >>
_parameters; | | /// For example: std::stringstream(_sPathOptimizationParameters) >>
_parameters; | |
| std::string _sPathOptimizationParameters; | | std::string _sPathOptimizationParameters; | |
| | | | |
| /// \brief Extra parameters data that does not fit within this plan
ner parameters structure, but is still important not to lose all the inform
ation. | | /// \brief Extra parameters data that does not fit within this plan
ner parameters structure, but is still important not to lose all the inform
ation. | |
| std::string _sExtraParameters; | | std::string _sExtraParameters; | |
| | | | |
| /// \brief Return the degrees of freedom of the planning configurat
ion space | | /// \brief Return the degrees of freedom of the planning configurat
ion space | |
|
| virtual int GetDOF() const { return (int)_vConfigLowerLimit.size(); | | virtual int GetDOF() const { | |
| } | | return (int)_vConfigLowerLimit.size(); | |
| | | } | |
| | | | |
|
| protected: | | protected: | |
| inline boost::shared_ptr<PlannerBase::PlannerParameters> shared_par | | inline boost::shared_ptr<PlannerBase::PlannerParameters> shared_par | |
| ameters() { return boost::static_pointer_cast<PlannerBase::PlannerParameter | | ameters() { | |
| s>(shared_from_this()); } | | return boost::static_pointer_cast<PlannerBase::PlannerParameter | |
| inline boost::shared_ptr<PlannerBase::PlannerParameters const > sha | | s>(shared_from_this()); | |
| red_parameters_const() const { return boost::static_pointer_cast<PlannerBas | | } | |
| e::PlannerParameters const>(shared_from_this()); } | | inline boost::shared_ptr<PlannerBase::PlannerParameters const > sha | |
| | | red_parameters_const() const { | |
| | | return boost::static_pointer_cast<PlannerBase::PlannerParameter | |
| | | s const>(shared_from_this()); | |
| | | } | |
| | | | |
| /// output the planner parameters in a string (in XML format) | | /// output the planner parameters in a string (in XML format) | |
| /// don't use PlannerParameters as a tag! | | /// don't use PlannerParameters as a tag! | |
| virtual bool serialize(std::ostream& O) const; | | virtual bool serialize(std::ostream& O) const; | |
| | | | |
| //@{ XML parsing functions, parses the default parameters | | //@{ XML parsing functions, parses the default parameters | |
| virtual ProcessElement startElement(const std::string& name, const
AttributesList& atts); | | virtual ProcessElement startElement(const std::string& name, const
AttributesList& atts); | |
| virtual bool endElement(const std::string& name); | | virtual bool endElement(const std::string& name); | |
| virtual void characters(const std::string& ch); | | virtual void characters(const std::string& ch); | |
|
| std::stringstream _ss; ///< holds the data read by characters | | std::stringstream _ss; ///< holds the data read by characte
rs | |
| boost::shared_ptr<std::stringstream> _sslocal; | | boost::shared_ptr<std::stringstream> _sslocal; | |
| /// all the top-level XML parameter tags (lower case) that are hand
led by this parameter structure, should be registered in the constructor | | /// all the top-level XML parameter tags (lower case) that are hand
led by this parameter structure, should be registered in the constructor | |
| std::vector<std::string> _vXMLParameters; | | std::vector<std::string> _vXMLParameters; | |
| //@} | | //@} | |
| | | | |
|
| private: | | private: | |
| /// disallow copy constructors since it gets complicated with virtu
alization | | /// disallow copy constructors since it gets complicated with virtu
alization | |
|
| PlannerParameters(const PlannerParameters& r) : XMLReadable("") { B | | PlannerParameters(const PlannerParameters &r) : XMLReadable("") { | |
| OOST_ASSERT(0); } | | BOOST_ASSERT(0); | |
| BaseXMLReaderPtr __pcurreader; ///< temporary reader | | } | |
| | | BaseXMLReaderPtr __pcurreader; ///< temporary reader | |
| std::string __processingtag; | | std::string __processingtag; | |
| int _plannerparametersdepth; | | int _plannerparametersdepth; | |
| | | | |
| /// outputs the data and surrounds it with \verbatim <PlannerParame
ters> \endverbatim tags | | /// outputs the data and surrounds it with \verbatim <PlannerParame
ters> \endverbatim tags | |
| friend OPENRAVE_API std::ostream& operator<<(std::ostream& O, const
PlannerParameters& v); | | friend OPENRAVE_API std::ostream& operator<<(std::ostream& O, const
PlannerParameters& v); | |
| /// expects \verbatim <PlannerParameters> \endverbatim to be the fi
rst token. Parses stream until \verbatim </PlannerParameters> \endverbatim
reached | | /// expects \verbatim <PlannerParameters> \endverbatim to be the fi
rst token. Parses stream until \verbatim </PlannerParameters> \endverbatim
reached | |
| friend OPENRAVE_API std::istream& operator>>(std::istream& I, Plann
erParameters& v); | | friend OPENRAVE_API std::istream& operator>>(std::istream& I, Plann
erParameters& v); | |
| }; | | }; | |
| typedef boost::shared_ptr<PlannerBase::PlannerParameters> PlannerParame
tersPtr; | | typedef boost::shared_ptr<PlannerBase::PlannerParameters> PlannerParame
tersPtr; | |
| typedef boost::shared_ptr<PlannerBase::PlannerParameters const> Planner
ParametersConstPtr; | | typedef boost::shared_ptr<PlannerBase::PlannerParameters const> Planner
ParametersConstPtr; | |
| typedef boost::weak_ptr<PlannerBase::PlannerParameters> PlannerParamete
rsWeakPtr; | | typedef boost::weak_ptr<PlannerBase::PlannerParameters> PlannerParamete
rsWeakPtr; | |
| | | | |
|
| PlannerBase(EnvironmentBasePtr penv) : InterfaceBase(PT_Planner, penv) | | PlannerBase(EnvironmentBasePtr penv) : InterfaceBase(PT_Planner, penv) | |
| {} | | { | |
| virtual ~PlannerBase() {} | | } | |
| | | virtual ~PlannerBase() { | |
| | | } | |
| | | | |
| /// \return the static interface type this class points to (used for sa
fe casting) | | /// \return the static interface type this class points to (used for sa
fe casting) | |
|
| static inline InterfaceType GetInterfaceTypeStatic() { return PT_Planne | | static inline InterfaceType GetInterfaceTypeStatic() { | |
| r; } | | return PT_Planner; | |
| | | } | |
| | | | |
| /// \brief Setup scene, robot, and properties of the plan, and reset al
l internal structures. | | /// \brief Setup scene, robot, and properties of the plan, and reset al
l internal structures. | |
| /// \param probot The robot will be planning for. | | /// \param probot The robot will be planning for. | |
| /// \param pparams The parameters of the planner, any class derived fro
m PlannerParameters can be passed. The planner should copy these parameters
for future instead of storing the pointer. | | /// \param pparams The parameters of the planner, any class derived fro
m PlannerParameters can be passed. The planner should copy these parameters
for future instead of storing the pointer. | |
| virtual bool InitPlan(RobotBasePtr probot, PlannerParametersConstPtr pp
arams) = 0; | | virtual bool InitPlan(RobotBasePtr probot, PlannerParametersConstPtr pp
arams) = 0; | |
| | | | |
| /** \brief Setup scene, robot, and properties of the plan, and reset al
l structures with pparams. | | /** \brief Setup scene, robot, and properties of the plan, and reset al
l structures with pparams. | |
| | | | |
| \param robot The robot will be planning for. Although the configura
tion space of the planner and the robot can be independent, | | \param robot The robot will be planning for. Although the configura
tion space of the planner and the robot can be independent, | |
| the planner uses the robot to check for environment and self-collis
ions. | | the planner uses the robot to check for environment and self-collis
ions. | |
| In order to speed up computations further, planners can use the CO_
ActiveDOFs collision checker option, which only focuses | | In order to speed up computations further, planners can use the CO_
ActiveDOFs collision checker option, which only focuses | |
| collision on the currently moving links in the robot. | | collision on the currently moving links in the robot. | |
| Even if the configuration space of the planner is different from th
e robot, the robot active DOFs must be set correctly (or at least have all
dofs active)! | | Even if the configuration space of the planner is different from th
e robot, the robot active DOFs must be set correctly (or at least have all
dofs active)! | |
| | | | |
| \param isParameters The serialized form of the parameters. By defau
lt, this exists to allow third parties to | | \param isParameters The serialized form of the parameters. By defau
lt, this exists to allow third parties to | |
| pass information to planners without excplicitly knowning the forma
t/internal structures used | | pass information to planners without excplicitly knowning the forma
t/internal structures used | |
| \return true if plan is initialized successfully and initial condit
ions are satisfied. | | \return true if plan is initialized successfully and initial condit
ions are satisfied. | |
|
| */ | | */ | |
| virtual bool InitPlan(RobotBasePtr robot, std::istream& isParameters); | | virtual bool InitPlan(RobotBasePtr robot, std::istream& isParameters); | |
| | | | |
| /** \brief Executes the main planner trying to solve for the goal condi
tion. | | /** \brief Executes the main planner trying to solve for the goal condi
tion. | |
| | | | |
| Fill ptraj with the trajectory of the planned path that the robot n
eeds to execute | | Fill ptraj with the trajectory of the planned path that the robot n
eeds to execute | |
| \param ptraj The output trajectory the robot has to follow in order
to successfully complete the plan. If this planner is a path optimizer, th
e trajectory can be used as an input for generating a smoother path. The tr
ajectory is for the configuration degrees of freedom defined by the planner
parameters. | | \param ptraj The output trajectory the robot has to follow in order
to successfully complete the plan. If this planner is a path optimizer, th
e trajectory can be used as an input for generating a smoother path. The tr
ajectory is for the configuration degrees of freedom defined by the planner
parameters. | |
| \param pOutStream If specified, planner will output any other speci
al data | | \param pOutStream If specified, planner will output any other speci
al data | |
| \return true if planner is successful | | \return true if planner is successful | |
|
| */ | | */ | |
| virtual bool PlanPath(TrajectoryBasePtr ptraj, boost::shared_ptr<std::o
stream> pOutStream = boost::shared_ptr<std::ostream>()) = 0; | | virtual bool PlanPath(TrajectoryBasePtr ptraj, boost::shared_ptr<std::o
stream> pOutStream = boost::shared_ptr<std::ostream>()) = 0; | |
| | | | |
| /// \brief return the internal parameters of the planner | | /// \brief return the internal parameters of the planner | |
| virtual PlannerParametersConstPtr GetParameters() const = 0; | | virtual PlannerParametersConstPtr GetParameters() const = 0; | |
| | | | |
| protected: | | protected: | |
| /** \brief Calls a planner to optimizes the trajectory path. | | /** \brief Calls a planner to optimizes the trajectory path. | |
| | | | |
| The PlannerParameters structure passed into the optimization planne
r is | | The PlannerParameters structure passed into the optimization planne
r is | |
| constructed with the same freespace constraints as this planner. | | constructed with the same freespace constraints as this planner. | |
| This function should always be called in PlanPath to post-process t
he trajectory. | | This function should always be called in PlanPath to post-process t
he trajectory. | |
| \param probot the robot this trajectory is meant for, also uses the
robot for checking collisions. | | \param probot the robot this trajectory is meant for, also uses the
robot for checking collisions. | |
| \param ptraj Initial trajectory to be smoothed is inputted. If opti
mization path succeeds, final trajectory output is set in this variable. Th
e trajectory is for the configuration degrees of freedom defined by the pla
nner parameters. | | \param ptraj Initial trajectory to be smoothed is inputted. If opti
mization path succeeds, final trajectory output is set in this variable. Th
e trajectory is for the configuration degrees of freedom defined by the pla
nner parameters. | |
|
| */ | | */ | |
| virtual bool _OptimizePath(RobotBasePtr probot, TrajectoryBasePtr ptraj
); | | virtual bool _OptimizePath(RobotBasePtr probot, TrajectoryBasePtr ptraj
); | |
| | | | |
| private: | | private: | |
|
| virtual const char* GetHash() const { return OPENRAVE_PLANNER_HASH; } | | virtual const char* GetHash() const { | |
| | | return OPENRAVE_PLANNER_HASH; | |
| | | } | |
| }; | | }; | |
| | | | |
| OPENRAVE_API std::ostream& operator<<(std::ostream& O, const PlannerBase::P
lannerParameters& v); | | OPENRAVE_API std::ostream& operator<<(std::ostream& O, const PlannerBase::P
lannerParameters& v); | |
| OPENRAVE_API std::istream& operator>>(std::istream& I, PlannerBase::Planner
Parameters& v); | | OPENRAVE_API std::istream& operator>>(std::istream& I, PlannerBase::Planner
Parameters& v); | |
| | | | |
| } // end namespace OpenRAVE | | } // end namespace OpenRAVE | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 26 change blocks. |
| 47 lines changed or deleted | | 59 lines changed or added | |
|
| robot.h | | robot.h | |
| | | | |
| skipping to change at line 28 | | skipping to change at line 28 | |
| \brief Base robot and manipulator description. | | \brief Base robot and manipulator description. | |
| */ | | */ | |
| | | | |
| #ifndef RAVE_ROBOT_H | | #ifndef RAVE_ROBOT_H | |
| #define RAVE_ROBOT_H | | #define RAVE_ROBOT_H | |
| | | | |
| namespace OpenRAVE { | | namespace OpenRAVE { | |
| | | | |
| /** \brief <b>[interface]</b> A robot is a kinematic body that has attached
manipulators, sensors, and controllers. <b>Methods not multi-thread safe.<
/b> See \ref arch_robot. | | /** \brief <b>[interface]</b> A robot is a kinematic body that has attached
manipulators, sensors, and controllers. <b>Methods not multi-thread safe.<
/b> See \ref arch_robot. | |
| \ingroup interfaces | | \ingroup interfaces | |
|
| */ | | */ | |
| class OPENRAVE_API RobotBase : public KinBody | | class OPENRAVE_API RobotBase : public KinBody | |
| { | | { | |
| public: | | public: | |
| /// \brief Defines a chain of joints for an arm and set of joints for a
gripper. Simplifies operating with them. | | /// \brief Defines a chain of joints for an arm and set of joints for a
gripper. Simplifies operating with them. | |
| class OPENRAVE_API Manipulator : public boost::enable_shared_from_this<
Manipulator> | | class OPENRAVE_API Manipulator : public boost::enable_shared_from_this<
Manipulator> | |
| { | | { | |
| Manipulator(RobotBasePtr probot); | | Manipulator(RobotBasePtr probot); | |
|
| Manipulator(const Manipulator& r); | | Manipulator(const Manipulator &r); | |
| Manipulator(RobotBasePtr probot, const Manipulator& r); | | Manipulator(RobotBasePtr probot, const Manipulator &r); | |
| | | | |
|
| public: | | public: | |
| virtual ~Manipulator(); | | virtual ~Manipulator(); | |
| | | | |
| /// \brief Return the transformation of the end effector (manipulat
or frame). | | /// \brief Return the transformation of the end effector (manipulat
or frame). | |
| /// | | /// | |
| /// All inverse kinematics and grasping queries are specifying this
frame. | | /// All inverse kinematics and grasping queries are specifying this
frame. | |
| virtual Transform GetTransform() const; | | virtual Transform GetTransform() const; | |
| | | | |
|
| virtual Transform GetEndEffectorTransform() const { return GetTrans | | virtual Transform GetEndEffectorTransform() const { | |
| form(); } | | return GetTransform(); | |
| | | } | |
| | | | |
|
| virtual const std::string& GetName() const { return _name; } | | virtual const std::string& GetName() const { | |
| virtual RobotBasePtr GetRobot() const { return RobotBasePtr(_probot | | return _name; | |
| ); } | | } | |
| | | virtual RobotBasePtr GetRobot() const { | |
| | | return RobotBasePtr(_probot); | |
| | | } | |
| | | | |
| /// \brief Sets the ik solver and initializes it with the current m
anipulator. | | /// \brief Sets the ik solver and initializes it with the current m
anipulator. | |
| /// | | /// | |
| /// Due to complications with translation,rotation,direction,and ra
y ik, | | /// Due to complications with translation,rotation,direction,and ra
y ik, | |
| /// the ik solver should take into account the grasp transform (_tG
rasp) internally. | | /// the ik solver should take into account the grasp transform (_tG
rasp) internally. | |
| /// The actual ik primitives are transformed into the base frame on
ly. | | /// The actual ik primitives are transformed into the base frame on
ly. | |
| virtual bool SetIkSolver(IkSolverBasePtr iksolver); | | virtual bool SetIkSolver(IkSolverBasePtr iksolver); | |
| | | | |
| /// \brief Returns the currently set ik solver | | /// \brief Returns the currently set ik solver | |
|
| virtual IkSolverBasePtr GetIkSolver() const { return _pIkSolver; } | | virtual IkSolverBasePtr GetIkSolver() const { | |
| | | return _pIkSolver; | |
| | | } | |
| | | | |
| /// \deprecated (11/02/08) use GetIkSolver()->GetNumFreeParameters(
) | | /// \deprecated (11/02/08) use GetIkSolver()->GetNumFreeParameters(
) | |
| virtual int GetNumFreeParameters() const RAVE_DEPRECATED; | | virtual int GetNumFreeParameters() const RAVE_DEPRECATED; | |
| | | | |
| /// \deprecated (11/02/08) use GetIkSolver()->GetFreeParameters() | | /// \deprecated (11/02/08) use GetIkSolver()->GetFreeParameters() | |
| virtual bool GetFreeParameters(std::vector<dReal>& vFreeParameters)
const RAVE_DEPRECATED; | | virtual bool GetFreeParameters(std::vector<dReal>& vFreeParameters)
const RAVE_DEPRECATED; | |
| | | | |
| /// \brief the base used for the iksolver | | /// \brief the base used for the iksolver | |
|
| virtual LinkPtr GetBase() const { return _pBase; } | | virtual LinkPtr GetBase() const { | |
| | | return _pBase; | |
| | | } | |
| | | | |
| /// \brief the end effector link (used to define workspace distance
) | | /// \brief the end effector link (used to define workspace distance
) | |
|
| virtual LinkPtr GetEndEffector() const { return _pEndEffector; } | | virtual LinkPtr GetEndEffector() const { | |
| | | return _pEndEffector; | |
| | | } | |
| | | | |
| /// \brief Return transform with respect to end effector defining t
he grasp coordinate system | | /// \brief Return transform with respect to end effector defining t
he grasp coordinate system | |
|
| virtual Transform GetGraspTransform() const { return _tGrasp; } | | virtual Transform GetGraspTransform() const { | |
| | | return _tGrasp; | |
| | | } | |
| | | | |
| /// \brief Gripper indices of the joints that the manipulator cont
rols. | | /// \brief Gripper indices of the joints that the manipulator cont
rols. | |
|
| virtual const std::vector<int>& GetGripperIndices() const { return | | virtual const std::vector<int>& GetGripperIndices() const { | |
| __vgripperdofindices; } | | return __vgripperdofindices; | |
| | | } | |
| | | | |
| /// \brief Return the indices of the DOFs of the arm (used for IK,
etc). | | /// \brief Return the indices of the DOFs of the arm (used for IK,
etc). | |
| /// | | /// | |
| /// Usually the DOF indices from pBase to pEndEffector | | /// Usually the DOF indices from pBase to pEndEffector | |
|
| virtual const std::vector<int>& GetArmIndices() const { return __va | | virtual const std::vector<int>& GetArmIndices() const { | |
| rmdofindices; } | | return __varmdofindices; | |
| | | } | |
| | | | |
| /// \brief return the normal direction to move joints to 'close' th
e hand | | /// \brief return the normal direction to move joints to 'close' th
e hand | |
|
| virtual const std::vector<dReal>& GetClosingDirection() const { ret | | virtual const std::vector<dReal>& GetClosingDirection() const { | |
| urn _vClosingDirection; } | | return _vClosingDirection; | |
| | | } | |
| | | | |
| /// \brief direction of palm/head/manipulator used for approaching.
defined inside the manipulator/grasp coordinate system | | /// \brief direction of palm/head/manipulator used for approaching.
defined inside the manipulator/grasp coordinate system | |
|
| virtual Vector GetDirection() const { return _vdirection; } | | virtual Vector GetDirection() const { | |
| | | return _vdirection; | |
| | | } | |
| | | | |
| /// \brief Find a close solution to the current robot's joint value
s. | | /// \brief Find a close solution to the current robot's joint value
s. | |
| /// | | /// | |
| /// The function is a wrapper around the IkSolver interface. | | /// The function is a wrapper around the IkSolver interface. | |
| /// Note that the solution returned is not guaranteed to be the clo
sest solution. In order to compute that, will have to | | /// Note that the solution returned is not guaranteed to be the clo
sest solution. In order to compute that, will have to | |
| /// compute all the ik solutions using FindIKSolutions. | | /// compute all the ik solutions using FindIKSolutions. | |
| /// \param param The transformation of the end-effector in the glob
al coord system | | /// \param param The transformation of the end-effector in the glob
al coord system | |
| /// \param solution Will be of size GetArmIndices().size() and cont
ain the best solution | | /// \param solution Will be of size GetArmIndices().size() and cont
ain the best solution | |
| /// \param[in] filteroptions A bitmask of \ref IkFilterOptions valu
es controlling what is checked for each ik solution. | | /// \param[in] filteroptions A bitmask of \ref IkFilterOptions valu
es controlling what is checked for each ik solution. | |
| virtual bool FindIKSolution(const IkParameterization& param, std::v
ector<dReal>& solution, int filteroptions) const; | | virtual bool FindIKSolution(const IkParameterization& param, std::v
ector<dReal>& solution, int filteroptions) const; | |
| | | | |
| skipping to change at line 125 | | skipping to change at line 147 | |
| ikparam = manip->GetIkParameterization(iktype); | | ikparam = manip->GetIkParameterization(iktype); | |
| ... move robot | | ... move robot | |
| std::vector<dReal> sol; | | std::vector<dReal> sol; | |
| if( FindIKSolution(ikparam,sol, filteroptions) ) { | | if( FindIKSolution(ikparam,sol, filteroptions) ) { | |
| manip->GetRobot()->SetActiveDOFs(manip->GetArmIndices()); | | manip->GetRobot()->SetActiveDOFs(manip->GetArmIndices()); | |
| manip->GetRobot()->SetActiveDOFValues(sol); | | manip->GetRobot()->SetActiveDOFValues(sol); | |
| BOOST_ASSERT( dist(manip->GetIkParameterization(iktype), ik
param) <= epsilon ); | | BOOST_ASSERT( dist(manip->GetIkParameterization(iktype), ik
param) <= epsilon ); | |
| } | | } | |
| \endcode | | \endcode | |
| \param iktype the type of parameterization to request | | \param iktype the type of parameterization to request | |
|
| */ | | */ | |
| virtual IkParameterization GetIkParameterization(IkParameterization
::Type iktype) const; | | virtual IkParameterization GetIkParameterization(IkParameterization
::Type iktype) const; | |
| | | | |
| /** \brief returns a full parameterization of a given IK type for t
he current manipulator position using an existing IkParameterization as the
seed. | | /** \brief returns a full parameterization of a given IK type for t
he current manipulator position using an existing IkParameterization as the
seed. | |
| | | | |
| Ideally pluging the returned ik parameterization into FindIkSol
ution should return the a manipulator configuration | | Ideally pluging the returned ik parameterization into FindIkSol
ution should return the a manipulator configuration | |
| such that a new call to GetIkParameterization returns the same
values. | | such that a new call to GetIkParameterization returns the same
values. | |
| \param ikparam Some IK types like Lookat3D and TranslationLocal
Global6D set constraints in the global coordinate system of the manipulator
. Because these values are not stored in manipulator itself, they have to b
e passed in through an existing IkParameterization. | | \param ikparam Some IK types like Lookat3D and TranslationLocal
Global6D set constraints in the global coordinate system of the manipulator
. Because these values are not stored in manipulator itself, they have to b
e passed in through an existing IkParameterization. | |
|
| */ | | */ | |
| virtual IkParameterization GetIkParameterization(const IkParameteri
zation& ikparam) const; | | virtual IkParameterization GetIkParameterization(const IkParameteri
zation& ikparam) const; | |
| | | | |
| /// \brief Get all child joints of the manipulator starting at the
pEndEffector link | | /// \brief Get all child joints of the manipulator starting at the
pEndEffector link | |
| virtual void GetChildJoints(std::vector<JointPtr>& vjoints) const; | | virtual void GetChildJoints(std::vector<JointPtr>& vjoints) const; | |
| | | | |
| /// \brief Get all child DOF indices of the manipulator starting at
the pEndEffector link | | /// \brief Get all child DOF indices of the manipulator starting at
the pEndEffector link | |
| virtual void GetChildDOFIndices(std::vector<int>& vdofndices) const
; | | virtual void GetChildDOFIndices(std::vector<int>& vdofndices) const
; | |
| | | | |
| /// \brief returns true if a link is part of the child links of the
manipulator. | | /// \brief returns true if a link is part of the child links of the
manipulator. | |
| /// | | /// | |
| | | | |
| skipping to change at line 163 | | skipping to change at line 185 | |
| /// | | /// | |
| /// conditioned that the base and end effector links are static. | | /// conditioned that the base and end effector links are static. | |
| /// In other words, returns all links not on the path from the base
to the end effector and not children of the end effector. | | /// In other words, returns all links not on the path from the base
to the end effector and not children of the end effector. | |
| virtual void GetIndependentLinks(std::vector<LinkPtr>& vlinks) cons
t; | | virtual void GetIndependentLinks(std::vector<LinkPtr>& vlinks) cons
t; | |
| | | | |
| /** \brief Checks collision with only the gripper given its end-eff
ector transform. Ignores disabled links. | | /** \brief Checks collision with only the gripper given its end-eff
ector transform. Ignores disabled links. | |
| | | | |
| \param tEE the end effector transform | | \param tEE the end effector transform | |
| \param[out] report [optional] collision report | | \param[out] report [optional] collision report | |
| \return true if a collision occurred | | \return true if a collision occurred | |
|
| */ | | */ | |
| virtual bool CheckEndEffectorCollision(const Transform& tEE, Collis
ionReportPtr report = CollisionReportPtr()) const; | | virtual bool CheckEndEffectorCollision(const Transform& tEE, Collis
ionReportPtr report = CollisionReportPtr()) const; | |
| | | | |
| /** \brief Checks collision with the environment with all the indep
endent links of the robot. Ignores disabled links. | | /** \brief Checks collision with the environment with all the indep
endent links of the robot. Ignores disabled links. | |
| | | | |
| \param[out] report [optional] collision report | | \param[out] report [optional] collision report | |
| \return true if a collision occurred | | \return true if a collision occurred | |
|
| */ | | */ | |
| virtual bool CheckIndependentCollision(CollisionReportPtr report =
CollisionReportPtr()) const; | | virtual bool CheckIndependentCollision(CollisionReportPtr report =
CollisionReportPtr()) const; | |
| | | | |
| /// \brief return true if the body is being grabbed by any link on
this manipulator | | /// \brief return true if the body is being grabbed by any link on
this manipulator | |
| virtual bool IsGrabbing(KinBodyConstPtr body) const; | | virtual bool IsGrabbing(KinBodyConstPtr body) const; | |
| | | | |
| /// \brief computes the jacobian of the manipulator arm indices fro
m the current manipulator frame origin. | | /// \brief computes the jacobian of the manipulator arm indices fro
m the current manipulator frame origin. | |
| virtual void CalculateJacobian(boost::multi_array<dReal,2>& mjacobi
an) const; | | virtual void CalculateJacobian(boost::multi_array<dReal,2>& mjacobi
an) const; | |
| | | | |
| /// \brief computes the quaternion jacobian of the manipulator arm
indices from the current manipulator frame rotation. | | /// \brief computes the quaternion jacobian of the manipulator arm
indices from the current manipulator frame rotation. | |
| virtual void CalculateRotationJacobian(boost::multi_array<dReal,2>&
mjacobian) const; | | virtual void CalculateRotationJacobian(boost::multi_array<dReal,2>&
mjacobian) const; | |
| | | | |
| skipping to change at line 194 | | skipping to change at line 216 | |
| | | | |
| virtual void serialize(std::ostream& o, int options) const; | | virtual void serialize(std::ostream& o, int options) const; | |
| | | | |
| /// \brief Return hash of just the manipulator definition. | | /// \brief Return hash of just the manipulator definition. | |
| virtual const std::string& GetStructureHash() const; | | virtual const std::string& GetStructureHash() const; | |
| | | | |
| /// \brief Return hash of all kinematics information that involves
solving the inverse kinematics equations. | | /// \brief Return hash of all kinematics information that involves
solving the inverse kinematics equations. | |
| /// | | /// | |
| /// This includes joint axes, joint positions, and final grasp tran
sform. Hash is used to cache the solvers. | | /// This includes joint axes, joint positions, and final grasp tran
sform. Hash is used to cache the solvers. | |
| virtual const std::string& GetKinematicsStructureHash() const; | | virtual const std::string& GetKinematicsStructureHash() const; | |
|
| protected: | | protected: | |
| std::string _name; | | std::string _name; | |
| LinkPtr _pBase, _pEndEffector; | | LinkPtr _pBase, _pEndEffector; | |
| Transform _tGrasp; | | Transform _tGrasp; | |
| std::vector<dReal> _vClosingDirection; | | std::vector<dReal> _vClosingDirection; | |
| Vector _vdirection; | | Vector _vdirection; | |
| IkSolverBasePtr _pIkSolver; | | IkSolverBasePtr _pIkSolver; | |
| std::string _strIkSolver; | | std::string _strIkSolver; | |
|
| std::vector<std::string> _vgripperjointnames; ///< names of the gri
pper joints | | std::vector<std::string> _vgripperjointnames; ///< names of
the gripper joints | |
| | | | |
|
| private: | | private: | |
| RobotBaseWeakPtr _probot; | | RobotBaseWeakPtr _probot; | |
| std::vector<int> __vgripperdofindices, __varmdofindices; | | std::vector<int> __vgripperdofindices, __varmdofindices; | |
| mutable std::string __hashstructure, __hashkinematicsstructure; | | mutable std::string __hashstructure, __hashkinematicsstructure; | |
| | | | |
| #ifdef RAVE_PRIVATE | | #ifdef RAVE_PRIVATE | |
| #ifdef _MSC_VER | | #ifdef _MSC_VER | |
| friend class ColladaReader; | | friend class ColladaReader; | |
| friend class OpenRAVEXMLParser::ManipulatorXMLReader; | | friend class OpenRAVEXMLParser::ManipulatorXMLReader; | |
| friend class OpenRAVEXMLParser::RobotXMLReader; | | friend class OpenRAVEXMLParser::RobotXMLReader; | |
| #else | | #else | |
| | | | |
| skipping to change at line 229 | | skipping to change at line 251 | |
| #endif | | #endif | |
| friend class RobotBase; | | friend class RobotBase; | |
| }; | | }; | |
| typedef boost::shared_ptr<RobotBase::Manipulator> ManipulatorPtr; | | typedef boost::shared_ptr<RobotBase::Manipulator> ManipulatorPtr; | |
| typedef boost::shared_ptr<RobotBase::Manipulator const> ManipulatorCons
tPtr; | | typedef boost::shared_ptr<RobotBase::Manipulator const> ManipulatorCons
tPtr; | |
| typedef boost::weak_ptr<RobotBase::Manipulator> ManipulatorWeakPtr; | | typedef boost::weak_ptr<RobotBase::Manipulator> ManipulatorWeakPtr; | |
| | | | |
| /// \brief Attaches a sensor to a link on the robot. | | /// \brief Attaches a sensor to a link on the robot. | |
| class OPENRAVE_API AttachedSensor : public boost::enable_shared_from_th
is<AttachedSensor> | | class OPENRAVE_API AttachedSensor : public boost::enable_shared_from_th
is<AttachedSensor> | |
| { | | { | |
|
| public: | | public: | |
| AttachedSensor(RobotBasePtr probot); | | AttachedSensor(RobotBasePtr probot); | |
|
| AttachedSensor(RobotBasePtr probot, const AttachedSensor& sensor, i
nt cloningoptions); | | AttachedSensor(RobotBasePtr probot, const AttachedSensor &sensor, i
nt cloningoptions); | |
| virtual ~AttachedSensor(); | | virtual ~AttachedSensor(); | |
| | | | |
|
| virtual SensorBasePtr GetSensor() const { return psensor; } | | virtual SensorBasePtr GetSensor() const { | |
| virtual LinkPtr GetAttachingLink() const { return LinkPtr(pattached | | return psensor; | |
| link); } | | } | |
| virtual Transform GetRelativeTransform() const { return trelative; | | virtual LinkPtr GetAttachingLink() const { | |
| } | | return LinkPtr(pattachedlink); | |
| virtual Transform GetTransform() const { return LinkPtr(pattachedli | | } | |
| nk)->GetTransform()*trelative; } | | virtual Transform GetRelativeTransform() const { | |
| virtual RobotBasePtr GetRobot() const { return RobotBasePtr(_probot | | return trelative; | |
| ); } | | } | |
| virtual const std::string& GetName() const { return _name; } | | virtual Transform GetTransform() const { | |
| | | return LinkPtr(pattachedlink)->GetTransform()*trelative; | |
| | | } | |
| | | virtual RobotBasePtr GetRobot() const { | |
| | | return RobotBasePtr(_probot); | |
| | | } | |
| | | virtual const std::string& GetName() const { | |
| | | return _name; | |
| | | } | |
| | | | |
| /// retrieves the current data from the sensor | | /// retrieves the current data from the sensor | |
| virtual SensorBase::SensorDataPtr GetData() const; | | virtual SensorBase::SensorDataPtr GetData() const; | |
| | | | |
| virtual void SetRelativeTransform(const Transform& t); | | virtual void SetRelativeTransform(const Transform& t); | |
| | | | |
| virtual void serialize(std::ostream& o, int options) const; | | virtual void serialize(std::ostream& o, int options) const; | |
| | | | |
| /// \return hash of the sensor definition | | /// \return hash of the sensor definition | |
| virtual const std::string& GetStructureHash() const; | | virtual const std::string& GetStructureHash() const; | |
|
| private: | | private: | |
| RobotBaseWeakPtr _probot; | | RobotBaseWeakPtr _probot; | |
| SensorBasePtr psensor; | | SensorBasePtr psensor; | |
|
| LinkWeakPtr pattachedlink; ///< the robot link that the sensor is a | | LinkWeakPtr pattachedlink; ///< the robot link that the sen | |
| ttached to | | sor is attached to | |
| Transform trelative; ///< relative transform of the sensor with res | | Transform trelative; ///< relative transform of the sensor | |
| pect to the attached link | | with respect to the attached link | |
| SensorBase::SensorDataPtr pdata; ///< pointer to a preallocated dat | | SensorBase::SensorDataPtr pdata; ///< pointer to a prealloc | |
| a using psensor->CreateSensorData() | | ated data using psensor->CreateSensorData() | |
| std::string _name; ///< name of the attached sensor | | std::string _name; ///< name of the attached sensor | |
| mutable std::string __hashstructure; | | mutable std::string __hashstructure; | |
| #ifdef RAVE_PRIVATE | | #ifdef RAVE_PRIVATE | |
| #ifdef _MSC_VER | | #ifdef _MSC_VER | |
| friend class ColladaReader; | | friend class ColladaReader; | |
| friend class OpenRAVEXMLParser::AttachedSensorXMLReader; | | friend class OpenRAVEXMLParser::AttachedSensorXMLReader; | |
| friend class OpenRAVEXMLParser::RobotXMLReader; | | friend class OpenRAVEXMLParser::RobotXMLReader; | |
| #else | | #else | |
| friend class ::ColladaReader; | | friend class ::ColladaReader; | |
| friend class ::OpenRAVEXMLParser::AttachedSensorXMLReader; | | friend class ::OpenRAVEXMLParser::AttachedSensorXMLReader; | |
| friend class ::OpenRAVEXMLParser::RobotXMLReader; | | friend class ::OpenRAVEXMLParser::RobotXMLReader; | |
| #endif | | #endif | |
| #endif | | #endif | |
| friend class RobotBase; | | friend class RobotBase; | |
| }; | | }; | |
| typedef boost::shared_ptr<RobotBase::AttachedSensor> AttachedSensorPtr; | | typedef boost::shared_ptr<RobotBase::AttachedSensor> AttachedSensorPtr; | |
| typedef boost::shared_ptr<RobotBase::AttachedSensor const> AttachedSens
orConstPtr; | | typedef boost::shared_ptr<RobotBase::AttachedSensor const> AttachedSens
orConstPtr; | |
| | | | |
| /// \brief The information of a currently grabbed body. | | /// \brief The information of a currently grabbed body. | |
| class OPENRAVE_API Grabbed | | class OPENRAVE_API Grabbed | |
| { | | { | |
|
| public: | | public: | |
| KinBodyWeakPtr pbody; ///< the grabbed body | | KinBodyWeakPtr pbody; ///< the grabbed body | |
| LinkPtr plinkrobot; ///< robot link that is grabbing the body | | LinkPtr plinkrobot; ///< robot link that is grabbing the bo | |
| std::vector<LinkConstPtr> vCollidingLinks, vNonCollidingLinks; ///< | | dy | |
| robot links that already collide with the body | | std::vector<LinkConstPtr> vCollidingLinks, vNonCollidingLinks; | |
| Transform troot; ///< root transform (of first link of body) relati | | ///< robot links that already collide with the body | |
| ve to plinkrobot's transform. In other words, pbody->GetTransform() == plin | | Transform troot; ///< root transform (of first link of body | |
| krobot->GetTransform()*troot | | ) relative to plinkrobot's transform. In other words, pbody->GetTransform() | |
| | | == plinkrobot->GetTransform()*troot | |
| }; | | }; | |
| | | | |
| /// \brief Helper class derived from KinBodyStateSaver to additionaly s
ave robot information. | | /// \brief Helper class derived from KinBodyStateSaver to additionaly s
ave robot information. | |
| class OPENRAVE_API RobotStateSaver : public KinBodyStateSaver | | class OPENRAVE_API RobotStateSaver : public KinBodyStateSaver | |
| { | | { | |
|
| public: | | public: | |
| RobotStateSaver(RobotBasePtr probot, int options = Save_LinkTransfo
rmation|Save_LinkEnable|Save_ActiveDOF|Save_ActiveManipulator); | | RobotStateSaver(RobotBasePtr probot, int options = Save_LinkTransfo
rmation|Save_LinkEnable|Save_ActiveDOF|Save_ActiveManipulator); | |
| virtual ~RobotStateSaver(); | | virtual ~RobotStateSaver(); | |
|
| protected: | | protected: | |
| RobotBasePtr _probot; | | RobotBasePtr _probot; | |
| std::vector<int> vactivedofs; | | std::vector<int> vactivedofs; | |
| int affinedofs; | | int affinedofs; | |
| Vector rotationaxis; | | Vector rotationaxis; | |
| int nActiveManip; | | int nActiveManip; | |
| std::vector<Grabbed> _vGrabbedBodies; | | std::vector<Grabbed> _vGrabbedBodies; | |
| }; | | }; | |
| | | | |
| virtual ~RobotBase(); | | virtual ~RobotBase(); | |
| | | | |
| /// \brief Return the static interface type this class points to (used
for safe casting). | | /// \brief Return the static interface type this class points to (used
for safe casting). | |
|
| static inline InterfaceType GetInterfaceTypeStatic() { return PT_Robot; | | static inline InterfaceType GetInterfaceTypeStatic() { | |
| } | | return PT_Robot; | |
| | | } | |
| | | | |
| virtual void Destroy(); | | virtual void Destroy(); | |
| | | | |
| /// \deprecated (11/02/18) \see EnvironmentBase::ReadRobotXMLFile | | /// \deprecated (11/02/18) \see EnvironmentBase::ReadRobotXMLFile | |
| virtual bool InitFromFile(const std::string& filename, const Attributes
List& atts = AttributesList()) RAVE_DEPRECATED; | | virtual bool InitFromFile(const std::string& filename, const Attributes
List& atts = AttributesList()) RAVE_DEPRECATED; | |
| /// \deprecated (11/02/18) \see EnvironmentBase::ReadRobotXMLData | | /// \deprecated (11/02/18) \see EnvironmentBase::ReadRobotXMLData | |
| virtual bool InitFromData(const std::string& data, const AttributesList
& atts = AttributesList()) RAVE_DEPRECATED; | | virtual bool InitFromData(const std::string& data, const AttributesList
& atts = AttributesList()) RAVE_DEPRECATED; | |
| | | | |
| /// \brief Returns the manipulators of the robot | | /// \brief Returns the manipulators of the robot | |
|
| virtual std::vector<ManipulatorPtr>& GetManipulators() { return _vecMan | | virtual std::vector<ManipulatorPtr>& GetManipulators() { | |
| ipulators; } | | return _vecManipulators; | |
| virtual bool SetMotion(TrajectoryBaseConstPtr ptraj) { return false; } | | } | |
| | | virtual bool SetMotion(TrajectoryBaseConstPtr ptraj) { | |
| | | return false; | |
| | | } | |
| | | | |
|
| virtual std::vector<AttachedSensorPtr>& GetAttachedSensors() { return _ | | virtual std::vector<AttachedSensorPtr>& GetAttachedSensors() { | |
| vecSensors; } | | return _vecSensors; | |
| | | } | |
| | | | |
| virtual void SetDOFValues(const std::vector<dReal>& vJointValues, bool
bCheckLimits = false); | | virtual void SetDOFValues(const std::vector<dReal>& vJointValues, bool
bCheckLimits = false); | |
| virtual void SetDOFValues(const std::vector<dReal>& vJointValues, const
Transform& transbase, bool bCheckLimits = false); | | virtual void SetDOFValues(const std::vector<dReal>& vJointValues, const
Transform& transbase, bool bCheckLimits = false); | |
| | | | |
| virtual void SetLinkTransformations(const std::vector<Transform>& vbodi
es); | | virtual void SetLinkTransformations(const std::vector<Transform>& vbodi
es); | |
| | | | |
| /// Transforms the robot and updates the attached sensors and grabbed b
odies. | | /// Transforms the robot and updates the attached sensors and grabbed b
odies. | |
| virtual void SetTransform(const Transform& trans); | | virtual void SetTransform(const Transform& trans); | |
| | | | |
| /** Methods using the active degrees of freedoms of the robot. Active D
OFs are a way for the | | /** Methods using the active degrees of freedoms of the robot. Active D
OFs are a way for the | |
| user to specify degrees of freedom of interest for a current execut
ion block. All planners | | user to specify degrees of freedom of interest for a current execut
ion block. All planners | |
| by default use the robot's active DOF and active manipultor. For ev
ery Get* method, there is | | by default use the robot's active DOF and active manipultor. For ev
ery Get* method, there is | |
| a corresponding GetActive* method rather than the methods when sett
ing joints. The active | | a corresponding GetActive* method rather than the methods when sett
ing joints. The active | |
| DOFs also include affine transfomrations of the robot's base. Affin
e transformation DOFs can | | DOFs also include affine transfomrations of the robot's base. Affin
e transformation DOFs can | |
| be found after the joint DOFs in this order: X, Y, Z, Rotation wher
e rotation can be around | | be found after the joint DOFs in this order: X, Y, Z, Rotation wher
e rotation can be around | |
| a specified axis a full 3D rotation. Usually the affine transforam
tion is with respect to | | a specified axis a full 3D rotation. Usually the affine transforam
tion is with respect to | |
| the first link in the body | | the first link in the body | |
| @name Affine DOFs | | @name Affine DOFs | |
| @{ | | @{ | |
|
| */ | | */ | |
| /// \brief Selects which DOFs of the affine transformation to include i
n the active configuration. | | /// \brief Selects which DOFs of the affine transformation to include i
n the active configuration. | |
| enum DOFAffine | | enum DOFAffine | |
| { | | { | |
| DOF_NoTransform = 0, | | DOF_NoTransform = 0, | |
|
| DOF_X = 1, ///< robot can move in the x direction | | DOF_X = 1, ///< robot can move in the x direction | |
| DOF_Y = 2, ///< robot can move in the y direction | | DOF_Y = 2, ///< robot can move in the y direction | |
| DOF_Z = 4, ///< robot can move in the z direction | | DOF_Z = 4, ///< robot can move in the z direction | |
| | | | |
| // DOF_RotationX fields are mutually exclusive | | // DOF_RotationX fields are mutually exclusive | |
|
| DOF_RotationAxis = 8, ///< robot can rotate around an axis (1 dof) | | DOF_RotationAxis = 8, ///< robot can rotate around an axis (1 d | |
| DOF_Rotation3D = 16, ///< robot can rotate freely (3 dof), the para | | of) | |
| meterization is | | DOF_Rotation3D = 16, ///< robot can rotate freely (3 dof), the | |
| ///< theta * v, where v is the rotation axis a | | parameterization is | |
| nd theta is the angle about that axis | | ///< theta * v, where v is the rotation ax | |
| DOF_RotationQuat = 32, ///< robot can rotate freely (4 dof), parame | | is and theta is the angle about that axis | |
| terization is a quaternion. In order for limits to work correctly, the quat | | DOF_RotationQuat = 32, ///< robot can rotate freely (4 dof), pa | |
| ernion is in the space of _vRotationQuatLimitStart. _vRotationQuatLimitStar | | rameterization is a quaternion. In order for limits to work correctly, the | |
| t is always left-multiplied before setting the transform! | | quaternion is in the space of _vRotationQuatLimitStart. _vRotationQuatLimit | |
| | | Start is always left-multiplied before setting the transform! | |
| }; | | }; | |
| | | | |
| /** \brief Set the joint indices and affine transformation dofs that th
e planner should use. If \ref DOF_RotationAxis is specified, the previously
set axis is used. | | /** \brief Set the joint indices and affine transformation dofs that th
e planner should use. If \ref DOF_RotationAxis is specified, the previously
set axis is used. | |
| | | | |
| \param dofindices the indices of the original degrees of freedom to
use. | | \param dofindices the indices of the original degrees of freedom to
use. | |
| \param affine A bitmask of \ref DOFAffine values | | \param affine A bitmask of \ref DOFAffine values | |
|
| */ | | */ | |
| virtual void SetActiveDOFs(const std::vector<int>& dofindices, int affi
ne = DOF_NoTransform); | | virtual void SetActiveDOFs(const std::vector<int>& dofindices, int affi
ne = DOF_NoTransform); | |
| | | | |
| /** \brief Set the joint indices and affine transformation dofs that th
e planner should use. If \ref DOF_RotationAxis is specified, then rotationa
xis is set as the new axis. | | /** \brief Set the joint indices and affine transformation dofs that th
e planner should use. If \ref DOF_RotationAxis is specified, then rotationa
xis is set as the new axis. | |
| | | | |
| \param dofindices the indices of the original degrees of freedom to
use. | | \param dofindices the indices of the original degrees of freedom to
use. | |
| \param affine A bitmask of \ref DOFAffine values | | \param affine A bitmask of \ref DOFAffine values | |
| \param rotationaxis if \ref DOF_RotationAxis is specified, pRotatio
nAxis is used as the new axis | | \param rotationaxis if \ref DOF_RotationAxis is specified, pRotatio
nAxis is used as the new axis | |
|
| */ | | */ | |
| virtual void SetActiveDOFs(const std::vector<int>& dofindices, int affi
ne, const Vector& rotationaxis); | | virtual void SetActiveDOFs(const std::vector<int>& dofindices, int affi
ne, const Vector& rotationaxis); | |
|
| virtual int GetActiveDOF() const { return _nActiveDOF >= 0 ? _nActiveDO | | virtual int GetActiveDOF() const { | |
| F : GetDOF(); } | | return _nActiveDOF >= 0 ? _nActiveDOF : GetDOF(); | |
| virtual int GetAffineDOF() const { return _nAffineDOFs; } | | } | |
| | | virtual int GetAffineDOF() const { | |
| | | return _nAffineDOFs; | |
| | | } | |
| | | | |
| /// \brief If dof is set in the affine dofs, returns its index in the d
of values array, otherwise returns -1 | | /// \brief If dof is set in the affine dofs, returns its index in the d
of values array, otherwise returns -1 | |
| virtual int GetAffineDOFIndex(DOFAffine dof) const; | | virtual int GetAffineDOFIndex(DOFAffine dof) const; | |
| | | | |
| /// \brief Return the set of active dof indices of the joints. | | /// \brief Return the set of active dof indices of the joints. | |
| virtual const std::vector<int>& GetActiveDOFIndices() const; | | virtual const std::vector<int>& GetActiveDOFIndices() const; | |
| | | | |
|
| virtual Vector GetAffineRotationAxis() const { return vActvAffineRotati | | virtual Vector GetAffineRotationAxis() const { | |
| onAxis; } | | return vActvAffineRotationAxis; | |
| | | } | |
| virtual void SetAffineTranslationLimits(const Vector& lower, const Vect
or& upper); | | virtual void SetAffineTranslationLimits(const Vector& lower, const Vect
or& upper); | |
| virtual void SetAffineRotationAxisLimits(const Vector& lower, const Vec
tor& upper); | | virtual void SetAffineRotationAxisLimits(const Vector& lower, const Vec
tor& upper); | |
| virtual void SetAffineRotation3DLimits(const Vector& lower, const Vecto
r& upper); | | virtual void SetAffineRotation3DLimits(const Vector& lower, const Vecto
r& upper); | |
| | | | |
| /// \brief sets the quaternion limits using a starting rotation and the
max angle deviation from it. | | /// \brief sets the quaternion limits using a starting rotation and the
max angle deviation from it. | |
| /// | | /// | |
| /// \param quatangle quaternion_start * max_angle. acos(q dot quaternio
n_start) <= max_angle. | | /// \param quatangle quaternion_start * max_angle. acos(q dot quaternio
n_start) <= max_angle. | |
| /// If max_angle is 0, then will take the current transform of the robo
t | | /// If max_angle is 0, then will take the current transform of the robo
t | |
| virtual void SetAffineRotationQuatLimits(const Vector& quatangle); | | virtual void SetAffineRotationQuatLimits(const Vector& quatangle); | |
| virtual void SetAffineTranslationMaxVels(const Vector& vels); | | virtual void SetAffineTranslationMaxVels(const Vector& vels); | |
| | | | |
| skipping to change at line 404 | | skipping to change at line 452 | |
| virtual void SetAffineRotation3DWeights(const Vector& weights); | | virtual void SetAffineRotation3DWeights(const Vector& weights); | |
| virtual void SetAffineRotationQuatWeights(dReal weights); | | virtual void SetAffineRotationQuatWeights(dReal weights); | |
| | | | |
| virtual void GetAffineTranslationLimits(Vector& lower, Vector& upper) c
onst; | | virtual void GetAffineTranslationLimits(Vector& lower, Vector& upper) c
onst; | |
| virtual void GetAffineRotationAxisLimits(Vector& lower, Vector& upper)
const; | | virtual void GetAffineRotationAxisLimits(Vector& lower, Vector& upper)
const; | |
| virtual void GetAffineRotation3DLimits(Vector& lower, Vector& upper) co
nst; | | virtual void GetAffineRotation3DLimits(Vector& lower, Vector& upper) co
nst; | |
| | | | |
| /// \brief gets the quaternion limits | | /// \brief gets the quaternion limits | |
| /// | | /// | |
| /// \param quatangle quaternion_start * max_angle. acos(q dot quaternio
n_start) <= max_angle | | /// \param quatangle quaternion_start * max_angle. acos(q dot quaternio
n_start) <= max_angle | |
|
| virtual Vector GetAffineRotationQuatLimits() const { return _vRotationQ | | virtual Vector GetAffineRotationQuatLimits() const { | |
| uatLimitStart * _fQuatLimitMaxAngle; } | | return _vRotationQuatLimitStart * _fQuatLimitMaxAngle; | |
| virtual Vector GetAffineTranslationMaxVels() const { return _vTranslati | | } | |
| onMaxVels; } | | virtual Vector GetAffineTranslationMaxVels() const { | |
| virtual Vector GetAffineRotationAxisMaxVels() const { return _vRotation | | return _vTranslationMaxVels; | |
| AxisMaxVels; } | | } | |
| virtual Vector GetAffineRotation3DMaxVels() const { return _vRotation3D | | virtual Vector GetAffineRotationAxisMaxVels() const { | |
| MaxVels; } | | return _vRotationAxisMaxVels; | |
| virtual dReal GetAffineRotationQuatMaxVels() const { return _fQuatMaxAn | | } | |
| gleVelocity; } | | virtual Vector GetAffineRotation3DMaxVels() const { | |
| virtual Vector GetAffineTranslationResolution() const { return _vTransl | | return _vRotation3DMaxVels; | |
| ationResolutions; } | | } | |
| virtual Vector GetAffineRotationAxisResolution() const { return _vRotat | | virtual dReal GetAffineRotationQuatMaxVels() const { | |
| ionAxisResolutions; } | | return _fQuatMaxAngleVelocity; | |
| virtual Vector GetAffineRotation3DResolution() const { return _vRotatio | | } | |
| n3DResolutions; } | | virtual Vector GetAffineTranslationResolution() const { | |
| virtual dReal GetAffineRotationQuatResolution() const { return _fQuatAn | | return _vTranslationResolutions; | |
| gleResolution; } | | } | |
| virtual Vector GetAffineTranslationWeights() const { return _vTranslati | | virtual Vector GetAffineRotationAxisResolution() const { | |
| onWeights; } | | return _vRotationAxisResolutions; | |
| virtual Vector GetAffineRotationAxisWeights() const { return _vRotation | | } | |
| AxisWeights; } | | virtual Vector GetAffineRotation3DResolution() const { | |
| virtual Vector GetAffineRotation3DWeights() const { return _vRotation3D | | return _vRotation3DResolutions; | |
| Weights; } | | } | |
| virtual dReal GetAffineRotationQuatWeights() const { return _fQuatAngle | | virtual dReal GetAffineRotationQuatResolution() const { | |
| Resolution; } | | return _fQuatAngleResolution; | |
| | | } | |
| | | virtual Vector GetAffineTranslationWeights() const { | |
| | | return _vTranslationWeights; | |
| | | } | |
| | | virtual Vector GetAffineRotationAxisWeights() const { | |
| | | return _vRotationAxisWeights; | |
| | | } | |
| | | virtual Vector GetAffineRotation3DWeights() const { | |
| | | return _vRotation3DWeights; | |
| | | } | |
| | | virtual dReal GetAffineRotationQuatWeights() const { | |
| | | return _fQuatAngleResolution; | |
| | | } | |
| | | | |
| virtual void SetActiveDOFValues(const std::vector<dReal>& values, bool
bCheckLimits=false); | | virtual void SetActiveDOFValues(const std::vector<dReal>& values, bool
bCheckLimits=false); | |
| virtual void GetActiveDOFValues(std::vector<dReal>& v) const; | | virtual void GetActiveDOFValues(std::vector<dReal>& v) const; | |
| virtual void SetActiveDOFVelocities(const std::vector<dReal>& velocitie
s, bool bCheckLimits=false); | | virtual void SetActiveDOFVelocities(const std::vector<dReal>& velocitie
s, bool bCheckLimits=false); | |
| virtual void GetActiveDOFVelocities(std::vector<dReal>& velocities) con
st; | | virtual void GetActiveDOFVelocities(std::vector<dReal>& velocities) con
st; | |
| virtual void GetActiveDOFLimits(std::vector<dReal>& lower, std::vector<
dReal>& upper) const; | | virtual void GetActiveDOFLimits(std::vector<dReal>& lower, std::vector<
dReal>& upper) const; | |
| virtual void GetActiveDOFResolutions(std::vector<dReal>& v) const; | | virtual void GetActiveDOFResolutions(std::vector<dReal>& v) const; | |
| virtual void GetActiveDOFWeights(std::vector<dReal>& v) const; | | virtual void GetActiveDOFWeights(std::vector<dReal>& v) const; | |
| virtual void GetActiveDOFMaxVel(std::vector<dReal>& v) const; | | virtual void GetActiveDOFMaxVel(std::vector<dReal>& v) const; | |
| virtual void GetActiveDOFMaxAccel(std::vector<dReal>& v) const; | | virtual void GetActiveDOFMaxAccel(std::vector<dReal>& v) const; | |
| | | | |
| skipping to change at line 440 | | skipping to change at line 514 | |
| | | | |
| /// sets the active manipulator of the robot | | /// sets the active manipulator of the robot | |
| /// \param index manipulator index | | /// \param index manipulator index | |
| virtual void SetActiveManipulator(int index); | | virtual void SetActiveManipulator(int index); | |
| /// sets the active manipulator of the robot | | /// sets the active manipulator of the robot | |
| /// \param manipname manipulator name | | /// \param manipname manipulator name | |
| virtual void SetActiveManipulator(const std::string& manipname); | | virtual void SetActiveManipulator(const std::string& manipname); | |
| virtual ManipulatorPtr GetActiveManipulator(); | | virtual ManipulatorPtr GetActiveManipulator(); | |
| virtual ManipulatorConstPtr GetActiveManipulator() const; | | virtual ManipulatorConstPtr GetActiveManipulator() const; | |
| /// \return index of the current active manipulator | | /// \return index of the current active manipulator | |
|
| virtual int GetActiveManipulatorIndex() const { return _nActiveManip; } | | virtual int GetActiveManipulatorIndex() const { | |
| | | return _nActiveManip; | |
| | | } | |
| | | | |
| /// Converts a trajectory specified with the current active degrees of
freedom to a full joint/transform trajectory | | /// Converts a trajectory specified with the current active degrees of
freedom to a full joint/transform trajectory | |
| /// \param pFullTraj written with the final trajectory, | | /// \param pFullTraj written with the final trajectory, | |
| /// \param pActiveTraj the input active dof trajectory | | /// \param pActiveTraj the input active dof trajectory | |
| /// \param bOverwriteTransforms if true will use the current robot tran
sform as the base (ie will ignore any transforms specified in pActiveTraj).
If false, will use the pActiveTraj transforms specified | | /// \param bOverwriteTransforms if true will use the current robot tran
sform as the base (ie will ignore any transforms specified in pActiveTraj).
If false, will use the pActiveTraj transforms specified | |
| virtual void GetFullTrajectoryFromActive(TrajectoryBasePtr pFullTraj, T
rajectoryBaseConstPtr pActiveTraj, bool bOverwriteTransforms = true); | | virtual void GetFullTrajectoryFromActive(TrajectoryBasePtr pFullTraj, T
rajectoryBaseConstPtr pActiveTraj, bool bOverwriteTransforms = true); | |
| | | | |
|
| virtual bool SetActiveMotion(TrajectoryBaseConstPtr ptraj) { return fal | | virtual bool SetActiveMotion(TrajectoryBaseConstPtr ptraj) { | |
| se; } | | return false; | |
| | | } | |
| | | | |
| /// the speed at which the robot should go at | | /// the speed at which the robot should go at | |
|
| virtual bool SetActiveMotion(TrajectoryBaseConstPtr ptraj, dReal fSpeed | | virtual bool SetActiveMotion(TrajectoryBaseConstPtr ptraj, dReal fSpeed | |
| ) { return SetActiveMotion(ptraj); } | | ) { | |
| | | return SetActiveMotion(ptraj); | |
| | | } | |
| | | | |
| /** \brief Calculates the translation jacobian with respect to a link. | | /** \brief Calculates the translation jacobian with respect to a link. | |
| | | | |
| Calculates the partial differentials for the active degrees of free
dom that in the path from the root node to _veclinks[index] | | Calculates the partial differentials for the active degrees of free
dom that in the path from the root node to _veclinks[index] | |
| (doesn't touch the rest of the values). | | (doesn't touch the rest of the values). | |
| \param mjacobian a 3 x ActiveDOF matrix | | \param mjacobian a 3 x ActiveDOF matrix | |
|
| */ | | */ | |
| virtual void CalculateActiveJacobian(int index, const Vector& offset, b
oost::multi_array<dReal,2>& mjacobian) const; | | virtual void CalculateActiveJacobian(int index, const Vector& offset, b
oost::multi_array<dReal,2>& mjacobian) const; | |
| virtual void CalculateActiveJacobian(int index, const Vector& offset, s
td::vector<dReal>& pfJacobian) const; | | virtual void CalculateActiveJacobian(int index, const Vector& offset, s
td::vector<dReal>& pfJacobian) const; | |
| | | | |
| virtual void CalculateActiveRotationJacobian(int index, const Vector& q
InitialRot, boost::multi_array<dReal,2>& vjacobian) const; | | virtual void CalculateActiveRotationJacobian(int index, const Vector& q
InitialRot, boost::multi_array<dReal,2>& vjacobian) const; | |
| virtual void CalculateActiveRotationJacobian(int index, const Vector& q
InitialRot, std::vector<dReal>& pfJacobian) const; | | virtual void CalculateActiveRotationJacobian(int index, const Vector& q
InitialRot, std::vector<dReal>& pfJacobian) const; | |
| | | | |
| /** Calculates the angular velocity jacobian of a specified link about
the axes of world coordinates. | | /** Calculates the angular velocity jacobian of a specified link about
the axes of world coordinates. | |
| | | | |
| \param index of the link that the rotation is attached to | | \param index of the link that the rotation is attached to | |
| \param mjacobian 3x(num ACTIVE DOF) matrix | | \param mjacobian 3x(num ACTIVE DOF) matrix | |
|
| */ | | */ | |
| virtual void CalculateActiveAngularVelocityJacobian(int index, boost::m
ulti_array<dReal,2>& mjacobian) const; | | virtual void CalculateActiveAngularVelocityJacobian(int index, boost::m
ulti_array<dReal,2>& mjacobian) const; | |
| virtual void CalculateActiveAngularVelocityJacobian(int index, std::vec
tor<dReal>& pfJacobian) const; | | virtual void CalculateActiveAngularVelocityJacobian(int index, std::vec
tor<dReal>& pfJacobian) const; | |
| | | | |
| virtual const std::set<int>& GetNonAdjacentLinks(int adjacentoptions=0)
const; | | virtual const std::set<int>& GetNonAdjacentLinks(int adjacentoptions=0)
const; | |
| | | | |
| //@} | | //@} | |
| | | | |
| /** A grabbed body becomes part of the robot and its relative pose with
respect to a robot's | | /** A grabbed body becomes part of the robot and its relative pose with
respect to a robot's | |
| link will be fixed. KinBody::_AttachBody is called for every grabbe
d body in order to make | | link will be fixed. KinBody::_AttachBody is called for every grabbe
d body in order to make | |
| the grabbed body a part of the robot. Once grabbed, the inter-colli
sions between the robot | | the grabbed body a part of the robot. Once grabbed, the inter-colli
sions between the robot | |
| and the body are regarded as self-collisions; any outside collision
s of the body and the | | and the body are regarded as self-collisions; any outside collision
s of the body and the | |
| environment are regarded as environment collisions with the robot. | | environment are regarded as environment collisions with the robot. | |
| @name Grabbing Bodies | | @name Grabbing Bodies | |
| @{ | | @{ | |
|
| */ | | */ | |
| | | | |
| /** \brief Grab the body with the specified link. | | /** \brief Grab the body with the specified link. | |
| | | | |
| \param[in] body the body to be grabbed | | \param[in] body the body to be grabbed | |
| \param[in] pRobotLinkToGrabWith the link of this robot that will pe
rform the grab | | \param[in] pRobotLinkToGrabWith the link of this robot that will pe
rform the grab | |
| \param[in] setRobotLinksToIgnore Additional robot link indices that
collision checker ignore | | \param[in] setRobotLinksToIgnore Additional robot link indices that
collision checker ignore | |
| when checking collisions between the grabbed body and the robot. | | when checking collisions between the grabbed body and the robot. | |
| \return true if successful and body is grabbed. | | \return true if successful and body is grabbed. | |
|
| */ | | */ | |
| virtual bool Grab(KinBodyPtr body, LinkPtr pRobotLinkToGrabWith, const
std::set<int>& setRobotLinksToIgnore); | | virtual bool Grab(KinBodyPtr body, LinkPtr pRobotLinkToGrabWith, const
std::set<int>& setRobotLinksToIgnore); | |
| | | | |
| /** \brief Grab a body with the specified link. | | /** \brief Grab a body with the specified link. | |
| | | | |
| \param[in] body the body to be grabbed | | \param[in] body the body to be grabbed | |
| \param[in] pRobotLinkToGrabWith the link of this robot that will pe
rform the grab | | \param[in] pRobotLinkToGrabWith the link of this robot that will pe
rform the grab | |
| \return true if successful and body is grabbed/ | | \return true if successful and body is grabbed/ | |
|
| */ | | */ | |
| virtual bool Grab(KinBodyPtr body, LinkPtr pRobotLinkToGrabWith); | | virtual bool Grab(KinBodyPtr body, LinkPtr pRobotLinkToGrabWith); | |
| | | | |
| /** \brief Grabs the body with the active manipulator's end effector. | | /** \brief Grabs the body with the active manipulator's end effector. | |
| | | | |
| \param[in] body the body to be grabbed | | \param[in] body the body to be grabbed | |
| \param[in] setRobotLinksToIgnore Additional robot link indices that
collision checker ignore | | \param[in] setRobotLinksToIgnore Additional robot link indices that
collision checker ignore | |
| when checking collisions between the grabbed body and the robot. | | when checking collisions between the grabbed body and the robot. | |
| \return true if successful and body is grabbed | | \return true if successful and body is grabbed | |
|
| */ | | */ | |
| virtual bool Grab(KinBodyPtr body, const std::set<int>& setRobotLinksTo
Ignore); | | virtual bool Grab(KinBodyPtr body, const std::set<int>& setRobotLinksTo
Ignore); | |
| | | | |
| /** \brief Grabs the body with the active manipulator's end effector. | | /** \brief Grabs the body with the active manipulator's end effector. | |
| | | | |
| \param[in] body the body to be grabbed | | \param[in] body the body to be grabbed | |
| \return true if successful and body is grabbed | | \return true if successful and body is grabbed | |
|
| */ | | */ | |
| virtual bool Grab(KinBodyPtr body); | | virtual bool Grab(KinBodyPtr body); | |
| | | | |
| /** \brief Release the body if grabbed. | | /** \brief Release the body if grabbed. | |
| | | | |
| \param body body to release | | \param body body to release | |
|
| */ | | */ | |
| virtual void Release(KinBodyPtr body); | | virtual void Release(KinBodyPtr body); | |
| | | | |
| /// Release all grabbed bodies. | | /// Release all grabbed bodies. | |
|
| virtual void ReleaseAllGrabbed(); ///< release all bodies | | virtual void ReleaseAllGrabbed(); ///< release all bodies | |
| | | | |
| /** Releases and grabs all bodies, has the effect of recalculating all
the initial collision with the bodies. | | /** Releases and grabs all bodies, has the effect of recalculating all
the initial collision with the bodies. | |
| | | | |
| This has the effect of resetting the current collisions any grabbed
body makes with the robot into an ignore list. | | This has the effect of resetting the current collisions any grabbed
body makes with the robot into an ignore list. | |
|
| */ | | */ | |
| virtual void RegrabAll(); | | virtual void RegrabAll(); | |
| | | | |
| /** \brief return the robot link that is currently grabbing the body. I
f the body is not grabbed, will return an empty pointer. | | /** \brief return the robot link that is currently grabbing the body. I
f the body is not grabbed, will return an empty pointer. | |
| | | | |
| \param[in] body the body to check | | \param[in] body the body to check | |
|
| */ | | */ | |
| virtual LinkPtr IsGrabbing(KinBodyConstPtr body) const; | | virtual LinkPtr IsGrabbing(KinBodyConstPtr body) const; | |
| | | | |
| /** \brief gets all grabbed bodies of the robot | | /** \brief gets all grabbed bodies of the robot | |
| | | | |
| \param[out] vbodies filled with the grabbed bodies | | \param[out] vbodies filled with the grabbed bodies | |
|
| */ | | */ | |
| virtual void GetGrabbed(std::vector<KinBodyPtr>& vbodies) const; | | virtual void GetGrabbed(std::vector<KinBodyPtr>& vbodies) const; | |
| //@} | | //@} | |
| | | | |
| /** \brief Simulate the robot and update the grabbed bodies and attache
d sensors | | /** \brief Simulate the robot and update the grabbed bodies and attache
d sensors | |
| | | | |
| Do not call SimulationStep for the attached sensors in this functio
n. | | Do not call SimulationStep for the attached sensors in this functio
n. | |
|
| */ | | */ | |
| virtual void SimulationStep(dReal fElapsedTime); | | virtual void SimulationStep(dReal fElapsedTime); | |
| | | | |
| /** \brief Check if body is self colliding. Links that are joined toget
her are ignored. | | /** \brief Check if body is self colliding. Links that are joined toget
her are ignored. | |
| | | | |
| \param report [optional] collision report | | \param report [optional] collision report | |
|
| */ | | */ | |
| virtual bool CheckSelfCollision(CollisionReportPtr report = CollisionRe
portPtr()) const; | | virtual bool CheckSelfCollision(CollisionReportPtr report = CollisionRe
portPtr()) const; | |
| | | | |
| /** \brief checks collision of a robot link with the surrounding enviro
nment. Attached/Grabbed bodies to this link are also checked for collision. | | /** \brief checks collision of a robot link with the surrounding enviro
nment. Attached/Grabbed bodies to this link are also checked for collision. | |
| | | | |
| \param[in] ilinkindex the index of the link to check | | \param[in] ilinkindex the index of the link to check | |
| \param[in] tlinktrans The transform of the link to check | | \param[in] tlinktrans The transform of the link to check | |
| \param[out] report [optional] collision report | | \param[out] report [optional] collision report | |
|
| */ | | */ | |
| virtual bool CheckLinkCollision(int ilinkindex, const Transform& tlinkt
rans, CollisionReportPtr report = CollisionReportPtr()); | | virtual bool CheckLinkCollision(int ilinkindex, const Transform& tlinkt
rans, CollisionReportPtr report = CollisionReportPtr()); | |
| | | | |
| /// does not clone the grabbed bodies since it requires pointers from o
ther bodies (that might not be initialized yet) | | /// does not clone the grabbed bodies since it requires pointers from o
ther bodies (that might not be initialized yet) | |
| virtual void Clone(InterfaceBaseConstPtr preference, int cloningoptions
); | | virtual void Clone(InterfaceBaseConstPtr preference, int cloningoptions
); | |
| | | | |
| /// \return true if this body is derived from RobotBase | | /// \return true if this body is derived from RobotBase | |
|
| virtual bool IsRobot() const { return true; } | | virtual bool IsRobot() const { | |
| | | return true; | |
| | | } | |
| | | | |
| virtual void serialize(std::ostream& o, int options) const; | | virtual void serialize(std::ostream& o, int options) const; | |
| | | | |
| /// A md5 hash unique to the particular robot structure that involves m
anipulation and sensing components | | /// A md5 hash unique to the particular robot structure that involves m
anipulation and sensing components | |
| /// The serialization for the attached sensors will not involve any sen
sor specific properties (since they can change through calibration) | | /// The serialization for the attached sensors will not involve any sen
sor specific properties (since they can change through calibration) | |
| virtual const std::string& GetRobotStructureHash() const; | | virtual const std::string& GetRobotStructureHash() const; | |
| | | | |
| /// \brief gets the robot controller | | /// \brief gets the robot controller | |
|
| virtual ControllerBasePtr GetController() const { return ControllerBase | | virtual ControllerBasePtr GetController() const { | |
| Ptr(); } | | return ControllerBasePtr(); | |
| | | } | |
| | | | |
| /// \brief set a controller for a robot | | /// \brief set a controller for a robot | |
| /// \param pController - if NULL, sets the controller of this robot to
NULL. otherwise attemps to set the controller to this robot. | | /// \param pController - if NULL, sets the controller of this robot to
NULL. otherwise attemps to set the controller to this robot. | |
| /// \param args - the argument list to pass when initializing the contr
oller | | /// \param args - the argument list to pass when initializing the contr
oller | |
| virtual bool SetController(ControllerBasePtr controller, const std::vec
tor<int>& dofindices, int nControlTransformation); | | virtual bool SetController(ControllerBasePtr controller, const std::vec
tor<int>& dofindices, int nControlTransformation); | |
| | | | |
| /// \deprecated (10/11/16) | | /// \deprecated (10/11/16) | |
| virtual bool SetController(ControllerBasePtr controller, const std::str
ing& args) RAVE_DEPRECATED { | | virtual bool SetController(ControllerBasePtr controller, const std::str
ing& args) RAVE_DEPRECATED { | |
| std::vector<int> dofindices; | | std::vector<int> dofindices; | |
| for(int i = 0; i < GetDOF(); ++i) { | | for(int i = 0; i < GetDOF(); ++i) { | |
| dofindices.push_back(i); | | dofindices.push_back(i); | |
| } | | } | |
| return SetController(controller,dofindices,1); | | return SetController(controller,dofindices,1); | |
| } | | } | |
| | | | |
| protected: | | protected: | |
| RobotBase(EnvironmentBasePtr penv); | | RobotBase(EnvironmentBasePtr penv); | |
| | | | |
|
| inline RobotBasePtr shared_robot() { return boost::static_pointer_cast< | | inline RobotBasePtr shared_robot() { | |
| RobotBase>(shared_from_this()); } | | return boost::static_pointer_cast<RobotBase>(shared_from_this()); | |
| inline RobotBaseConstPtr shared_robot_const() const { return boost::sta | | } | |
| tic_pointer_cast<RobotBase const>(shared_from_this()); } | | inline RobotBaseConstPtr shared_robot_const() const { | |
| | | return boost::static_pointer_cast<RobotBase const>(shared_from_this | |
| | | ()); | |
| | | } | |
| | | | |
| /// \brief Proprocess the manipulators and sensors and build the specif
ic robot hashes. | | /// \brief Proprocess the manipulators and sensors and build the specif
ic robot hashes. | |
| virtual void _ComputeInternalInformation(); | | virtual void _ComputeInternalInformation(); | |
| | | | |
| /// \brief Called to notify the body that certain groups of parameters
have been changed. | | /// \brief Called to notify the body that certain groups of parameters
have been changed. | |
| /// | | /// | |
| /// This function in calls every registers calledback that is tracking
the changes. | | /// This function in calls every registers calledback that is tracking
the changes. | |
| virtual void _ParametersChanged(int parameters); | | virtual void _ParametersChanged(int parameters); | |
| | | | |
|
| std::vector<Grabbed> _vGrabbedBodies; ///vector of grabbed bodies | | std::vector<Grabbed> _vGrabbedBodies; ///< vector of grabbed bodies | |
| virtual void _UpdateGrabbedBodies(); | | virtual void _UpdateGrabbedBodies(); | |
| virtual void _UpdateAttachedSensors(); | | virtual void _UpdateAttachedSensors(); | |
| std::vector<ManipulatorPtr> _vecManipulators; ///< \see GetManipulators | | std::vector<ManipulatorPtr> _vecManipulators; ///< \see GetManipulators | |
|
| int _nActiveManip; ///< \see GetActiveManipulatorIndex | | int _nActiveManip; ///< \see GetActiveManipulatorIndex | |
| | | | |
| std::vector<AttachedSensorPtr> _vecSensors; ///< \see GetAttachedSensor
s | | std::vector<AttachedSensorPtr> _vecSensors; ///< \see GetAttachedSensor
s | |
| | | | |
| std::vector<int> _vActiveDOFIndices, _vAllDOFIndices; | | std::vector<int> _vActiveDOFIndices, _vAllDOFIndices; | |
| Vector vActvAffineRotationAxis; | | Vector vActvAffineRotationAxis; | |
|
| int _nActiveDOF; ///< Active degrees of freedom; if -1, use | | int _nActiveDOF; ///< Active degrees of freedom; if -1, use robot dofs | |
| robot dofs | | int _nAffineDOFs; ///< dofs describe what affine transformations are al | |
| int _nAffineDOFs; ///< dofs describe what affine transformati | | lowed | |
| ons are allowed | | | |
| | | | |
| Vector _vTranslationLowerLimits, _vTranslationUpperLimits, _vTranslatio
nMaxVels, _vTranslationResolutions, _vTranslationWeights; | | Vector _vTranslationLowerLimits, _vTranslationUpperLimits, _vTranslatio
nMaxVels, _vTranslationResolutions, _vTranslationWeights; | |
| /// the xyz components are used if the rotation axis is solely about X,
Y,or Z; otherwise the W component is used. | | /// the xyz components are used if the rotation axis is solely about X,
Y,or Z; otherwise the W component is used. | |
| Vector _vRotationAxisLowerLimits, _vRotationAxisUpperLimits, _vRotation
AxisMaxVels, _vRotationAxisResolutions, _vRotationAxisWeights; | | Vector _vRotationAxisLowerLimits, _vRotationAxisUpperLimits, _vRotation
AxisMaxVels, _vRotationAxisResolutions, _vRotationAxisWeights; | |
| Vector _vRotation3DLowerLimits, _vRotation3DUpperLimits, _vRotation3DMa
xVels, _vRotation3DResolutions, _vRotation3DWeights; | | Vector _vRotation3DLowerLimits, _vRotation3DUpperLimits, _vRotation3DMa
xVels, _vRotation3DResolutions, _vRotation3DWeights; | |
| Vector _vRotationQuatLimitStart; | | Vector _vRotationQuatLimitStart; | |
| dReal _fQuatLimitMaxAngle, _fQuatMaxAngleVelocity, _fQuatAngleResolutio
n, _fQuatAngleWeight; | | dReal _fQuatLimitMaxAngle, _fQuatMaxAngleVelocity, _fQuatAngleResolutio
n, _fQuatAngleWeight; | |
| | | | |
| private: | | private: | |
|
| virtual const char* GetHash() const { return OPENRAVE_ROBOT_HASH; } | | virtual const char* GetHash() const { | |
| virtual const char* GetKinBodyHash() const { return OPENRAVE_KINBODY_HA | | return OPENRAVE_ROBOT_HASH; | |
| SH; } | | } | |
| | | virtual const char* GetKinBodyHash() const { | |
| | | return OPENRAVE_KINBODY_HASH; | |
| | | } | |
| mutable std::string __hashrobotstructure; | | mutable std::string __hashrobotstructure; | |
| mutable std::vector<dReal> _vTempRobotJoints; | | mutable std::vector<dReal> _vTempRobotJoints; | |
| | | | |
| #ifdef RAVE_PRIVATE | | #ifdef RAVE_PRIVATE | |
| #ifdef _MSC_VER | | #ifdef _MSC_VER | |
| friend class Environment; | | friend class Environment; | |
| friend class ColladaReader; | | friend class ColladaReader; | |
| friend class ColladaWriter; | | friend class ColladaWriter; | |
| friend class OpenRAVEXMLParser::RobotXMLReader; | | friend class OpenRAVEXMLParser::RobotXMLReader; | |
| friend class OpenRAVEXMLParser::ManipulatorXMLReader; | | friend class OpenRAVEXMLParser::ManipulatorXMLReader; | |
| | | | |
End of changes. 64 change blocks. |
| 146 lines changed or deleted | | 208 lines changed or added | |
|
| sensor.h | | sensor.h | |
| | | | |
| skipping to change at line 19 | | skipping to change at line 19 | |
| // | | // | |
| // This program is distributed in the hope that it will be useful, | | // This program is distributed in the hope that it will be useful, | |
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| // GNU Lesser General Public License for more details. | | // GNU Lesser General Public License for more details. | |
| // | | // | |
| // You should have received a copy of the GNU Lesser General Public License | | // You should have received a copy of the GNU Lesser General Public License | |
| // along with this program. If not, see <http://www.gnu.org/licenses/>. | | // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| /** \file sensor.h | | /** \file sensor.h | |
| \brief Sensor and sensing related defintions. | | \brief Sensor and sensing related defintions. | |
|
| */ | | */ | |
| #ifndef OPENRAVE_SENSOR_H | | #ifndef OPENRAVE_SENSOR_H | |
| #define OPENRAVE_SENSOR_H | | #define OPENRAVE_SENSOR_H | |
| | | | |
| namespace OpenRAVE { | | namespace OpenRAVE { | |
| | | | |
| /** \brief <b>[interface]</b> A sensor measures physical properties from th
e environment. See \ref arch_sensor. | | /** \brief <b>[interface]</b> A sensor measures physical properties from th
e environment. See \ref arch_sensor. | |
|
| \ingroup interfaces | | \ingroup interfaces | |
| */ | | */ | |
| class OPENRAVE_API SensorBase : public InterfaceBase | | class OPENRAVE_API SensorBase : public InterfaceBase | |
| { | | { | |
| public: | | public: | |
| enum SensorType | | enum SensorType | |
| { | | { | |
| ST_Invalid=0, | | ST_Invalid=0, | |
| ST_Laser=1, | | ST_Laser=1, | |
| ST_Camera=2, | | ST_Camera=2, | |
| ST_JointEncoder=3, | | ST_JointEncoder=3, | |
| ST_Force6D=4, | | ST_Force6D=4, | |
| | | | |
| skipping to change at line 50 | | skipping to change at line 50 | |
| ST_Tactile=7, | | ST_Tactile=7, | |
| ST_Actuator=8, | | ST_Actuator=8, | |
| ST_NumberofSensorTypes=8 | | ST_NumberofSensorTypes=8 | |
| }; | | }; | |
| | | | |
| typedef geometry::RaveCameraIntrinsics<dReal> CameraIntrinsics; | | typedef geometry::RaveCameraIntrinsics<dReal> CameraIntrinsics; | |
| | | | |
| /// used to pass sensor data around | | /// used to pass sensor data around | |
| class OPENRAVE_API SensorData | | class OPENRAVE_API SensorData | |
| { | | { | |
|
| public: | | public: | |
| virtual ~SensorData() {} | | virtual ~SensorData() { | |
| | | } | |
| virtual SensorType GetType() = 0; | | virtual SensorType GetType() = 0; | |
| | | | |
| /// Serialize the sensor data to stream in XML format | | /// Serialize the sensor data to stream in XML format | |
| virtual bool serialize(std::ostream& O) const; | | virtual bool serialize(std::ostream& O) const; | |
| | | | |
|
| uint64_t __stamp; ///< time stamp of the sensor data in microsecond | | uint64_t __stamp; ///< time stamp of the sensor data in mic | |
| s. If 0, then the data is uninitialized! (floating-point precision is bad h | | roseconds. If 0, then the data is uninitialized! (floating-point precision | |
| ere). This can be either simulation or real time depending on the sensor. | | is bad here). This can be either simulation or real time depending on the s | |
| Transform __trans; ///< the coordinate system the sensor was wh | | ensor. | |
| en the measurement was taken, this is taken directly from SensorBase::GetTr | | Transform __trans; ///< the coordinate system the senso | |
| ansform | | r was when the measurement was taken, this is taken directly from SensorBas | |
| | | e::GetTransform | |
| }; | | }; | |
| typedef boost::shared_ptr<SensorBase::SensorData> SensorDataPtr; | | typedef boost::shared_ptr<SensorBase::SensorData> SensorDataPtr; | |
| typedef boost::shared_ptr<SensorBase::SensorData const> SensorDataConst
Ptr; | | typedef boost::shared_ptr<SensorBase::SensorData const> SensorDataConst
Ptr; | |
| | | | |
| class OPENRAVE_API LaserSensorData : public SensorData | | class OPENRAVE_API LaserSensorData : public SensorData | |
| { | | { | |
|
| public: | | public: | |
| virtual SensorType GetType() { return ST_Laser; } | | virtual SensorType GetType() { | |
| | | return ST_Laser; | |
| | | } | |
| | | | |
|
| std::vector<RaveVector<dReal> > positions; ///< world coordinates o | | std::vector<RaveVector<dReal> > positions; ///< world coord | |
| f the origins of each of the laser points. | | inates of the origins of each of the laser points. | |
| ///< if positions is empty, assume t | | ///< if positions is empty, assume the origin is t.trans for all po | |
| he origin is t.trans for all points | | ints | |
| std::vector<RaveVector<dReal> > ranges; ///< Range and direction re | | std::vector<RaveVector<dReal> > ranges; ///< Range and dire | |
| adings in the form of direction*distance. The direction is in world coordin | | ction readings in the form of direction*distance. The direction is in world | |
| ates. The values should be returned in the order laser detected them in. | | coordinates. The values should be returned in the order laser detected the | |
| std::vector<dReal> intensity; ///< Intensity readings. | | m in. | |
| | | std::vector<dReal> intensity; ///< Intensity readings. | |
| | | | |
| virtual bool serialize(std::ostream& O) const; | | virtual bool serialize(std::ostream& O) const; | |
| }; | | }; | |
| class OPENRAVE_API CameraSensorData : public SensorData | | class OPENRAVE_API CameraSensorData : public SensorData | |
| { | | { | |
|
| public: | | public: | |
| virtual SensorType GetType() { return ST_Camera; } | | virtual SensorType GetType() { | |
| std::vector<uint8_t> vimagedata; ///< rgb image data, if camera onl | | return ST_Camera; | |
| y outputs in grayscale, fill each channel with the same value | | } | |
| | | std::vector<uint8_t> vimagedata; ///< rgb image data, if ca | |
| | | mera only outputs in grayscale, fill each channel with the same value | |
| virtual bool serialize(std::ostream& O) const; | | virtual bool serialize(std::ostream& O) const; | |
| }; | | }; | |
| | | | |
| /// \brief Stores joint angles and EE position. | | /// \brief Stores joint angles and EE position. | |
| class OPENRAVE_API JointEncoderSensorData : public SensorData | | class OPENRAVE_API JointEncoderSensorData : public SensorData | |
| { | | { | |
|
| public: | | public: | |
| virtual SensorType GetType() { return ST_JointEncoder; } | | virtual SensorType GetType() { | |
| std::vector<dReal> encoderValues; ///< measured joint angles in rad | | return ST_JointEncoder; | |
| ians | | } | |
| std::vector<dReal> encoderVelocity; ///< measured joint velocity in | | std::vector<dReal> encoderValues; ///< measured joint angle | |
| radians | | s in radians | |
| | | std::vector<dReal> encoderVelocity; ///< measured joint vel | |
| | | ocity in radians | |
| }; | | }; | |
| | | | |
| /// \brief Stores force data | | /// \brief Stores force data | |
| class OPENRAVE_API Force6DSensorData : public SensorData | | class OPENRAVE_API Force6DSensorData : public SensorData | |
| { | | { | |
|
| public: | | public: | |
| virtual SensorType GetType() { return ST_Force6D; } | | virtual SensorType GetType() { | |
| Vector force; ///< Force in X Y Z, in newtons | | return ST_Force6D; | |
| Vector torque; ///< Torque in X Y Z, in newtonmeters | | } | |
| | | Vector force; ///< Force in X Y Z, in newtons | |
| | | Vector torque; ///< Torque in X Y Z, in newtonmeters | |
| }; | | }; | |
| | | | |
| /// \brief Stores IMU data | | /// \brief Stores IMU data | |
| class OPENRAVE_API IMUSensorData : public SensorData | | class OPENRAVE_API IMUSensorData : public SensorData | |
| { | | { | |
|
| public: | | public: | |
| virtual SensorType GetType() { return ST_IMU; } | | virtual SensorType GetType() { | |
| Vector rotation; ///< quaternion | | return ST_IMU; | |
| | | } | |
| | | Vector rotation; ///< quaternion | |
| Vector angular_velocity; | | Vector angular_velocity; | |
| Vector linear_acceleration; | | Vector linear_acceleration; | |
|
| boost::array<dReal,9> rotation_covariance; ///< Row major about x, | | boost::array<dReal,9> rotation_covariance; ///< Row major a | |
| y, z axes | | bout x, y, z axes | |
| boost::array<dReal,9> angular_velocity_covariance; ///< Row major a | | boost::array<dReal,9> angular_velocity_covariance; ///< Row | |
| bout x, y, z axes | | major about x, y, z axes | |
| boost::array<dReal,9> linear_acceleration_covariance; ///< Row majo | | boost::array<dReal,9> linear_acceleration_covariance; ///< | |
| r x, y z axes | | Row major x, y z axes | |
| }; | | }; | |
| | | | |
| /// \brief odometry data storing full 6D pose and velocity | | /// \brief odometry data storing full 6D pose and velocity | |
| class OPENRAVE_API OdometrySensorData : public SensorData | | class OPENRAVE_API OdometrySensorData : public SensorData | |
| { | | { | |
|
| public: | | public: | |
| virtual SensorType GetType() { return ST_Odometry; } | | virtual SensorType GetType() { | |
| Transform pose; ///< measured pose | | return ST_Odometry; | |
| Vector linear_velocity, angular_velocity; ///< measured velocity | | } | |
| boost::array<dReal,36> pose_covariance; ///< Row major of 6x6 matri | | Transform pose; ///< measured pose | |
| x about linear x, y, z axes | | Vector linear_velocity, angular_velocity; ///< measured vel | |
| boost::array<dReal,36> velocity_covariance; ///< Row major of 6x6 m | | ocity | |
| atrix about rotational x, y, z axes | | boost::array<dReal,36> pose_covariance; ///< Row major of 6 | |
| | | x6 matrix about linear x, y, z axes | |
| | | boost::array<dReal,36> velocity_covariance; ///< Row major | |
| | | of 6x6 matrix about rotational x, y, z axes | |
| }; | | }; | |
| | | | |
| /// \brief tactle data | | /// \brief tactle data | |
| class OPENRAVE_API TactileSensorData : public SensorData | | class OPENRAVE_API TactileSensorData : public SensorData | |
| { | | { | |
|
| public: | | public: | |
| virtual SensorType GetType() { return ST_Tactile; } | | virtual SensorType GetType() { | |
| std::vector<Vector> forces; /// xyz force of each individual elemen | | return ST_Tactile; | |
| t | | } | |
| boost::array<dReal,9> force_covariance; ///< row major 3x3 matrix o | | std::vector<Vector> forces; /// xyz force of each individua | |
| f the uncertainty on the xyz force measurements | | l element | |
| | | boost::array<dReal,9> force_covariance; ///< row major 3x3 | |
| | | matrix of the uncertainty on the xyz force measurements | |
| }; | | }; | |
| | | | |
| /// \brief An actuator for modeling motors and other mechanisms that pr
oduce torque/force. The actuator has only one degree of freedom. | | /// \brief An actuator for modeling motors and other mechanisms that pr
oduce torque/force. The actuator has only one degree of freedom. | |
| class OPENRAVE_API ActuatorSensorData : public SensorData | | class OPENRAVE_API ActuatorSensorData : public SensorData | |
| { | | { | |
|
| public: | | public: | |
| /// \brief the state of the actuator | | /// \brief the state of the actuator | |
| enum ActuatorState { | | enum ActuatorState { | |
|
| AS_Undefined=0, ///< returned when no state is defined | | AS_Undefined=0, ///< returned when no state is defined | |
| AS_Idle=1, ///< this actuator is idle | | AS_Idle=1, ///< this actuator is idle | |
| AS_Moving=2, ///< this actuator is in motion from previous comm | | AS_Moving=2, ///< this actuator is in motion from previ | |
| ands | | ous commands | |
| AS_Stalled=3, ///< the actuator is stalled, needs to be unstall | | AS_Stalled=3, ///< the actuator is stalled, needs to be | |
| ed by sending a ready signal | | unstalled by sending a ready signal | |
| AS_Braked=4, ///< the actuator is braked | | AS_Braked=4, ///< the actuator is braked | |
| }; | | }; | |
| | | | |
|
| ActuatorSensorData() : state(AS_Undefined), measuredcurrent(0), mea | | ActuatorSensorData() : state(AS_Undefined), measuredcurrent(0), mea | |
| suredtemperature(0), appliedcurrent(0) {} | | suredtemperature(0), appliedcurrent(0) { | |
| virtual SensorType GetType() { return ST_Actuator; } | | } | |
| | | virtual SensorType GetType() { | |
| | | return ST_Actuator; | |
| | | } | |
| | | | |
| ActuatorState state; | | ActuatorState state; | |
|
| dReal measuredcurrent; ///< measured current from the actuator | | dReal measuredcurrent; ///< measured current from the actua | |
| dReal measuredtemperature; ///< measured temperature from the actua | | tor | |
| tor | | dReal measuredtemperature; ///< measured temperature from t | |
| dReal appliedcurrent; ///< current sent to the actuator | | he actuator | |
| | | dReal appliedcurrent; ///< current sent to the actuator | |
| }; | | }; | |
| | | | |
| /// permanent properties of the sensors | | /// permanent properties of the sensors | |
| class OPENRAVE_API SensorGeometry | | class OPENRAVE_API SensorGeometry | |
| { | | { | |
|
| public: | | public: | |
| virtual ~SensorGeometry() {} | | virtual ~SensorGeometry() { | |
| | | } | |
| virtual SensorType GetType() = 0; | | virtual SensorType GetType() = 0; | |
| }; | | }; | |
| typedef boost::shared_ptr<SensorBase::SensorGeometry> SensorGeometryPtr
; | | typedef boost::shared_ptr<SensorBase::SensorGeometry> SensorGeometryPtr
; | |
| typedef boost::shared_ptr<SensorBase::SensorGeometry const> SensorGeome
tryConstPtr; | | typedef boost::shared_ptr<SensorBase::SensorGeometry const> SensorGeome
tryConstPtr; | |
| | | | |
| class OPENRAVE_API LaserGeomData : public SensorGeometry | | class OPENRAVE_API LaserGeomData : public SensorGeometry | |
| { | | { | |
|
| public: | | public: | |
| LaserGeomData() : min_range(0), max_range(0), time_increment(0), time_s | | LaserGeomData() : min_range(0), max_range(0), time_increment(0), ti | |
| can(0) { min_angle[0] = min_angle[1] = max_angle[0] = max_angle[1] = resolu | | me_scan(0) { | |
| tion[0] = resolution[1] = 0; } | | min_angle[0] = min_angle[1] = max_angle[0] = max_angle[1] = res | |
| virtual SensorType GetType() { return ST_Laser; } | | olution[0] = resolution[1] = 0; | |
| boost::array<dReal,2> min_angle; ///< Start for the laser scan [rad | | } | |
| ]. | | virtual SensorType GetType() { | |
| boost::array<dReal,2> max_angle; ///< End angles for the laser scan | | return ST_Laser; | |
| [rad]. | | } | |
| boost::array<dReal,2> resolution; ///< Angular resolutions for each | | boost::array<dReal,2> min_angle; ///< Start for the laser s | |
| axis of rotation [rad]. | | can [rad]. | |
| dReal min_range, max_range; ///< Maximum range [m]. | | boost::array<dReal,2> max_angle; ///< End angles for the la | |
| dReal time_increment; ///< time between individual measurements [se | | ser scan [rad]. | |
| conds] | | boost::array<dReal,2> resolution; ///< Angular resolutions | |
| dReal time_scan; ///< time between scans [seconds] | | for each axis of rotation [rad]. | |
| | | dReal min_range, max_range; ///< Maximum range [m]. | |
| | | dReal time_increment; ///< time between individual measurem | |
| | | ents [seconds] | |
| | | dReal time_scan; ///< time between scans [seconds] | |
| }; | | }; | |
| class OPENRAVE_API CameraGeomData : public SensorGeometry | | class OPENRAVE_API CameraGeomData : public SensorGeometry | |
| { | | { | |
|
| public: | | public: | |
| CameraGeomData() : width(0), height(0) {} | | CameraGeomData() : width(0), height(0) { | |
| virtual SensorType GetType() { return ST_Camera; } | | } | |
| CameraIntrinsics KK; ///< intrinsic matrix | | virtual SensorType GetType() { | |
| int width, height; ///< width and height of image | | return ST_Camera; | |
| | | } | |
| | | CameraIntrinsics KK; ///< intrinsic matrix | |
| | | int width, height; ///< width and height of image | |
| }; | | }; | |
| class OPENRAVE_API JointEncoderGeomData : public SensorGeometry | | class OPENRAVE_API JointEncoderGeomData : public SensorGeometry | |
| { | | { | |
|
| public: | | public: | |
| JointEncoderGeomData() : resolution(0) {} | | JointEncoderGeomData() : resolution(0) { | |
| virtual SensorType GetType() { return ST_JointEncoder; } | | } | |
| std::vector<dReal> resolution; ///< the delta value of one encoder | | virtual SensorType GetType() { | |
| tick | | return ST_JointEncoder; | |
| | | } | |
| | | std::vector<dReal> resolution; ///< the delta value of one | |
| | | encoder tick | |
| }; | | }; | |
| class OPENRAVE_API Force6DGeomData : public SensorGeometry | | class OPENRAVE_API Force6DGeomData : public SensorGeometry | |
| { | | { | |
|
| public: | | public: | |
| virtual SensorType GetType() { return ST_Force6D; } | | virtual SensorType GetType() { | |
| | | return ST_Force6D; | |
| | | } | |
| }; | | }; | |
| class OPENRAVE_API IMUGeomData : public SensorGeometry | | class OPENRAVE_API IMUGeomData : public SensorGeometry | |
| { | | { | |
|
| public: | | public: | |
| virtual SensorType GetType() { return ST_IMU; } | | virtual SensorType GetType() { | |
| dReal time_measurement; ///< time between measurements | | return ST_IMU; | |
| | | } | |
| | | dReal time_measurement; ///< time between measurements | |
| }; | | }; | |
| class OPENRAVE_API OdometryGeomData : public SensorGeometry | | class OPENRAVE_API OdometryGeomData : public SensorGeometry | |
| { | | { | |
|
| public: | | public: | |
| virtual SensorType GetType() { return ST_Odometry; } | | virtual SensorType GetType() { | |
| std::string targetid; ///< id of the target whose odometry/pose mes | | return ST_Odometry; | |
| sages are being published for | | } | |
| | | std::string targetid; ///< id of the target whose odometry/ | |
| | | pose messages are being published for | |
| }; | | }; | |
| | | | |
| class OPENRAVE_API TactileGeomData : public SensorGeometry | | class OPENRAVE_API TactileGeomData : public SensorGeometry | |
| { | | { | |
|
| public: | | public: | |
| virtual SensorType GetType() { return ST_Tactile; } | | virtual SensorType GetType() { | |
| | | return ST_Tactile; | |
| | | } | |
| | | | |
| /// LuGre friction model? | | /// LuGre friction model? | |
| struct Friction | | struct Friction | |
| { | | { | |
|
| dReal sigma_0; ///< the stiffness coefficient of the contacting | | dReal sigma_0; ///< the stiffness coefficient of the co | |
| surfaces | | ntacting surfaces | |
| dReal sigma_1; ///< the friction damping coefficient. | | dReal sigma_1; ///< the friction damping coefficient. | |
| dReal mu_s; ///< static friction coefficient | | dReal mu_s; ///< static friction coefficient | |
| dReal mu_d; ///< dynamic friction coefficient | | dReal mu_d; ///< dynamic friction coefficient | |
| }; | | }; | |
|
| std::vector<Vector> positions; ///< 3D positions of all the element | | std::vector<Vector> positions; ///< 3D positions of all the | |
| s in the sensor frame | | elements in the sensor frame | |
| dReal thickness; ///< the thickness of the tactile sensors (used fo | | dReal thickness; ///< the thickness of the tactile sensors | |
| r determining contact and computing force) | | (used for determining contact and computing force) | |
| ///dReal normal_force_stiffness, normal_force_damping; ///< simple
model for determining contact force from depressed distance... necessary? | | ///dReal normal_force_stiffness, normal_force_damping; ///< simple
model for determining contact force from depressed distance... necessary? | |
|
| std::map<std::string, Friction> _mapfriction; ///< friction coeffic
ients references by target objects | | std::map<std::string, Friction> _mapfriction; ///< friction
coefficients references by target objects | |
| }; | | }; | |
| | | | |
| class OPENRAVE_API ActuatorGeomData : public SensorGeometry | | class OPENRAVE_API ActuatorGeomData : public SensorGeometry | |
| { | | { | |
|
| public: | | public: | |
| virtual SensorType GetType() { return ST_Actuator; } | | virtual SensorType GetType() { | |
| dReal maxtorque; ///< Maximum possible torque actuator can apply (o | | return ST_Actuator; | |
| n output side). This includes the actuator's rotor, if one exists. | | } | |
| dReal maxcurrent; ///< Maximum permissible current of the actuator. | | dReal maxtorque; ///< Maximum possible torque actuator can | |
| If this current value is exceeded for a prolonged period of time, then an | | apply (on output side). This includes the actuator's rotor, if one exists. | |
| error could occur (due to heat, etc). | | dReal maxcurrent; ///< Maximum permissible current of the a | |
| dReal nominalcurrent; ///< Rated current of the actuator. | | ctuator. If this current value is exceeded for a prolonged period of time, | |
| dReal maxvelocity; ///< Maximum permissible velocity of the system | | then an error could occur (due to heat, etc). | |
| (on output side). | | dReal nominalcurrent; ///< Rated current of the actuator. | |
| dReal maxacceleration; ///< Maximum permissible acceleration of the | | dReal maxvelocity; ///< Maximum permissible velocity of the | |
| system (on output side). | | system (on output side). | |
| dReal maxjerk; ///< Maximum permissible jerking of the system (on o | | dReal maxacceleration; ///< Maximum permissible acceleratio | |
| utput side). The jerk results from a sudden change in acceleration. | | n of the system (on output side). | |
| dReal staticfriction; ///< minimum torque that must be applied for | | dReal maxjerk; ///< Maximum permissible jerking of the syst | |
| actuator to overcome static friction | | em (on output side). The jerk results from a sudden change in acceleration. | |
| dReal viscousfriction; ///< friction depending on the velocity of t | | dReal staticfriction; ///< minimum torque that must be appl | |
| he actuator | | ied for actuator to overcome static friction | |
| | | dReal viscousfriction; ///< friction depending on the veloc | |
| | | ity of the actuator | |
| }; | | }; | |
| | | | |
|
| SensorBase(EnvironmentBasePtr penv) : InterfaceBase(PT_Sensor, penv) {} | | SensorBase(EnvironmentBasePtr penv) : InterfaceBase(PT_Sensor, penv) { | |
| virtual ~SensorBase() {} | | } | |
| | | virtual ~SensorBase() { | |
| | | } | |
| | | | |
| /// return the static interface type this class points to (used for saf
e casting) | | /// return the static interface type this class points to (used for saf
e casting) | |
|
| static inline InterfaceType GetInterfaceTypeStatic() { return PT_Sensor | | static inline InterfaceType GetInterfaceTypeStatic() { | |
| ; } | | return PT_Sensor; | |
| | | } | |
| | | | |
| /// \brief A set of commands used for run-time sensor configuration. | | /// \brief A set of commands used for run-time sensor configuration. | |
| enum ConfigureCommand | | enum ConfigureCommand | |
| { | | { | |
|
| CC_PowerOn=0x10, ///< turns the sensor on, starts gathering data an | | CC_PowerOn=0x10, ///< turns the sensor on, starts gathering dat | |
| d using processor cycles. If the power is already on, servers as a reset. ( | | a and using processor cycles. If the power is already on, servers as a rese | |
| off by default) | | t. (off by default) | |
| CC_PowerOff=0x11, ///< turns the sensor off, stops gathering data ( | | CC_PowerOff=0x11, ///< turns the sensor off, stops gathering da | |
| off by default). | | ta (off by default). | |
| CC_PowerCheck=0x12, ///< returns whether power is on | | CC_PowerCheck=0x12, ///< returns whether power is on | |
| CC_RenderDataOn=0x20, ///< turns on any rendering of the sensor dat | | CC_RenderDataOn=0x20, ///< turns on any rendering of the sensor | |
| a (off by default) | | data (off by default) | |
| CC_RenderDataOff=0x21, ///< turns off any rendering of the sensor d | | CC_RenderDataOff=0x21, ///< turns off any rendering of the sens | |
| ata (off by default) | | or data (off by default) | |
| CC_RenderDataCheck=0x23, ///< returns whether data rendering is on | | CC_RenderDataCheck=0x23, ///< returns whether data rendering is | |
| CC_RenderGeometryOn=0x30, ///< turns on any rendering of the sensor | | on | |
| geometry (on by default) | | CC_RenderGeometryOn=0x30, ///< turns on any rendering of the se | |
| CC_RenderGeometryOff=0x31, ///< turns off any rendering of the sens | | nsor geometry (on by default) | |
| or geometry (on by default) | | CC_RenderGeometryOff=0x31, ///< turns off any rendering of the | |
| CC_RenderGeometryCheck=0x32, ///< returns whether geometry renderin | | sensor geometry (on by default) | |
| g is on | | CC_RenderGeometryCheck=0x32, ///< returns whether geometry rend | |
| | | ering is on | |
| }; | | }; | |
| | | | |
| /// \brief Configures properties of the sensor like power. | | /// \brief Configures properties of the sensor like power. | |
| /// | | /// | |
| /// \param type \ref ConfigureCommand | | /// \param type \ref ConfigureCommand | |
| /// \param blocking If set to true, makes sure the configuration ends b
efore this function returns.(might cause problems if environment is locked)
. | | /// \param blocking If set to true, makes sure the configuration ends b
efore this function returns.(might cause problems if environment is locked)
. | |
| /// \throw openrave_exception if command doesn't succeed | | /// \throw openrave_exception if command doesn't succeed | |
| virtual int Configure(ConfigureCommand command, bool blocking=false) =
0; | | virtual int Configure(ConfigureCommand command, bool blocking=false) =
0; | |
| | | | |
| /// \brief Simulate one step forward for sensors. | | /// \brief Simulate one step forward for sensors. | |
| | | | |
| skipping to change at line 311 | | skipping to change at line 354 | |
| /// \param trans - The transform defining the frame of the sensor. | | /// \param trans - The transform defining the frame of the sensor. | |
| virtual void SetTransform(const Transform& trans) = 0; | | virtual void SetTransform(const Transform& trans) = 0; | |
| virtual Transform GetTransform() = 0; | | virtual Transform GetTransform() = 0; | |
| | | | |
| /// \brief Register a callback whenever new sensor data comes in. | | /// \brief Register a callback whenever new sensor data comes in. | |
| /// \param type the sensor type to register for | | /// \param type the sensor type to register for | |
| /// \param callback the user function to call, note that this might blo
ck the thread generating/receiving sensor data | | /// \param callback the user function to call, note that this might blo
ck the thread generating/receiving sensor data | |
| virtual boost::shared_ptr<void> RegisterDataCallback(SensorType type, c
onst boost::function<void(SensorDataConstPtr)>& callback) OPENRAVE_DUMMY_IM
PLEMENTATION; | | virtual boost::shared_ptr<void> RegisterDataCallback(SensorType type, c
onst boost::function<void(SensorDataConstPtr)>& callback) OPENRAVE_DUMMY_IM
PLEMENTATION; | |
| | | | |
| /// \return the name of the sensor | | /// \return the name of the sensor | |
|
| virtual const std::string& GetName() const { return _name; } | | virtual const std::string& GetName() const { | |
| virtual void SetName(const std::string& newname) { _name = newname; } | | return _name; | |
| | | } | |
| | | virtual void SetName(const std::string& newname) { | |
| | | _name = newname; | |
| | | } | |
| | | | |
| /// \deprecated (11/03/28) | | /// \deprecated (11/03/28) | |
|
| virtual bool Init(const std::string&) RAVE_DEPRECATED { RAVELOG_WARN("S | | virtual bool Init(const std::string&) RAVE_DEPRECATED { | |
| ensorBase::Init has been deprecated\n"); return Configure(CC_PowerOn)>0; } | | RAVELOG_WARN("SensorBase::Init has been deprecated\n"); return Conf | |
| virtual void Reset(int) RAVE_DEPRECATED { RAVELOG_WARN("SensorBase::Res | | igure(CC_PowerOn)>0; | |
| et has been deprecated\n"); Configure(CC_PowerOff); } | | } | |
| | | virtual void Reset(int) RAVE_DEPRECATED { | |
| | | RAVELOG_WARN("SensorBase::Reset has been deprecated\n"); Configure( | |
| | | CC_PowerOff); | |
| | | } | |
| | | | |
| protected: | | protected: | |
|
| std::string _name; ///< name of the sensor | | std::string _name; ///< name of the sensor | |
| | | | |
| private: | | private: | |
|
| virtual const char* GetHash() const { return OPENRAVE_SENSOR_HASH; } | | virtual const char* GetHash() const { | |
| | | return OPENRAVE_SENSOR_HASH; | |
| | | } | |
| }; | | }; | |
| | | | |
| } // end namespace OpenRAVE | | } // end namespace OpenRAVE | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 36 change blocks. |
| 168 lines changed or deleted | | 225 lines changed or added | |
|