-
Notifications
You must be signed in to change notification settings - Fork 42
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
Lifecycle service callback isuue #300
Comments
@Cryoschrome does a normal subscriber callback work on your platform? |
Thanks for the reply @JanStaschulat! |
Some points:
Edit: also |
Compared to the lifecycle example the On your setup, you use two functions. Try using global variables, i.e. for |
Thanks, @JanStaschulat. Please @Cryoschrome could you try and report? If it still does not work, I will try to replicate it here. |
Thanks @pablogs9 and @JanStaschulat! |
So, I have made both Updated Code#include <stdio.h>
#include <unistd.h>
#include <ArduinoJson.h>
#include <SPI.h>
#include <SD.h>
#include <TeensyStep.h>
#include <micro_ros_platformio.h>
#include <rclc/rclc.h>
#include <rclc/executor.h>
#include <rclc_parameter/rclc_parameter.h>
#include <rcl/error_handling.h>
#include "rclc_lifecycle/rclc_lifecycle.h"
#include <lifecycle_msgs/msg/transition_description.h>
#include <lifecycle_msgs/msg/transition_event.h>
#include <lifecycle_msgs/srv/change_state.h>
#include <lifecycle_msgs/srv/get_state.h>
#include <lifecycle_msgs/srv/get_available_states.h>
#include <lifecycle_msgs/srv/get_available_transitions.h>
#include <rcl_interfaces/msg/log.h>
//define motor pins
#define STEP 2
#define DIR 3
#define ENABLE 4
#define ALARM 5
#define BRAKE 6
#define RCCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){errorLoop();}}
#define RCSOFTCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){}}
void errorLoop()
{
while (1) {
digitalWrite(13, !digitalRead(13));
delay(100);
}
}
rcl_node_t node;
rclc_lifecycle_node_t lifecycleNode;
rclc_lifecycle_service_context_t context;
rcl_lifecycle_state_machine_t stateMachine_;
rclc_support_t support;
rcl_allocator_t allocator;
rclc_executor_t executor;
rclc_parameter_server_t parameterServer;
static const char * jointID = "j0001";
//create motor control objects
Stepper motor(STEP, DIR);
StepControl stepMotor;
RotateControl rotateMotor;
rcl_ret_t onJointConfigure()
{
for(int i=0; i<4; i++)
{
digitalWrite(13, !digitalRead(13));
delay(500);
}
return RCL_RET_OK;
}
rcl_ret_t onJointActivate()
{
digitalWrite(13, HIGH);
return RCL_RET_OK;
}
rcl_ret_t onJointDeactivate()
{
digitalWrite(13, LOW);
return RCL_RET_OK;
}
rcl_ret_t onJointCleanup()
{
for(int i=0; i<6; i++)
{
digitalWrite(13, !digitalRead(13));
delay(500);
}
return RCL_RET_OK;
}
void setup() {
Serial.begin(115200);
pinMode(13, OUTPUT);
set_microros_serial_transports(Serial);
delay(2000);
allocator = rcl_get_default_allocator();
rclc_support_init(&support, 0, NULL, &allocator);
//Initialise node and parameter server
RCCHECK(rclc_node_init_default(&node, jointID, "", &support));
stateMachine_ = rcl_lifecycle_get_zero_initialized_state_machine();
//Make the node to lifecycle node
RCCHECK(rclc_make_node_a_lifecycle_node(
&lifecycleNode,
&node,
&stateMachine_,
&allocator,
true
));
//initialise executor
RCCHECK(rclc_executor_init(&executor, &support.context, 6, &allocator));
context.lifecycle_node = &lifecycleNode;
RCCHECK(rclc_lifecycle_init_get_state_server(&context, &executor));
RCCHECK(rclc_lifecycle_init_get_available_states_server(&context, &executor));
RCCHECK(rclc_lifecycle_init_change_state_server(&context, &executor));
RCCHECK(rclc_lifecycle_register_on_configure(&lifecycleNode, &onJointConfigure));
RCCHECK(rclc_lifecycle_register_on_activate(&lifecycleNode, &onJointActivate));
RCCHECK(rclc_lifecycle_register_on_deactivate(&lifecycleNode, &onJointDeactivate));
RCCHECK(rclc_lifecycle_register_on_cleanup(&lifecycleNode, &onJointCleanup));
}
void loop() {
RCSOFTCHECK(rclc_executor_spin_some(&executor, RCL_MS_TO_NS(100)));
} Agent log
|
Your micro-ROS client is only creating a Maybe this is related to the colcon meta configuration issue with platform.io: micro-ROS/micro_ros_platformio#33 In order to check this, could you find |
I checked the |
Ok, the colcon metas are misbehaving. You need to create a user meta (instead of modifying the provided colcon_lowmem.meta) as explained here: https://github.com/micro-ROS/micro_ros_platformio#other-configuration In order to make this "user meta" work, please use this branch: micro-ROS/micro_ros_platformio#34 Just note that this branch is not working in platformio 6.0.2, so make sure that you have an older version. Also make sure that you start in a clean environment, with no micro-ROS built. Sorry for this workaround, but we are just working in this fix right now. If you could provide feedback it would be nice. |
Any update on this? |
Sorry, didn't get the time to work on this. Agent log
|
Which is the output of |
|
Service is up & running. @JanStaschulat have you tested lifecycle in micro-ROS w/ Micro XRCE-DDS rmw? is the inner memory for types being correctly initialized and so on? |
Just checked, we used publisher, timer, rclc_parameter, and micro_ros_diagnostics on ESP32 with FreeRTOS in the final OFERA demo. But not lifecycle. |
@norro Has lifecycle been tested in micro-ROS with Micro XRCE-DDS rmw? |
Hi,
I am trying to create a lifecycle node using micro_ros_platformio.
Code (main.cpp)
colcon_lowmem.meta
The callback for the lifecycle services does not get called.
Output
Expected behavior
Response is given is by the server
Actual behavior
No response is given by the server
Any help is appreciated
Thank you!
The text was updated successfully, but these errors were encountered: