Skip to content

Comments

Add code to use encoders#65

Merged
ryanloeffelman merged 13 commits intoMST-Robotics:masterfrom
ryanloeffelman:encoder
Apr 29, 2016
Merged

Add code to use encoders#65
ryanloeffelman merged 13 commits intoMST-Robotics:masterfrom
ryanloeffelman:encoder

Conversation

@ryanloeffelman
Copy link
Contributor

Needs to be tested on working robot, to verify the speed is calculated
correctly, and accurately

Also updated a lot of names to match the Missouri S&T Robotics Competition Team standards

closes #35

Needs to be tested on working robot, to verify the speed is calculated
correctlly, and acurattly
@ryanloeffelman ryanloeffelman added this to the Sensing data milestone Nov 2, 2015
Changed the desiered_speed variable to desired_speed
Added code to Arduino to publish encoder ticks
Created a custom msg including Header, and Uint8
@ryanloeffelman
Copy link
Contributor Author

I know it currently doesn't work, I need help in getting the Arduino compiler to see the custom msg I created @islamelnabarawy

@ryanloeffelman
Copy link
Contributor Author

I think this link may help, http://wiki.ros.org/rosserial_client/Tutorials/Generating%20Message%20Header%20Files but I don't fully understand it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a missing function here which is what is causing the msg build failure. Since this depends on std_msgs you need the line:

generate_messages(DEPENDENCIES std_msgs)

to come here. This entire message block will also have to be moved up to be above the catkin_specific configuration block in order for it to build.

@islamelnabarawy
Copy link
Contributor

@ryanloeffelman @matthewia94
Is this pull request ready for review or is it still waiting for a fix?

@ryanloeffelman
Copy link
Contributor Author

Matt fixed the main issue, however I have yet to push my changes, give me around 10ish minuets and it should be ready to review

Allowed the Arduino to see the Ros Custom Header, will require remaking the
rosserial_python libraries after making, so that the arduino code can
 actully compile
@ryanloeffelman
Copy link
Contributor Author

I haven't actually been able to test the code on the Robot yet, as we have no encoders installed to test with, however the code will has at least been able to read the encoder successfully. The ROS message updating has yet to be tested. Also, I am starting to get a low memory warning on the Arduino Compiler, not to much of an issue, however If you see anything I do to save space, that would be great, thanks @islamelnabarawy

@islamelnabarawy
Copy link
Contributor

@ryanloeffelman The arduino file caused merge conflicts, and after resolving them I'm getting a compilation error saying it can't find Encoder.h. We might need to go over this together in person.

@matthewia94
Copy link
Contributor

The arduino file needs you to build the message headers. This is done with the make_libraries script contained in the rosserial_arduino package. The section Install ros_lib into the Arduino Environment here: http://wiki.ros.org/rosserial_arduino/Tutorials/Arduino%20IDE%20Setup gives details on how to set it up

@islamelnabarawy
Copy link
Contributor

The error I'm getting while trying to compile the arduino code is:

motor.ino:14:29: fatal error: control/Encoder.h: No such file or directory

@matthewia94
Copy link
Contributor

Correct, you would get this error if you have not run the make_libraries script as the message header is auto generated by ROS. @ryanloeffelman Would you mind maybe adding the build process for custom messages to the arduino page on our wiki?

Basically you need to build the normal code and source, find the libraries folder for arduino, delete ros_lib directory if it exists and run:
rosrun rosserial_arduino make_libraries.py .

@islamelnabarawy
Copy link
Contributor

Ok, it's possible that I hadn't sourced the project before generating the libraries last time. This time it worked, but there was another error because the set_pwm_frequency() function needed to be forward-declared. I did that and it compiled. I'll add a comment to the relevant line of code.

@ryanloeffelman
Copy link
Contributor Author

At least its not just me who makes that mistake. Are you using the Arduino Compiler? I know its good practice to forward declare things, however Arduino doesn't usually care about that.

@islamelnabarawy
Copy link
Contributor

It might have been due to a merge error. I will have to merge the code manually to make sure the merge doesn't break anything, and I'll accept the pull request as soon as I'm done with that.

@ryanloeffelman
Copy link
Contributor Author

Sound good, however I wouldn't actually accept this pull request until we can test it on the Robot, which will be after the encoder have been successfully installed

@islamelnabarawy
Copy link
Contributor

Noted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to:
attachInterrupt(0, encoderCount, RISING);
This will update on the rising edge and we won't have to check if the change was from low to high or not.

@matthewia94 matthewia94 mentioned this pull request Jan 31, 2016
@ryanloeffelman ryanloeffelman merged commit 24a7f7c into MST-Robotics:master Apr 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Encoder Reading to motor.ino

4 participants