31 #include <boost/thread.hpp> 34 #include <omronsentech_camera/GetSDKInfo.h> 35 #include <omronsentech_camera/GetLastError.h> 36 #include <omronsentech_camera/GetDeviceList.h> 37 #include <omronsentech_camera/WriteNodeFloat.h> 38 #include <omronsentech_camera/GetGenICamNodeInfo.h> 39 #include <omronsentech_camera/GetImageAcquisitionStatus.h> 40 #include <omronsentech_camera/EnableImageAcquisition.h> 41 #include <omronsentech_camera/EnableTrigger.h> 42 #include <omronsentech_camera/SendSoftTrigger.h> 44 #define SERVER_NODE "stcamera_node" 45 #define MAX_GRABBED 10 46 #define TRIGGER_SELECTOR "FrameStart" 47 #define TRIGGER_SOURCE "Software" 55 omronsentech_camera::GetSDKInfo srv;
58 std::cout <<
"SentechSDK ver.: " << srv.response.sdk_version << std::endl;
59 for (
size_t i = 0; i < srv.response.gentl_info_list.size(); i++)
61 std::cout <<
"GenTL vendor: " << srv.response.gentl_info_list[i].vendor
63 std::cout <<
"\tversion: " << srv.response.gentl_info_list[i].version
65 std::cout <<
"\tproducer: " << srv.response.gentl_info_list[i]
66 .producer_version << std::endl;
67 std::cout <<
"\tfullpath: " << srv.response.gentl_info_list[i]
68 .full_path << std::endl;
69 std::cout <<
"\tTL type: " << srv.response.gentl_info_list[i]
79 omronsentech_camera::GetDeviceList>(
SERVER_NODE "/get_device_list");
80 omronsentech_camera::GetDeviceList srv;
83 for (
size_t i = 0; i < srv.response.device_list.size(); i++)
85 if (srv.response.device_list[i].connected)
86 return srv.response.device_list[i].device_namespace;
96 std::string ns = NS + dev_ns +
"/get_last_error";
98 omronsentech_camera::GetLastError>(ns);
99 omronsentech_camera::GetLastError srv;
101 std::cout <<
"Last error: " << srv.response.error_code << std::endl;
102 std::cout << srv.response.description << std::endl;
103 return srv.response.error_code;
110 std::string ns = NS + dev_ns +
"/write_node_float";
112 omronsentech_camera::WriteNodeFloat>(ns);
113 omronsentech_camera::WriteNodeFloat srv;
114 srv.request.module_name =
"RemoteDevice";
115 srv.request.node_name =
"Gain";
116 srv.request.value = value;
117 if (client.
call(srv))
return 0;
123 double &value_min,
double &value_max)
126 std::string ns = NS + dev_ns +
"/get_genicam_node_info";
128 omronsentech_camera::GetGenICamNodeInfo>(ns);
129 omronsentech_camera::GetGenICamNodeInfo srv;
130 srv.request.module_name =
"RemoteDevice";
131 srv.request.node_name =
"Gain";
132 if (client.
call(srv))
134 value = std::stod(srv.response.current_value);
135 value_min = std::stod(srv.response.min_value);
136 value_max = std::stod(srv.response.max_value);
147 << msg->width <<
" x " << msg->height <<
" Encoding: " 148 << msg->encoding << std::endl;
155 std::string ns = NS + dev_ns +
"/get_image_acquisition_status";
157 omronsentech_camera::GetImageAcquisitionStatus>(ns);
158 omronsentech_camera::GetImageAcquisitionStatus srv;
159 if (client.
call(srv))
161 return srv.response.value;
171 std::string ns = NS + dev_ns +
"/enable_image_acquisition";
173 omronsentech_camera::EnableImageAcquisition>(ns);
174 omronsentech_camera::EnableImageAcquisition srv;
175 srv.request.value = enabled;
176 if (client.
call(srv))
187 std::string ns = NS + dev_ns +
"/enable_trigger";
189 omronsentech_camera::EnableTrigger>(ns);
190 omronsentech_camera::EnableTrigger srv;
193 srv.request.trigger_delayus = 0;
194 srv.request.value= enabled;
195 if (client.
call(srv))
206 std::string ns = NS + dev_ns +
"/send_soft_trigger";
208 omronsentech_camera::SendSoftTrigger>(ns);
209 omronsentech_camera::SendSoftTrigger srv;
211 if (client.
call(srv))
220 int main(
int argc,
char **argv)
224 boost::thread th(boost::bind(&
ros::spin));
230 std::string dev_ns =
"";
235 if (!dev_ns.empty() || !
ros::ok())
245 double gain_value = 0;
246 double gain_min_value = 0;
247 double gain_max_value = 0;
248 int ret =
getGain(n, dev_ns, gain_value, gain_min_value, gain_max_value);
251 std::cout <<
"Current Gain: " << gain_value << std::endl;
253 double new_gain_value = ((int)(gain_min_value + gain_max_value)/2);
256 ret =
setGain(n, dev_ns, new_gain_value);
259 std::cout <<
"Update Gain to " << new_gain_value <<
" was successful" 265 std::string ns = NS + dev_ns +
"/image_raw";
278 std::cout << std::endl <<
"Enable trigger selector: " <<
TRIGGER_SELECTOR <<
286 for (
int i = 0; i < 10; i++)
289 std::cout <<
"Sleep for 1s" << std::endl;
301 setGain(n, dev_ns, gain_value);
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
int sendTrigger(ros::NodeHandle &n, std::string dev_ns)
std::string getConnectedDeviceNamespace(ros::NodeHandle &n)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool call(MReq &req, MRes &res)
int setGain(ros::NodeHandle &n, std::string dev_ns, double value)
void imageCallback(const sensor_msgs::ImageConstPtr &msg)
ROSCPP_DECL void spin(Spinner &spinner)
int getGain(ros::NodeHandle &n, std::string dev_ns, double &value, double &value_min, double &value_max)
bool isImageAcquisitionEnabled(ros::NodeHandle &n, std::string dev_ns)
void displaySDKInfo(ros::NodeHandle &n)
int setTrigger(ros::NodeHandle &n, std::string dev_ns, bool enabled)
int setImageAcquisition(ros::NodeHandle &n, std::string dev_ns, bool enabled)
ROSCPP_DECL void shutdown()
int getLastError(ros::NodeHandle &n, std::string dev_ns)
int main(int argc, char **argv)