flynneva / grbl_ros

ROS2 node for interfacing with a GRBL device
https://flynneva.github.io/grbl_ros/
MIT License
17 stars 11 forks source link

Unlock/ClearAlarm grbl #106

Closed liushuya7 closed 2 years ago

liushuya7 commented 3 years ago

Hi Evan,

Thanks for creating this package. I was able to connect to my grbl. However, I could do nothing more from that point on. My speculation is that I need to unlock grbl first since grbl initializes in Alarm state. Although I found clearAlarm(), I didn't see any ros service/action to trigger that callback.

github-actions[bot] commented 3 years ago

Thank you for creating your first issue on this repo! Give me some time to review and respond to your problem.

flynneva commented 3 years ago

hi @liushuya7, yeah unfortunately i havent added a specific callback/service for that yet. but you can send the unlock command to it using the send service provided, just use what is shown in the clearAlarm function:

$X i think

flynneva commented 3 years ago

i havent decided what the best way to do this is since it is hard to determine if the user wants to unlock the machine or not.

flynneva commented 3 years ago

you can call services from the terminal by the way: https://docs.ros.org/en/foxy/Tutorials/Services/Understanding-ROS2-Services.html#ros2-service-call

liushuya7 commented 3 years ago

I tried calling service that way first with ros2 action send_goal /cnc_001/send_gcode_cmd '{command: $X}' then with ros2 service call /cnc_001/unlock grbl_msgs/srv/Unlock with my newly defined service type Unlock, but somehow it stuck at service_request, nothing seems happening.

flynneva commented 3 years ago

you might need to use a backslash so the $ goes through..thats why in the clearAlarm function there is a backslash:

ros2 action info /cnc_001/send_gcode_cmd '{command: \$X}'
liushuya7 commented 3 years ago

Hi @flynneva ,

I tried ros2 action send_goal /cnc_001/send_gcode_cmd grbl_msgs/action/SendGcodeCmd '{command: \$X}'. Now on the sending terminal I got:

Waiting for an action server to become available...
Sending goal:
     command: \$X

Goal accepted with ID: f64ce19ca8c945c39f8c455763f18b7a

Result:
    success: false

Goal finished with status: ABORTED

On the grbl node terminal, I got:

[grbl_node] [ERROR] [1615442045.956277731] [cnc_001]: Error raised in execute callback: 'grbl_node' object has no attribute 'decode_error'
[grbl_node] [WARN] [1615442045.956782143] [cnc_001]: Goal state not set, assuming aborted. Goal ID: [ 44 116 242 153 159 145  66 169 190 187 147  48   0 197  21 226]
[grbl_node] [INFO] [1615442060.117807715] [cnc_001]: [ \$X ] error:9
flynneva commented 3 years ago

Just updated the README with some instructions on how to clear the alarm. Maybe check it out and let me know if that answers your question?

flynneva commented 3 years ago

Also maybe double check your parameters in the grbl_ros/config/cnc001.yaml file. I updated it so now to be more generic for whatever you call your node

liushuya7 commented 3 years ago

Great, thanks!

flynneva commented 3 years ago

@liushuya7 were you able to solve your problem? I can add this to my "todos" since I plan on picking this package up again in over the next few weeks

liushuya7 commented 3 years ago

Hi @flynneva , Sorry, I haven't been using your package. I created grbl_ros2_gui, which based on cn5X. But it definitely would be interesting to combine our code to provide the best performance. Joshua