jsk-ros-pkg / geneus

3 stars 16 forks source link

[generate.py] Fix bug of write_constants #59

Closed taichiH closed 5 years ago

taichiH commented 5 years ago

Now, we cannot get a default boolean rosmsg value.

For example, if create test_msg.msg message in eus_test_msg package like below,

bool flag
bool FLAG=1

I always get nil as a default value even though I set FLAG=1.

1.irteusgl$ ros::load-ros-manifest "eus_msg_test"           
t                                                                               
2.irteusgl$ setq msg (instance eus_msg_test::test_msg :init)                    
#<eus_msg_test::test_msg #X6396318>                                                                                                                        
3.irteusgl$ send msg :flag eus_msg_test::test_msg::*flag*                       
nil

The cause of this problem is this line. https://github.com/jsk-ros-pkg/geneus/blob/a97101f8ce8aa95bbaa9dee1586bcfccc9abf125/src/geneus/generate.py#L673

This line's "True" should not be string value.

"t" if c.val == "True" else "nil"

after fix like below, I got correct boolean default value.

"t" if c.val == True else "nil"
k-okada commented 5 years ago

Thanks 1) can you create test code for this issues? 2) can you check rospy/roscpp behavior?

2018年12月3日(月) 16:59 Taichi Higashide notifications@github.com:

Now, we cannot get a default boolean rosmsg value.

For example, if create test_msg.msg message in eus_test_msg package like below,

bool flag bool FLAG=1

I always get nil as a default value even though I set FLAG=1.

1.irteusgl$ ros::load-ros-manifest "eus_msg_test" t 2.irteusgl$ setq msg (instance eus_msg_test::test_msg :init)

<eus_msg_test::test_msg #X6396318>

3.irteusgl$ send msg :flag eus_msg_test::test_msg::flag nil

The cause of this problem is this line.

geneus/src/geneus/generate.py https://github.com/jsk-ros-pkg/geneus/blob/a97101f8ce8aa95bbaa9dee1586bcfccc9abf125/src/geneus/generate.py#L673

Line 673 in a97101f http:///jsk-ros-pkg/geneus/commit/a97101f8ce8aa95bbaa9dee1586bcfccc9abf125 s.write('(defconstant %s::%s::%s %s)'%(spec.package, spec.actual_name, c.name.upper(), "t" if c.val == "True" else "nil"))

This line's "True" should not be string value.

"t" if c.val == "True" else "nil"

after fix like below, I got correct boolean default value.

"t" if c.val == True else "nil"


You can view, comment on, or merge this pull request online at:

https://github.com/jsk-ros-pkg/geneus/pull/59 Commit Summary

  • fix bug of write_constants

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jsk-ros-pkg/geneus/pull/59, or mute the thread https://github.com/notifications/unsubscribe-auth/AAeG3EWjNXzMf_WVbZMSi-kdgyQyyvznks5u1NnugaJpZM4Y-Dlf .

--

◉ Kei Okada

taichiH commented 5 years ago

@k-okada 1) I added test code. 2) I checked roscpp and rospy behavior, as a result, I correctly got True from both.

taichiH commented 5 years ago

@k-okada Maybe I got mistake. Is it correct to add geneus test in https://github.com/jsk-ros-pkg/jsk_roseus/blob/master/roseus/test/test-geneus.l ?

k-okada commented 5 years ago

@taichiH thank you for improvement. your patch has been merged via #62