-
Notifications
You must be signed in to change notification settings - Fork 128
portenta h7 m7 ethernet support #852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pablogs9
merged 10 commits into
micro-ROS:galactic
from
Jenifen:feature/ethernet_transport_portenta_h7_m7
Mar 21, 2022
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d32519f
add ethernet trasport for PORTENTA_H7_M7 in uros header
Jenifen 064988b
add ethernet trasport for PORTENTA_H7_M7 cpp
Jenifen 218653a
add ethernet publish example
Jenifen 86549ef
correct error msg add
Jenifen f6f87e2
add comment ip
Jenifen a4e3e6f
change topic_name, namespace
Jenifen 505d6ab
update mac address
Jenifen ab12062
remove comment
Jenifen 7c1771f
remove not used headers
Jenifen 9a64cf3
fix error condition
Jenifen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
examples/micro-ros_publisher_ethernet/micro-ros_publisher_ethernet.ino
This file contains hidden or 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,76 @@ | ||
#include <micro_ros_arduino.h> | ||
|
||
#include <stdio.h> | ||
#include <rcl/rcl.h> | ||
#include <rcl/error_handling.h> | ||
#include <rclc/rclc.h> | ||
#include <rclc/executor.h> | ||
#include <std_msgs/msg/int32.h> | ||
|
||
#if !defined(TARGET_STM32F4) && !defined(ARDUINO_TEENSY41) && !defined(TARGET_PORTENTA_H7_M7) | ||
#error This example is only avaible for Arduino Portenta, Arduino Teensy41 and STM32F4 | ||
#endif | ||
|
||
rcl_publisher_t publisher; | ||
std_msgs__msg__Int32 msg; | ||
rclc_support_t support; | ||
rcl_allocator_t allocator; | ||
rcl_node_t node; | ||
|
||
#define LED_PIN 13 | ||
|
||
#define RCCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){error_loop();}} | ||
#define RCSOFTCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){}} | ||
|
||
|
||
|
||
void error_loop(){ | ||
while(1){ | ||
digitalWrite(LED_PIN, !digitalRead(LED_PIN)); | ||
delay(100); | ||
} | ||
} | ||
|
||
void timer_callback(rcl_timer_t * timer, int64_t last_call_time) | ||
{ | ||
RCLC_UNUSED(last_call_time); | ||
if (timer != NULL) { | ||
RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL)); | ||
msg.data++; | ||
} | ||
} | ||
|
||
void setup() { | ||
byte arduino_mac[] = { 0xAA, 0xBB, 0xCC, 0xEE, 0xDD, 0xFF }; | ||
IPAddress arduino_ip(192, 168, 1, 177); | ||
IPAddress agent_ip(192, 168, 1, 113); | ||
set_microros_native_ethernet_udp_transports(arduino_mac, arduino_ip, agent_ip, 9999); | ||
|
||
pinMode(LED_PIN, OUTPUT); | ||
digitalWrite(LED_PIN, HIGH); | ||
|
||
delay(2000); | ||
|
||
allocator = rcl_get_default_allocator(); | ||
|
||
//create init_options | ||
RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); | ||
|
||
// create node | ||
RCCHECK(rclc_node_init_default(&node, "micro_ros_arduino_ethernet_node", "namespace", &support)); | ||
|
||
// create publisher | ||
RCCHECK(rclc_publisher_init_best_effort( | ||
&publisher, | ||
&node, | ||
ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32), | ||
"topic_name")); | ||
|
||
msg.data = 0; | ||
} | ||
|
||
void loop() { | ||
RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL)); | ||
msg.data++; | ||
delay(100); | ||
} |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.