Skip to content

Commit

Permalink
Make frame_id configurable and improved default.
Browse files Browse the repository at this point in the history
  • Loading branch information
heikohimu committed Feb 4, 2021
1 parent ed3fad6 commit 2b23f32
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Parameters to be set to the ROS param server before run-time.
* 'exclusive' Exclusive access to the sensor. This prevents other clients to
read GenICam parameters.

* `frame_id`: Frame ID that will be used for header of all published messages.
The default is [<namespace>_]camera[<calib_id>].

* `image_prefix`: Optional prefix for storing all grabbed images.

* `rotate`: True for rotating input images by 180 degrees.
Expand Down
30 changes: 28 additions & 2 deletions src/genicam_camera_nodelet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,34 @@ void GenICamCameraNodelet::onInit()
std::string calib = "";
int calib_id=-1;

std::string ns = ros::this_node::getNamespace();
frame_id_ = ns + "camera";
pnh.param("frame_id", frame_id_, frame_id_);

if (frame_id_.size() == 0)
{
std::string ns = ros::this_node::getNamespace();

if (ns.size() > 0 && ns[0] == '/')
{
ns = ns.substr(1);
}

if (ns.size() > 0)
{
frame_id_ = ns + "_camera";
}
else
{
frame_id_ = "camera";
}

int cid=-1;
pnh.param("calib_id", cid, cid);

if (cid >= 0)
{
frame_id_ = frame_id_ + std::to_string(cid);
}
}

pnh.param("device", device, device);
pnh.param("gev_access", access, access);
Expand Down

0 comments on commit 2b23f32

Please sign in to comment.