ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

How to start creating a package/node in ROS?

asked 2014-08-07 10:41:13 -0600

mister_kay gravatar image

updated 2014-08-11 04:07:09 -0600

Hello,

I started some weeks ago with ROS, now I want to write a node (or nodelet or package) for my stereo-camera-system (2 Point Grey Flea3 GigE-Cameras).

The pointgrey-camera-driver for ROS doesnt let me handle things like the polarity of the trigger or setting a fixed IP.

Basically my program already exists as a Visual Studio 2010 (yes, PointGrey doesnot support VS2012) project. The program checks the system for exisiting cameras and then sets them up with fixed IP's, enables a trigger, selects a ROI and so on. In the end the settings are stored to the cameras' memory channels where they persist.

Basically I have the problem that I dont know with which ROS tutorial to start and whether I want to create an own ROS package or if it makes sense to define my program as a node/nodelet of the pointgrey-camera package.

I think my node should not subscribe to any topics, it really is more of a c++ program working on its own. I have the compiled library files (eqivalent to windows dlls in Linux I guess) for the FlyCap SDK.

So my idea is to put that node (if succesfully) into my launch file before starting the camera, ideally the node should return a boolean true/false on sucess/failure to the system. How can that be done?

My supervisor told me for Linux there exists a good IDE called QtCreator, so far I have used VS and eclipse in Windows.

Do you have any ideas/suggestions for me?

----UPDATE---

This is the code of my node "stereo_setup" in stereo_setup.cpp. What happens to lines like std::cout << "xyz" or printf(...) in ROS?

I am still uncertain how to set the info that the camera_setup was successfull.

#include <ros.h>

#include<iostream>

#include "FlyCapture2_Axel.h"

using namespace std;
using namespace FlyCapture2;


const char * const mac_address_char_12062824 = "00:B0:9D:B8:10:68";
const char * const mac_address_char_12062828 = "00:B0:9D:B8:10:6C";

const char * const ip_address_char_12062824 = "192.168.1.2";
const char * const ip_address_char_12062828 = "192.168.1.3";

const char * const ip_address_char_submask = "255.255.0.0";
const char * const ip_address_char_gateway= "0.0.0.0";

const unsigned int SN_12062824 = 12062824;
const unsigned int SN_12062828 = 12062828;


const Mode k_fmt7Mode = MODE_0;
const unsigned int image_width =  1344;
const unsigned int image_height = 1032;
const unsigned int MAX_image_width =  1384;
const unsigned int MAX_image_height =  1032;
const PixelFormat pixel_format = PIXEL_FORMAT_RGB;

//turn shutter to manual mode
const bool SHUTTER_MANUAL_MODE = false;
//shutter duration in milliseconds
const unsigned int SHUTTER_DURATION = 8;



//turn on filewriting
//const bool WRITE_TO_FILE = true;

// File Format

// File Format
//const char  * file_format = "bmp";


bool initialize_cameras();
bool connect_cameras(Camera * cam_12062824, Camera * cam_12062828, PGRGuid * pgr_guid_12062824, PGRGuid * pgr_guid_12062828);
bool setup_cameras(Camera * cam_12062824, Camera * cam_12062828);
void PrintBuildInfo();
void PrintError( Error error );
void PrintCameraInfo( CameraInfo* pCamInfo );
void PrintFormat7Capabilities( Format7Info fmt7Info);



int main(int argc, char** argv )

{

    ros::init(argc, argv, "stereo_setup");

    PrintBuildInfo();

    Error error;
    //BusManager busmanager;


    Camera cam_12062824, cam_12062828;
    PGRGuid pgr_guid_12062824, pgr_guid_12062828;

    bool ini = initialize_cameras();
    if(ini == false)
    {
    std::cout << "Could not successfully initialize the two cameras!" << std ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2014-08-07 12:41:07 -0600

l0g1x gravatar image

updated 2015-01-25 14:06:04 -0600

The easiest/simplest way you can do this without modifying much of your code right now, is by creating a ros package, and put all of your source in a folder within that package (i.e /camera_project/catkin_ws/src/stereo_camera_lib/). Then you can just create a node, which instantiates the class that runs everything. To make it even simpler, make sure all of the things that start your camera processing is in constructor of the class you are instantiating. So now at this point you should pretty much have 1 main line of code that starts everything. Its up to you how you want to spit your data through a rostopic. You dont really need a IDE to do that.

I dont 100% know how to correctly link your own libraries to a executable, so you can look at the CMakeList reference and try to figure out on how to link one.


EDIT: To answer your question about the std print functions, ROS has pre-defined macros that already use these to print to screen. I would recommend using the ROS logging macros since they give you the to capability switch between logging to a screen, or to a file, as well as set different debugging levels.

edit flag offensive delete link more

Comments

Thanks for your answer lOg1x

mister_kay gravatar image mister_kay  ( 2014-08-11 03:45:32 -0600 )edit
1

If this answer resolves your question, please click the check mark icon.

joq gravatar image joq  ( 2014-08-13 11:28:08 -0600 )edit

Same problem I am facing. I have bunch of C files, i want to create ROS package for that, How to do that. Mr. 10g1x, Ur idea is matching my problem plz tell me the detail procedure.

Kd gravatar image Kd  ( 2014-12-30 00:57:29 -0600 )edit

@Kd Well im not exactly sure what your C files do, and how you want the data to be represented. It can vary in many different ways for every different scenario. Have you tried anything at all up till this point?

l0g1x gravatar image l0g1x  ( 2015-01-25 14:08:29 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-08-07 10:41:13 -0600

Seen: 948 times

Last updated: Jan 25 '15