-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from flynneva/ros2-clean-up
Ros2 clean up
- Loading branch information
Showing
8 changed files
with
325 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.cproject | ||
.project | ||
.settings | ||
**__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
usb_cam: | ||
ros__parameters: | ||
video_device: "/dev/video0" | ||
framerate: 15 | ||
io_method: "mmap" | ||
frame_id: "camera" | ||
pixel_format: "yuyv" | ||
image_width: 640 | ||
image_height: 480 | ||
camera_name: "test" | ||
/**: | ||
ros__parameters: | ||
video_device: "/dev/video0" | ||
framerate: 30.0 | ||
io_method: "mmap" | ||
frame_id: "camera" | ||
pixel_format: "yuyv" | ||
image_width: 640 | ||
image_height: 480 | ||
camera_name: "test_cam" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include "usb_cam/usb_cam.h" | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
// #include <image_transport/image_transport.h> | ||
#include "camera_info_manager/camera_info_manager.hpp" | ||
#include "sensor_msgs/msg/image.hpp" | ||
#include "std_srvs/srv/set_bool.hpp" | ||
|
||
std::ostream& operator<<(std::ostream& ostr, const rclcpp::Time& tm) { | ||
ostr << tm.nanoseconds(); | ||
return ostr; | ||
} | ||
|
||
using namespace std::chrono_literals; | ||
|
||
|
||
namespace usb_cam { | ||
|
||
|
||
class UsbCamNode : public rclcpp::Node | ||
{ | ||
public: | ||
UsbCamNode(); | ||
virtual ~UsbCamNode() override; | ||
|
||
void init(); | ||
void get_params(); | ||
void update(); | ||
bool take_and_send_image(); | ||
|
||
void service_capture( | ||
const std::shared_ptr<rmw_request_id_t> request_header, | ||
const std::shared_ptr<std_srvs::srv::SetBool::Request> request, | ||
std::shared_ptr<std_srvs::srv::SetBool::Response> response); | ||
|
||
UsbCam cam_; | ||
|
||
// shared image message | ||
sensor_msgs::msg::Image::UniquePtr img_; | ||
rclcpp::Publisher<sensor_msgs::msg::Image>::SharedPtr image_pub_; | ||
// parameters | ||
std::string video_device_name_; | ||
std::string frame_id_; | ||
|
||
std::string io_method_name_; | ||
// these parameters all have to be a combination supported by the device | ||
// Use | ||
// v4l2-ctl --device=0 --list-formats-ext | ||
// to discover them, | ||
// or guvcview | ||
std::string pixel_format_name_; | ||
int image_width_; | ||
int image_height_; | ||
int framerate_; | ||
|
||
// TODO(lucasw) use v4l2ucp for these? | ||
// int exposure_, brightness_, contrast_, saturation_, sharpness_, focus_, | ||
// white_balance_, gain_; | ||
// bool autofocus_, autoexposure_, auto_white_balance_; | ||
|
||
std::string camera_name_; | ||
std::string camera_info_url_; | ||
std::shared_ptr<camera_info_manager::CameraInfoManager> cinfo_; | ||
|
||
rclcpp::TimerBase::SharedPtr timer_; | ||
|
||
rclcpp::Service<std_srvs::srv::SetBool>::SharedPtr service_capture_; | ||
}; | ||
} // namespace usb_cam |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.