Closed mskimP closed 4 years ago
We had luck with using forms of IPC like message queues and shared memory to communicate whatever we wanted. You'll have to include the flag --ipc="host" \
in the docker run in dev_start.sh to get IPC working between docker and host.
We had luck with using forms of IPC like message queues and shared memory to communicate whatever we wanted. You'll have to include the flag
--ipc="host" \
in the docker run in dev_start.sh to get IPC working between docker and host.
@DevMohamedMI Thank you for replying my question.
I had done with your suggestion.
(change the dev_start.sh)
I was send the messages in the Windows 10(Matlab) to Ubuntu docker(Apollo).
But still can't receive the messages in Ubuntu docker.
---ADD try I tried removed option that '--net host'.
(Remove the '--net host')
If I try that I cannot connect dreamveiw and rosmaster.
I know that there must be the '--net host' to open all docker ports or '-p' option to open dreamveiw(8888), rosmaster(11311), rosbridge(9090).
This is the firewall that outside of the docker.
(Result of 'ufw status' command)
For your Apollo 3.0 purposes, I'd point you to Issue 4892
For your Apollo 3.0 purposes, I'd point you to Issue 4892
Thanks, I think the problem here is that nodes can be connected, but no msg transmission. I have the similar problem with this. +_+
I solved the problem of connection.
I changed the dev_start.sh file.
In that file, there is a lines of this command around 297 line.
${DOCKER_CMD} run -it \ -d \ --privileged \ --name $APOLLO_DEV \ ${MAP_VOLUME_CONF} \ --volumes-from ${LOCALIZATION_VOLUME} \ --volumes-from ${YOLO3D_VOLUME} \ -e DISPLAY=$display \ -e DOCKER_USER=$USER \ -e USER=$USER \ -e DOCKER_USER_ID=$USER_ID \ -e DOCKER_GRP="$GRP" \ -e DOCKER_GRP_ID=$GRP_ID \ -e DOCKER_IMG=$IMG \ -e USE_GPU=$USE_GPU \ $(local_volumes) \ --net host \ -w /apollo \ --add-host in_dev_docker:127.0.0.1 \ --add-host ${LOCAL_HOST}:127.0.0.1 \ --hostname in_dev_docker \ --shm-size 2G \ --pid=host \ -v /dev/null:/dev/raw1394 \ $IMG \ /bin/bash
And I added the two lines.
-e ROS_DOMAIN_ID=$ROS_DOMAIN_ID \ -e ROS_IP= ***.***.***.***
The '...' is Ubuntu IP.
And there is a connection between of it.
Ths is the Publisher of Simulink in Windows.
This is the subscriber in Ubuntu docker.
The connection is done.
But the message that I made(/apollo/sensor/gnss/odometry) cannot sending.
This is the simulink that I made.
What is the wrong with it?
I solved the problem of connection.
I changed the dev_start.sh file.
In that file, there is a lines of this command around 297 line.
${DOCKER_CMD} run -it \ -d \ --privileged \ --name $APOLLO_DEV \ ${MAP_VOLUME_CONF} \ --volumes-from ${LOCALIZATION_VOLUME} \ --volumes-from ${YOLO3D_VOLUME} \ -e DISPLAY=$display \ -e DOCKER_USER=$USER \ -e USER=$USER \ -e DOCKER_USER_ID=$USER_ID \ -e DOCKER_GRP="$GRP" \ -e DOCKER_GRP_ID=$GRP_ID \ -e DOCKER_IMG=$IMG \ -e USE_GPU=$USE_GPU \ $(local_volumes) \ --net host \ -w /apollo \ --add-host in_dev_docker:127.0.0.1 \ --add-host ${LOCAL_HOST}:127.0.0.1 \ --hostname in_dev_docker \ --shm-size 2G \ --pid=host \ -v /dev/null:/dev/raw1394 \ $IMG \ /bin/bash
And I added the two lines.
-e ROS_DOMAIN_ID=$ROS_DOMAIN_ID \ -e ROS_IP= ***.***.***.***
The '...' is Ubuntu IP.
And there is a connection between of it.
Ths is the Publisher of Simulink in Windows.
This is the subscriber in Ubuntu docker.
The connection is done.
But the message that I made(/apollo/sensor/gnss/odometry) cannot sending.
This is the simulink that I made.
What is the wrong with it?
Hi, guys, I met the same problem. Do you resolve this problem?
Did you resolve this problem? @mskimP
@wijdim Yes. Just using protobuf. First, I using PreScan to make scene, and change to ROS. Second, Change ROS data to protobuf. Third, insert protobuf data to Apollo. You should change ROS data to protobuf.
@MinseokKim-KR didn't you make changes on dev_start.sh file?
@MinseokKim-KR How did you insert protobuf data to Apollo?
@wijdim I changed dev_start.sh and make python file to change ROS to protobuf. I run python file in docker. If I find that python file, I will mention to you.
@MinseokKim-KR what changes did you make in dev_start.sh? I m actually working on a new version for apollo using Cyber RT unstead of ROS but I'm still interested to know how did you insert the proto in apollo? Thank you
@wijdim I found the code!! I changed "${DOCKER_CMD} run -it ~~ " part in "dev_start.sh".
${DOCKER_CMD} run -it \
-d \
--privileged \
--name apollo_dev \
${MAP_VOLUME_CONF} \
--volumes-from ${LOCALIZATION_VOLUME} \
--volumes-from ${YOLO3D_VOLUME} \
-e DISPLAY=$display \
-e DOCKER_USER=$USER \
-e USER=$USER \
-e DOCKER_USER_ID=$USER_ID \
-e DOCKER_GRP="$GRP" \
-e DOCKER_GRP_ID=$GRP_ID \
-e DOCKER_IMG=$IMG \
-e ROS_DOMAIN_ID=$ROS_DOMAIN_ID \
$(local_volumes) \
--net host \
-w /apollo \
--add-host in_dev_docker:127.0.0.1 \
--add-host ${LOCAL_HOST}:127.0.0.1 \
--hostname in_dev_docker \
--shm-size 2G \
--pid=host \
-v /dev/null:/dev/raw1394 \
-e ROS_MASTER_URI=http://localhost:11311 \
-e ROS_IP=***.***.***.***\ -> my privacy IP
$IMG \
/bin/bash
And I used "protobuf-to-dict" and "dict-to-protobuf" install using pip. I change ROS -> dict -> protobuf. I made apollo_topic.txt and apollo_type.txt that minimum topic for run apollo/control.
This is the ROS graph. Dark Blue is ROS message that received from PreScan. Green is converted to dict. Light Blue is Protobuf that changed from dict(green). And the Red Box is apollo/control that I want.
@MinseokKim-KR Thank you for your answer, concerning the changes made in dev_start.sh you added two lines about ROS_IP and ROS_DOMAIN_ID comparing to the original file? You converted from dict to proto then how did you add your proto file in apollo?
@wijdim
Thank you for your answer, concerning the changes made in dev_start.sh you added two lines about ROS_IP and ROS_DOMAIN_ID comparing to the original file?
Yes! right
You converted from dict to proto then how did you add your proto file in apollo?
Into the docker, and just run python file.
@MinseokKim-KR where can i find the python file?
@wijdim Sorry for open python file. Because it was proceed as an industrial project. So I just open part of that code. start_message_to_pb.py
#['./run_pb.py', 'pb_msgs', 'PerceptionObstacles', 'apollo/perception/obstacles', '/my_msgs/PerceptionObstacles', 'my_msgs']
thread_input_str = 'python ./run_pb.py %s %s %s %s %s' %(result_Name, str(result_Type), str(result_Topic), str(sub_Name), msg_type)
thread_ = threading.Thread(target=thread_func, args=(thread_input_str,))
print("thread : ", thread_input_str)
thread_.start()
run_pb.py
import message_converter
import dict_to_protobuf as dp
import rospy
import sys
def talker(data):
# pub = rospy.Publisher('/apollo/sensor/gnss/odometry', pb_msgs.msg.Gps, queue_size = 10)
pub = rospy.Publisher(sys.argv[3], eval(sys.argv[1]+'.msg.'+sys.argv[2]), queue_size=10)
rate = rospy.Rate(10)
if not rospy.is_shutdown():
msg=eval(sys.argv[1]+'.msg.'+sys.argv[2]+'()')
dictionary=message_converter.convert_ros_message_to_dictionary(data)
dp.dict_to_protobuf(dictionary, msg)
pub.publish(msg)
rate.sleep()
def listener():
rospy.Subscriber(sys.argv[4], eval(sys.argv[5]+'.msg.'+sys.argv[2]), talker)
if __name__ == '__main__':
print(sys.argv)
print(sys.argv[1])
print(sys.argv[2])
print(sys.argv[3])
print(sys.argv[4])
try:
rospy.init_node("Node", anonymous=True)
listener()
rospy.spin()
except rospy.ROSInterruptException:
pass
@MinseokKim-KR Thank you for your answer. It is very helpful even if it doesn't solve my problem since I m working on new Version for Apollo so no more using ROS but unstead there is Cyber RT message. and the goal was to assure a communication with the docker container from outside (host machine) using netcat to send data in the server inside of gnss module, but still fail to receive data even if i made the same changes for dev_start.sh Any suggestion about this issue will be appreciated, Thank you.
@wijdim
I was suffering that communicate with inside-docker and outside-docker. The project was 3 years ago, so I cannot remember all things. But to communicate with in&out side docker, you should add --net host \
, --pid=host \
, -e ROS_MASTER_URI=http://localhost:11311
, -e ROS_IP=***.***.***.***\ -> my privacy IP
. That's what I remember now. Sorry for not being of much help.
${DOCKER_CMD} run -it \
-d \
--privileged \
--name apollo_dev \
${MAP_VOLUME_CONF} \
--volumes-from ${LOCALIZATION_VOLUME} \
--volumes-from ${YOLO3D_VOLUME} \
-e DISPLAY=$display \
-e DOCKER_USER=$USER \
-e USER=$USER \
-e DOCKER_USER_ID=$USER_ID \
-e DOCKER_GRP="$GRP" \
-e DOCKER_GRP_ID=$GRP_ID \
-e DOCKER_IMG=$IMG \
-e ROS_DOMAIN_ID=$ROS_DOMAIN_ID \
$(local_volumes) \
--net host \
-w /apollo \
--add-host in_dev_docker:127.0.0.1 \
--add-host ${LOCAL_HOST}:127.0.0.1 \
--hostname in_dev_docker \
--shm-size 2G \
--pid=host \
-v /dev/null:/dev/raw1394 \
-e ROS_MASTER_URI=http://localhost:11311 \
-e ROS_IP=***.***.***.***\ -> my privacy IP
$IMG \
/bin/bash
@wijdim Sorry for open python file. Because it was proceed as an industrial project. So I just open part of that code. start_message_to_pb.py
#['./run_pb.py', 'pb_msgs', 'PerceptionObstacles', 'apollo/perception/obstacles', '/my_msgs/PerceptionObstacles', 'my_msgs'] thread_input_str = 'python ./run_pb.py %s %s %s %s %s' %(result_Name, str(result_Type), str(result_Topic), str(sub_Name), msg_type) thread_ = threading.Thread(target=thread_func, args=(thread_input_str,)) print("thread : ", thread_input_str) thread_.start()
run_pb.py
import message_converter import dict_to_protobuf as dp import rospy import sys def talker(data): # pub = rospy.Publisher('/apollo/sensor/gnss/odometry', pb_msgs.msg.Gps, queue_size = 10) pub = rospy.Publisher(sys.argv[3], eval(sys.argv[1]+'.msg.'+sys.argv[2]), queue_size=10) rate = rospy.Rate(10) if not rospy.is_shutdown(): msg=eval(sys.argv[1]+'.msg.'+sys.argv[2]+'()') dictionary=message_converter.convert_ros_message_to_dictionary(data) dp.dict_to_protobuf(dictionary, msg) pub.publish(msg) rate.sleep() def listener(): rospy.Subscriber(sys.argv[4], eval(sys.argv[5]+'.msg.'+sys.argv[2]), talker) if __name__ == '__main__': print(sys.argv) print(sys.argv[1]) print(sys.argv[2]) print(sys.argv[3]) print(sys.argv[4]) try: rospy.init_node("Node", anonymous=True) listener() rospy.spin() except rospy.ROSInterruptException: pass
Hi @MinseokKim-KR Concerning the "run_pb.py" file that helped you to integrate proto file inside apollo, you used "pub = rospy.Publisher(sys.argv[3], eval(sys.argv[1]+'.msg.'+sys.argv[2]), queue_size=10)" to create the publisher. Can you please share with me the content of (sys.argv[])?? Thank you
System information
Steps to reproduce the issue:
I have tried that connect with Ubuntu's ROS and Matlab(Windows).
It works find. But in docker Apollo, cannot connect to Matlab(Windows).
I open the roscore using Apollo.
And found the rosnode in 'rqt_graph'.
This is the Simulink in Windows10 (top : publisher, bottom : subscriber). (The data is test data in Apollo demo).
But when I trying to rostopic echo in Ubuntu, there is no replying in it.
I tried to open port in docker using '-p' option.
But there is nothing port in docker.
What did I wrong?
And how can I check the data in rostopic?
And how can I open the port in docker to communicate with Simulator(Windows)?
Thank you.