-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Subscribe to an image and print out msg fields, but not manipulating …
…the data yet.
- Loading branch information
Showing
5 changed files
with
79 additions
and
8 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
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,15 @@ | ||
<?xml version="1.0"?> | ||
<launch> | ||
|
||
<node pkg="image_publisher" type="image_publisher" | ||
name="image_pub" output="screen" | ||
args="$(find image_manip)/data/mosaic.png" > | ||
<param name="publish_rate" value="1.0"/> | ||
</node> | ||
|
||
<node pkg="rsc_test" type="image_sub_pub" | ||
name="image_sub_pub" output="screen" > | ||
<remap from="image_in" to="image_pub/image_raw" /> | ||
</node> | ||
|
||
</launch> |
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Subscribe to an image topic and publish a modified version of the image in response. | ||
// For now modify the image directly in the callback and publish that output, | ||
// but later maybe store the image and then modify it in a separate thread. | ||
// | ||
|
||
use rosrust_msg::sensor_msgs::Image; | ||
use rosrust::api::raii as ros; | ||
// use std::sync::Mutex; | ||
|
||
struct ImageSubPub { | ||
_image_sub: ros::Subscriber, // <Image> | ||
// image_pub: ros::Publisher<Image>, | ||
// TODO(lucasw) add a variable float to scale the incoming image with | ||
// fr : f32, | ||
} | ||
|
||
|
||
impl ImageSubPub { | ||
fn new() -> Self{ | ||
rosrust::ros_info!("new ImageSubPub"); | ||
let image_pub = rosrust::publish("image_out", 4).unwrap(); | ||
let fr = 2.5; | ||
|
||
let image_callback = { | ||
move |msg: Image| { | ||
rosrust::ros_info!("preferred callback {} {} {} {} {}", | ||
msg.width, msg.height, msg.data.len(), msg.encoding, | ||
fr); | ||
image_pub.send(msg).unwrap(); | ||
} | ||
}; | ||
|
||
let _image_sub = rosrust::subscribe("image_in", 4, image_callback).unwrap(); | ||
|
||
let image_sub_pub = Self { | ||
_image_sub, | ||
// image_pub, | ||
// fr, | ||
}; | ||
|
||
image_sub_pub | ||
} | ||
} | ||
|
||
fn main() { | ||
rosrust::init("image_sub_pub_rs"); | ||
let _image_sub_pub = ImageSubPub::new(); | ||
rosrust::spin(); | ||
} |
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,2 @@ | ||
// Subscribe to an image topic and publish a modified version of the image in response. | ||
// For now modify the image directly in the callback and publish that output. |