Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: rosserial_mbed_lib mbed Servo
Diff: tests/array_test.cpp
- Revision:
- 0:06fc856e99ca
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/array_test.cpp Fri Aug 19 09:06:16 2011 +0000
@@ -0,0 +1,47 @@
+//#define COMPILE_ARRAY_CODE_RSOSSERIAL
+#ifdef COMPILE_ARRAY_CODE_RSOSSERIAL
+
+/*
+ * rosserial::geometry_msgs::PoseArray Test
+ * Sums an array, publishes sum
+ */
+#include "mbed.h"
+#include <ros.h>
+#include <geometry_msgs/Pose.h>
+#include <geometry_msgs/PoseArray.h>
+
+
+ros::NodeHandle nh;
+
+bool set_;
+DigitalOut myled(LED1);
+
+geometry_msgs::Pose sum_msg;
+ros::Publisher p("sum", &sum_msg);
+
+void messageCb(const geometry_msgs::PoseArray& msg) {
+ sum_msg.position.x = 0;
+ sum_msg.position.y = 0;
+ sum_msg.position.z = 0;
+ for (int i = 0; i < msg.poses_length; i++) {
+ sum_msg.position.x += msg.poses[i].position.x;
+ sum_msg.position.y += msg.poses[i].position.y;
+ sum_msg.position.z += msg.poses[i].position.z;
+ }
+ myled = !myled; // blink the led
+}
+
+ros::Subscriber<geometry_msgs::PoseArray> s("poses",messageCb);
+
+int main() {
+ nh.initNode();
+ nh.subscribe(s);
+ nh.advertise(p);
+
+ while (1) {
+ p.publish(&sum_msg);
+ nh.spinOnce();
+ wait_ms(10);
+ }
+}
+#endif
\ No newline at end of file