ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ROS on python

asked 2016-05-05 18:15:07 -0500

Emilien gravatar image

hi, i wrote my program of node with python and i receive an error of syntaxe. can you help me please? my program:

 security_distance = 25
    if d1 < security_distance:
        if (d0 < security_distance) and (d2 < security_distance):
            moteur_msg = 0
            rospy.loginfo(moteur_msg)
            pub_moteur.publish(moteur_msg)
            time.sleep(2)
            if d0 > d2:
                servo_msg = 2
                rospy.loginfo(servo_msg)
                pub_servo.publish(servo_msg)
            else:
                servo_msg = 3
                rospy.loginfo(servo_msg)
                pub_servo.publish(servo_msg)

        elif (d0 < security_distance) and (d2 > security_distance):
            moteur_msg = 3
            rospy.loginfo(moteur_msg)
            pub_moteur.publish(moteur_msg
        elif (d0 > security_distance) and (d2 < security_distance):
            moteur_msg = 2
            rospy.loginfo(moteur_msg)
            ub_moteur.publish(moteur_msg
        elif (d0 > security_distance) and (d2 > security_distance):                                      
            if d0 > d2:
                servo_msg = 2
                rospy.loginfo(servo_msg)
                pub_servo.publish(servo_msg)
            else:
                servo_msg = 3
                rospy.loginfo(servo_msg)
                pub_servo.publish(servo_msg)
    else:                                             
        moteur_msg = 3
        rospy.loginfo(moteur_msg)
        pub_moteur.publish(moteur_msg)

i receive this error:

pi@raspberrypi:~ $ rosrun control control.py
  File "/home/pi/catkin_ws/src/control/script/control.py", line 82
    elif (d0 > security_distance) and (d2 < security_distance):
       ^
SyntaxError: invalid syntax
edit retag flag offensive close merge delete

Comments

The error is there to give you a hint, look at line 81

Mehdi. gravatar image Mehdi.  ( 2016-05-06 04:23:59 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-05-05 19:00:51 -0500

robustify gravatar image

You're missing a close parenthesis on this line:

ub_moteur.publish(moteur_msg
edit flag offensive delete link more

Comments

Same thing four lines higher as well.

robustify gravatar image robustify  ( 2016-05-05 19:01:58 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-05-05 18:15:07 -0500

Seen: 275 times

Last updated: May 05 '16