Go to the documentation of this file.
74 #define LOG_NXLIB_EXCEPTION(EXCEPTION) \
77 if (EXCEPTION.getErrorCode() == NxLibExecutionFailed) \
79 NxLibItem executionNode(EXCEPTION.getItemPath()); \
80 ENSENSO_ERROR(nh, "%s: %s", executionNode[itmResult][itmErrorSymbol].asString().c_str(), \
81 executionNode[itmResult][itmErrorText].asString().c_str()); \
87 ENSENSO_DEBUG(nh, "Current NxLib tree: %s", NxLibItem().asJson(true).c_str());
93 #define START_NXLIB_ACTION(ACTION_NAME, ACTION_SERVER) \
94 ENSENSO_DEBUG(nh, "Received a " #ACTION_NAME " request."); \
95 auto& server = ACTION_SERVER; \
96 if (server->isPreemptRequested()) \
98 server->setPreempted(); \
101 std::lock_guard<std::mutex> lock(nxLibMutex); \
104 #define FINISH_NXLIB_ACTION(ACTION_NAME) \
106 catch (NxLibException & e) \
108 ENSENSO_ERROR(nh, "NxLibException %d (%s) for item %s", e.getErrorCode(), e.getErrorText().c_str(), \
109 e.getItemPath().c_str()); \
110 LOG_NXLIB_EXCEPTION(e) \
111 ensenso::action::ACTION_NAME##Result result; \
112 result.error.code = e.getErrorCode(); \
113 result.error.message = e.getErrorText(); \
114 server->setAborted(std::move(result)); \
117 catch (tf2::TransformException & e) \
119 ENSENSO_ERROR(nh, "tf Exception: %s", e.what()); \
120 ensenso::action::ACTION_NAME##Result result; \
121 result.error.code = ERROR_CODE_TF; \
122 result.error.message = e.what(); \
123 server->setAborted(std::move(result)); \
126 catch (std::exception & e) \
128 ENSENSO_ERROR(nh, "Unknown Exception: %s", e.what()); \
129 ensenso::action::ACTION_NAME##Result result; \
130 result.error.code = ERROR_CODE_UNKNOWN_EXCEPTION; \
131 result.error.message = e.what(); \
132 server->setAborted(std::move(result)); \
136 #define PREEMPT_ACTION_IF_REQUESTED \
137 if (server->isPreemptRequested()) \
139 server->setPreempted(); \
169 ParameterSet(std::string
const& name, NxLibItem
const& defaultParameters);
314 virtual void init() = 0;
333 bool loadSettings(std::string
const& jsonFile,
bool saveAsDefaultParameters =
false);
338 void onAccessTree(ensenso::action::AccessTreeGoalConstPtr
const& goal);
343 void onExecuteCommand(ensenso::action::ExecuteCommandGoalConstPtr
const& goal);
348 void onGetParameter(ensenso::action::GetParameterGoalConstPtr
const& goal);
353 virtual void onSetParameter(ensenso::action::SetParameterGoalConstPtr
const& goal) = 0;
419 std::string
const& targetFrame =
"",
420 bool latestPatternOnly =
false)
const = 0;
425 virtual std::vector<geometry_msgs::msg::PoseStamped>
435 bool useCachedTransformation =
false)
const;
461 virtual ensenso::msg::ParameterPtr
readParameter(std::string
const& key)
const;
466 virtual void writeParameter(ensenso::msg::Parameter
const& parameter);
CameraParameters(ensenso::ros::NodeHandle &nh, std::string const &cameraType, std::string serial)
void fillBasicCameraInfoFromNxLib(sensor_msgs::msg::CameraInfoPtr const &info) const
virtual void updateCameraTypeSpecifics()
void updateTransformations(tf2::Transform const &targetFrameTransformation) const
std::map< std::string, ParameterSet > parameterSets
std::unique_ptr< ExecuteCommandServer > executeCommandServer
std::string getNxLibTargetFrameName() const
virtual geometry_msgs::msg::PoseStamped estimatePatternPose(ensenso::ros::Time imageTimestamp, std::string const &targetFrame="", bool latestPatternOnly=false) const =0
ParameterSet(std::string const &name, NxLibItem const &defaultParameters)
const std::string DEFAULT_PARAMETER_SET
const double TF_REQUEST_TIMEOUT
std::unique_ptr< ensenso_camera::VirtualObjectHandler > virtualObjectHandler
void saveDefaultParameterSet()
bool cameraIsOpen() const
void onGetParameter(ensenso::action::GetParameterGoalConstPtr const &goal)
void onAccessTree(ensenso::action::AccessTreeGoalConstPtr const &goal)
void loadParameterSet(std::string name)
virtual void writeParameter(ensenso::msg::Parameter const ¶meter)
void saveParameterSet(std::string name)
ensenso::ros::Timer cameraPosePublisher
virtual void startServers() const
std::string fileCameraPath
virtual std::vector< geometry_msgs::msg::PoseStamped > estimatePatternPoses(ensenso::ros::Time imageTimestamp, std::string const &targetFrame="") const =0
std::string currentParameterSet
std::unique_ptr< tf2_ros::TransformBroadcaster > transformBroadcaster
geometry_msgs::msg::TransformStamped stampedLinkToCamera()
ensenso::ros::Timer statusTimer
bool cameraIsAvailable() const
virtual ensenso::ros::Time capture() const =0
void publishStatus(TIMER_CALLBACK_DECLARATION_ARGS)
bool loadSettings(std::string const &jsonFile, bool saveAsDefaultParameters=false)
ensenso::ros::Publisher< diagnostic_msgs::msg::DiagnosticArray > statusPublisher
::ros::NodeHandle NodeHandle
virtual void updateCameraInfo()=0
std::unique_ptr< tf2_ros::TransformListener > transformListener
virtual void onSetParameter(ensenso::action::SetParameterGoalConstPtr const &goal)=0
virtual void initStatusTimer()
virtual void initTfPublishTimer()
NxLibVersion nxLibVersion
std::map< std::string, geometry_msgs::msg::TransformStamped > transformationCache
void onExecuteCommand(ensenso::action::ExecuteCommandGoalConstPtr const &goal)
const int ERROR_CODE_UNKNOWN_EXCEPTION
virtual ensenso::msg::ParameterPtr readParameter(std::string const &key) const
const std::string TARGET_FRAME_LINK
const double POSE_TF_INTERVAL
NxLibItem defaultParameters
std::unique_ptr< AccessTreeServer > accessTreeServer
std::unique_ptr< GetParameterServer > getParameterServer
::std::unique_ptr< ::ros::Publisher > Publisher
Camera(ensenso::ros::NodeHandle &nh, CameraParameters params)
std::unique_ptr< SetParameterServer > setParameterServer
std::unique_ptr< tf2_ros::Buffer > tfBuffer
ensenso::ros::NodeHandle nh
tf2::Transform getCameraToLinkTransform()
#define TIMER_CALLBACK_DECLARATION_ARGS
void updateGlobalLink(ensenso::ros::Time time, std::string targetFrame="", bool useCachedTransformation=false) const
const double STATUS_INTERVAL
void publishCurrentLinks(TIMER_CALLBACK_DECLARATION_ARGS)
ensenso_camera
Author(s): Ensenso
autogenerated on Wed Apr 2 2025 02:37:46