Closed thatting closed 6 years ago
Here is the output in my terminal: ..... robond@udacity:~$ roslaunch quad_controller position_controller.launch ... logging to /home/robond/.ros/log/878fd22a-8fd2-11e7-a2e7-000c29100b05/roslaunch-udacity-16151.log Checking log directory for disk usage. This may take awhile. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://192.168.19.129:46513/
PARAMETERS
NODES / attitude_controller (quad_controller/attitude_controller_node) position_controller (quad_controller/position_controller_node) quaternion_to_euler_node (quad_controller/quaternion_to_euler_node) rqt_reconfigure (rqt_reconfigure/rqt_reconfigure)
ROS_MASTER_URI=http://localhost:11311
core service [/rosout] found process[position_controller-1]: started with pid [16170] process[attitude_controller-2]: started with pid [16171] process[quaternion_to_euler_node-3]: started with pid [16172] process[rqt_reconfigure-4]: started with pid [16173] [INFO] [1504352060.975659]: Attitude controller config changed! [ERROR] [1504352061.129975]: bad callback: <bound method PositionControllerNode.pose_callback of <main.PositionControllerNode instance at 0x7f2de875fe18>> Traceback (most recent call last): File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback cb(msg) File "/home/robond/catkin_ws/src/RoboND-Controls-Lab/quad_controller/scripts/position_controller_node", line 116, in pose_callback if self.counter >= 10 or not self.first_posereceived: AttributeError: PositionControllerNode instance has no attribute 'counter'
[INFO] [1504352061.136584]: Position controller node config changed! [ERROR] [1504352061.158853]: bad callback: <bound method PositionControllerNode.pose_callback of <main.PositionControllerNode instance at 0x7f2de875fe18>> Traceback (most recent call last): File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback cb(msg) File "/home/robond/catkin_ws/src/RoboND-Controls-Lab/quad_controller/scripts/position_controller_node", line 116, in pose_callback if self.counter >= 10 or not self.first_posereceived: AttributeError: PositionControllerNode instance has no attribute 'counter'
[ERROR] [1504352061.174335]: bad callback: <bound method PositionControllerNode.pose_callback of <main.PositionControllerNode instance at 0x7f2de875fe18>> Traceback (most recent call last): File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback cb(msg) File "/home/robond/catkin_ws/src/RoboND-Controls-Lab/quad_controller/scripts/position_controller_node", line 116, in pose_callback if self.counter >= 10 or not self.first_posereceived: AttributeError: PositionControllerNode instance has no attribute 'counter'
If instead, I restart the system, and I carry out an individual rosrun for the position controller, the error does not appear. Is it because the launch file for the position controller is trying to launch an instance of the attitude controller at the same time? The output of the individual rosrun is shown below:....................... robond@udacity:~$ rosrun quad_controller position_controller_node [INFO] [1504353054.984205]: Position controller node config changed!
What is the current status of this issue?
I tried to reboot the VM to remove the errror (as recommended on Slack channel for Controls). Also, I ran a new catkin_make. However, these actions did not remove the error in the end.
Instead, I managed to remove the error by modifying the script "position_controller_node", as below:
--> moved the line "self.counter = 0" to the beginning of the constructor belonging to class PositionControllerNode()
See code snippet below.
I'm not sure exactly why, but once I modified the constructor as mentioned, the position controller worked fine.
I have now managed to complete the lab for Controls. My drone can fly out to the lava cube, land and return back.
class PositionControllerNode(): def init(self): self.first_posereceived = False self.counter = 0 #moved self.counter to beginning of the constructor rather than the end
x_kp = float(rospy.get_param('x_kp', '0'))
x_ki = float(rospy.get_param('x_ki', '0'))
x_ki_max = float(rospy.get_param('x_ki_max', '0'))
x_kd = float(rospy.get_param('x_kd', '0'))
self.x_controller_ = PIDController(x_kp, x_ki, x_kd, x_ki_max)
.
,
.
srv = Server(position_controller_paramsConfig, self.config_callback)
#self.counter = 0 #Original position of self.counter
Okay we will take a look at it!
Excellent find! The real problem here is that we are calling init_node before we initialized the PositionControllerNode
class.
Because of this, the pose callback (which depends upon the counter) is getting called before the counter has been declared (aka PositionControllerNode's init() function is still running).
The fix that you've implemented will probably work, but we should instead be calling init_node() after PositionControllerNode has been initialize.d
Made the changes. Can you confirm it working now @Things2Connect
I've done a git pull tonight to download the above-mentioned changes onto my local repository. However, I get an error when I re-run a roslaunch for the position controller node. The systems seems to have a problem creating topics before doing a node init? I've attached the terminal output below:
robond@udacity:~$ roslaunch quad_controller position_controller.launch ... logging to /home/robond/.ros/log/187d73c6-957f-11e7-b68b-000c29100b05/roslaunch-udacity-11046.log . . . . . ROS_MASTER_URI=http://localhost:11311
core service [/rosout] found
process[position_controller-1]: started with pid [11065]
process[attitude_controller-2]: started with pid [11066]
process[quaternion_to_euler_node-3]: started with pid [11067]
process[rqt_reconfigure-4]: started with pid [11068]
Traceback (most recent call last):
File "/home/robond/catkin_ws/src/RoboND-Controls-Lab/quad_controller/scripts/position_controller_node", line 155, in
I reverted the changes to your original suggestion. Hopefully this will resolve the issue. Thanks for the follow up
Thanks. Yes, the issue is resolved now. Just tried again. The simulator works fine and can position the drone onto the lava cube.
I get an error when I carry out a roslaunch for the position controller in lesson 2.14. I don't know if it is related to tickets #114 and #115. If I do an individual rosrun for the position controller node , it seems to work fine. There is some kind of issue in the launch file of the position controller?