Skip to content
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

juliacall: Can not use @show and println in the callback function of ros.py #484

Open
wly2014 opened this issue Mar 21, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@wly2014
Copy link

wly2014 commented Mar 21, 2024

Affects: JuliaCall

Describe the bug
When I use @show and println in the julia function which is called by the callback function of ros.py, the program becomes unresponsive.

Python test.py:

#!/usr/bin/env python3
#coding: utf-8

import rospy
import time
import numpy as np
from std_msgs.msg import Char

from juliacall import Main as jl


def solve(data):
    rospy.loginfo("==================== Start ... ======================")
    
    xs = jl.call_ext()
    
    print("len(xs) = ", len(xs))


def Solver_Interface():
    rospy.init_node('solver_interface', anonymous = True)

    rospy.Subscriber('test', Char, solve, queue_size=1)    # can not callback successfully.
    
    jl.include("./test.jl")

    time.sleep(1.0)
    solve(None)   # can call successfully.

    rospy.spin()

Solver_Interface()

Julia test.jl:

function call_ext()

    @show "Hello"
    @show "World"
    return [1,2,3]
end

Run the Python python test.py in a terminal.
Run rostopic pub /test std_msgs/Char "data: 0" in a new terminal to do ros subscriber's callback.
The text printed in the terminal is:

$ python test.py 
[INFO] [1711030056.700593]: ==================== Start ... ======================
"Hello" = "Hello"
"World" = "World"
len(xs) =  3
[INFO] [1711030086.854242]: ==================== Start ... ======================
"Hello" = 

Finally, Hello is not printed completely, the this terminal becomes unresponsive.

@wly2014 wly2014 added the bug Something isn't working label Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant