Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not load FalconFirmware #45

Open
agirault opened this issue May 9, 2016 · 38 comments
Open

Could not load FalconFirmware #45

agirault opened this issue May 9, 2016 · 38 comments

Comments

@agirault
Copy link
Contributor

agirault commented May 9, 2016

Hi,

I am running into a wall trying to run my Novint Falcon.

Here are my steps simplified :

// Init device
auto falconDevice = new libnifalcon::FalconDevice;
falconDevice->setFalconFirmware<libnifalcon::FalconFirmwareNovintSDK>();
falconDevice->setFalconKinematic<libnifalcon::FalconKinematicStamper>();
falconDevice->setFalconGrip<libnifalcon::FalconGripFourButton>();

// Open device
falconDevice->open(0)

// Load firmware
for(int i = 0; i < 10; ++i)
{
    if (!falconDevice->isFirmwareLoaded())
    {
        auto skip_checksum = false;
        auto firmware_size = libnifalcon::NOVINT_FALCON_NVENT_FIRMWARE_SIZE;
        auto buffer = const_cast<uint8_t*>(libnifalcon::NOVINT_FALCON_NVENT_FIRMWARE);
        auto loaded = m_falconDevice->getFalconFirmware()->loadFirmware(skip_checksum, firmware_size, buffer);
    }
}

Opening the device succeeds (returns true), not loading the firmware (loaded always false).

I get FALCON_FIRMWARE_CHECKSUM_MISMATCH (3004) error at the end of FalconFirmware::loadFirmware():

For READ_SIZE = 62, if get the error for

  • total_read = 0
  • bytes_check = 0
  • i=44.

For READ_SIZE = 58, if get the error for

  • total_read = 0
  • bytes_check = 0
  • i=26.

Is there anything else to do than set FalconFirmwareNovintSDK to load the firmware successfully? I did this based on the barrow_mechanics and findfalcons example.

@qdot
Copy link
Member

qdot commented May 9, 2016

What OS are you on?

@agirault
Copy link
Contributor Author

agirault commented May 9, 2016

OpenSuse (Unix)

@qdot
Copy link
Member

qdot commented May 9, 2016

Ok, well, let's try the old style black magic solution first. Do you have the falcon plugged into a USB hub, or directly into the machine?

@agirault
Copy link
Contributor Author

This started working for no apparent reasons.
Was plugged directly in the machine (I like to play with 🔥).
Sounds like a consistent working behavior isn't always guaranteed, if I run into the issue again I'll try to debug that.

@qdot
Copy link
Member

qdot commented May 10, 2016

Aggggggggggh whyyyyyyyyyy. We just resolved #33 'cause I thought this was over and done with. I guess I'll put more notes in the readme about it. :(

It's something that's been a problem since this project started 9 years ago. Just never took the time to properly debug it.

@qdot
Copy link
Member

qdot commented May 11, 2016

Um, actually, I just found out a Pull Request we have that I need to work on rebasing might have a fix for this?

12b56b3

Can you possibly pull this patch in and see if it works for you?

@qdot
Copy link
Member

qdot commented May 11, 2016

I just rebased the pull request that fix was in ( #30), it's now the gb-fix branch of this repo. So, if you just pull and try the branch, the fix should be there.

@agirault
Copy link
Contributor Author

Could not find the gb-fix branch in https://github.com/libnifalcon/libnifalcon/branches

@qdot
Copy link
Member

qdot commented May 11, 2016

Oops, pushed it to my personal repo, not this one. Just fixed that, sorry.

@agirault
Copy link
Contributor Author

Could you maybe rebase it on the current master and force push it? I can not test without the cmake changes since I use libnifalcon as a subproject

@qdot
Copy link
Member

qdot commented May 11, 2016

Rebased and pushed!

@agirault
Copy link
Contributor Author

agirault commented May 11, 2016

Tested: half-success: this branch fixes my first issue that was happening in FalconCommLibUSB::setFirmwareMode(), but I still have a checksum mismatch at the end of FalconFirmware::loadFirmware():

For READ_SIZE = 62, if get the error for

  • total_read = 0
  • bytes_check = 0
  • i=44.

For READ_SIZE = 58, if get the error for

  • total_read = 0
  • bytes_check = 0
  • i=26.

Error : FALCON_FIRMWARE_CHECKSUM_MISMATCH (3004)

Not sure if something changes for the check_sum since this branch, but I had the checksum issue before too. That new branch still seems to fix the other issue so I would merge it if you think the rest looks good, i can work by setting skip_checksum = true even though that's not great.

@qdot
Copy link
Member

qdot commented May 11, 2016

Ok, everything else looked ok enough, so I'm pushing it. Will leave this open to see about the checksum errors though.

@agirault
Copy link
Contributor Author

Updated the info in the issue. Do you think this could be due to a wrong firmware_size and buffer values passed to loadFirmware? Thanks for your help!

@qdot
Copy link
Member

qdot commented May 11, 2016

Can't say for sure off the top of my head. I basically just need to go back through and audit most of the code since I've been doing this for more 9 years more than I had when I originally wrote this, so I'm sure there's all sorts of "WTF WAS I THINKING" involved in this (for instance: all of the templates and boost stuff). Just may be a week or two before I can 'cause I've kinda got too many things going on at the moment. :)

@aline-fidencio
Copy link

Hi all!! I am new with Linux, Falcon and libnifalcon. Basically I would like to use Falcon to control a robot (SeekurJr) using a ROS package. But, first of all, I would like to try the libnifalcon examples. I am getting the "could not load firmware" error. Can anyone help me please? I read about the powered usb hub no longer being necessary, still connecting it directly to my computer didn't work. I am using Ubuntu 12.04. Thank you so much in advance!

Kind regards,

Aline

@dRacz3
Copy link

dRacz3 commented Oct 20, 2016

Dear Aline!
Are you running your apps in sudo? That might be a cause of the problem, and if the answer is yes, try running findfalcons first, that should do the trick.

Kind regards,

Daniel

@aline-fidencio
Copy link

aline-fidencio commented Oct 20, 2016

Hi Daniel!
Yes, I am running with sudo and I have tried to run exactly the findfalcons... Also tried running it several times to see if would simply work hahaha

Kind regards,

Aline

@aline-fidencio
Copy link

aline-fidencio commented Oct 20, 2016

Ahh guess what! It simply worked now... ¬¬

I called: ./falcon_test_cli --device_index 0 --nvent_firmware --cube_test
it worked.. then I called the usual findfalcons..

It worked on my VM.. now that I tried my robot it didn't work.

What a weird thing..

Sorry to bother you guys!

Kind regards,

Aline

@RisinT96
Copy link

RisinT96 commented Nov 16, 2016

Hi all,

I'm also having problems, I somehow managed to get this and Rosfalcon to work on my laptop (running ubuntu 14.04) about half a year ago for a project.

Now I'm trying to run it on another computer and libnifalcon just doesn't work...
It compiles fine and all, but when running findfalcons I get:
Falcons found: 1
Opening falcon 1
Cannot open falcon - Error:

and that's it... running with sudo manages to open it but then can't load firmware :(

It somehow worked on my laptop even without sudo, although rosfalcon always failed to load firmware so I had to run findfalcons every time before running it.
(also the falcon was kinda twitching once in a while but I guess that's the fault of a bad P controller in rosfalcon)

Any help would be very appreciated :)

image

image

Oh, I also tried this from a VM running on the original laptop but got the same results..

@aline-fidencio
Copy link

Hi RisinT96!

Yes, you always have to run it with sudo to be able to open the device. I think that it works fine in your computer because for some reason your user already has this kind of privilege over the usb device.

About loading the firmware, what worked for me was to run the other example: ./falcon_test_cli --device_index 0 --nvent_firmware --cube_test (I realised that the --nvent_firmware parameter is not actually necessary, since there is only one firmware to be loaded after all...)
Anyway, I couldn't find out what was wrong with the other example. I did notice some differences in the code, but nothing more than some more/less objects/classes. I thought it had to work just fine. Still, for me it was enough to have one example running. I wanted to use rosfalcon to use it as a joystick. So I just got the code I needed from it and basically created my own package, mixing the original rosfalcon code with the falcon_test_cli code for loading the firmware and now it works just fine.

I am now facing another problem that is, for some reason, after a quite short time the call m_falconDevice.RunIOLoop() is returning false, that means that whatever I am running stops to work; it is as if communication with the falcon would get lost. Do you have this problem as well?

Kind regards,

Aline

@RisinT96
Copy link

Hi Aline,

Unfortunately running falcon_test_cli doesn't help at all, it fails just like findfalcons.

I had a clean installation of ubuntu 14.04 on my laptop and installed libnifalcon, findfalcons worked flawlessly through all the usb ports without sudo permissions.

I have a version of rosfalcon modified to work with standard ROS topics (instead of the custom falconForces topic), this is all hooked up to matlab through ros in order to control a clearpath jackal robot, all of this seems to have worked without any major problems for the last year or so and I don't want to touch my installation of ubuntu before I manage to get it running on another machine.

Trying to get this to run on another computer, I haven't gotten to running rosfalcon yet, because libnifalcon doesn't properly work...

I tried compiling it to use the libftd2xx library instead of libusb (I read somehwere that the libusb version has trouble loading up the firmware) but it netted no results :/ ... still fails to open without sudo, and manages to open but fails to load firmware when run with sudo.

Big thanks to Kyle for even creating this driver, without it my project wouldn't have even become a reality.

@msadowski
Copy link

msadowski commented Jan 8, 2017

Hi all!

Did anyone manage to fix this issue or has some workaround? If not then I'm more than happy to look into it. I would appreciate any advice. I don't have too much experience with cmake so I would be grateful for any info on how to enable logging (I saw ENABLE_LOGGING in the files).

Edit:
Strange, after I reboot my laptop (just after installation) and tried to run findfalcon I got this message:

Falcons found: 1
Opening falcon 1
Opened falcon
Loading firmware
Firmware loaded
Firmware didn't load correctly. Try running findfalcons again

After I run it for the second time it succeed and now all examples run fine!

@aline-fidencio
Copy link

Hi RisinT96! I am very sorry I was gone. But actually I didn't know how could I help you. I am very bad at this.. still learning and struggling here also... Any update from you? And yes! Big thanks to Kyle for developing this driver!

@msadowski I really don't know why but not I am not having problems with loading the firmware anymore. What I did was using as example the code for the falcon_test_cli because it was working.

But I am still facing the communication problem. That is, for some reason, after a quite short time the call m_falconDevice.RunIOLoop() is returning false, that means that whatever I am running stops to work; it is as if communication with the falcon would get lost. Does anyone have this problem as well? Or know what could be causing it?

I tried to do some tests here in the lab but I had some problems with the computer and with the holidays and other things to do I have still not solved it.

And now I have another issue: I am not being able to read the buttons :( Can anyone help me with that? Maybe I am not calling all the functions I should or something like that. So far I do:

m_falconDevice->setFalconGrip<libnifalcon::FalconGripFourButton>();
unsigned int buttons = m_falconDevice->getFalconGrip()->getDigitalInputs(); //Read in buttons; Bitfield of digital inputs
cout << "Buttons = " << buttons << endl;
unsigned char *buttons_array;
			
buttons_array[0] = (buttons & libnifalcon::FalconGripFourButton::BUTTON_3) ? 1 : 0;
buttons_array[1] = (buttons & libnifalcon::FalconGripFourButton::BUTTON_1) ? 1 : 0;
buttons_array[2] = (buttons & libnifalcon::FalconGripFourButton::BUTTON_4) ? 1 : 0;
buttons_array[3] = (buttons & libnifalcon::FalconGripFourButton::BUTTON_2) ? 1 : 0;

I just found the runGripLoop function but I am not sure how to use it or even if I have to use it.

Best regards,

Aline

@dRacz3
Copy link

dRacz3 commented Jan 16, 2017

Dear @aline-fidencio , as far as i know you have to continuously call the runIOLoop, otherwise the connection closes after some time. So when you are not using the falcon, you still have to call it to not close the connection.

Hope this helps,

Daniel

@msadowski
Copy link

@aline-fidencio: I didn't experience communication issues (but as @dRacz3 mentions I'm continuously calling runIOLoop()).

I tried running your snippet and for me it was sometimes crashing on your assignments to button_arrays. In FalconTest.cpp from example files the code used to get buttons state looks like this:

if(m_falconDevice->getFalconGrip()->getDigitalInputs() & libnifalcon::FalconGripFourButton::PLUS_BUTTON) { m_plusButtonDown = true; }
In my case it seems to be working. Can you try to modify your code and follow the example above?

Good luck!

@aline-fidencio
Copy link

Hi Daniel! Thank you for the reply. In fact I am continuously calling the runIOLoop:


while(node.ok() && !stop && ros::ok())
	{
		ROS_INFO("Running Falcon Joystick node...");
		
		Joystick.buttons.resize(4);
		Joystick.axes.resize(3);
		
		if(m_falconDevice->runIOLoop()){
                        // Here is where I do stuff like reading the buttons...

This is what I get when running my ROS node...
image

What is weird to me is that sometimes I get this errorCodes = 2000 but sometimes they are all 0! Therefore I could not identify the reason why runIOLoop is returning false. Do you happen to have any ideas?

@msadowski , as for the buttons, thank you so much. Your code worked fine!
But I also have a funny story about it: for some time, I could only read the buttons when I would explicitly call the following code before reading the buttons:

if(!m_falconDevice->getFalconGrip()->runGripLoop(m_falconDevice->getFalconFirmware()->getGripInfoSize(), m_falconDevice->getFalconFirmware()->getGripInfo())) { cout << "Grip Error Code " << m_falconDevice->getFalconGrip()->getErrorCode(); }

After some testing it started working without it.. but that is very weird to me that before I needed it...

Thanks guys!

Best regards,

Aline

@msadowski
Copy link

@aline-fidencio: about your code starting to work suddenly I'm wondering if it's related to the original issue of loading firmware. If you run findfalcons program does it work straight away? Can you make a test where you successfully run findfalcons and then try to read buttons normally? I'm wondering if you will have to run the code that you showed or will it work straight away after findfalcons works correctly.

For me findfalcons works only after 2nd attempt:
screenshot from 2017-01-23 18-16-38

@aline-fidencio
Copy link

@msadowski I wanted to try what you suggested but, in my case, findfalcons is not able to load the firmware.. I tried over 10 times.

I am still with the error about the RunIOLoop returning false... a very annoying one because it takes lots of my testing time just to reconnect to the device..

Thanks.

Aline

@msadowski
Copy link

msadowski commented Feb 24, 2017

@aline-fidencio: I will let you know if I run at similar problem! Are you using your falcon code with ROS? Any chance you could share your CMakeLists.txt? I don't seem to be able to link the libraries properly.

Update to not spam:
I successfully made the library be usable in ROS by adding the following to CMakeLists.txt:
set(CMAKE_CXX_FLAGS "-std=c++14 -lnifalcon") #Falcon lib is build agains c++14
target_link_libraries(falcon_node nifalcon nifalcon_cli_base usb-1.0 ${catkin_LIBRARIES} )
Afterwards catkin_make runs correctly.

Since this post is largely offtopic let me know if you want me to remove it!

Thanks,
Mateusz

@aline-fidencio
Copy link

@msadowski sorry for taking so long to reply again. Just now that I was about to post my CMakeLists for you I saw your update. I am really sorry for no replying before. But I am glad you got it working. Next time I will be faster.

Aline

@aline-fidencio
Copy link

Hi everyone.. I am still facing some problems with the Falcon driver..

I call m_falconDevice->runIOLoop() and from time to time it returns false.. after some tracking I think that it comes from this part of the code:

bool FalconDevice::runIOLoop(unsigned int exe_flags) { // ... if(!m_falconFirmware->runIOLoop() && (exe_flags & FALCON_LOOP_FIRMWARE)) { ++m_errorCount; m_errorCode = m_falconFirmware->getErrorCode(); return false; }
m_errorCode is set to 0 ....

Has anyone had the same problem or could give me some hint?
This is being very annoying because I get the message that the falcon is calibrated but no forces are applied to it.. so it is basically dead... But sometimes it works..

Thanks,

Aline

@RisinT96
Copy link

RisinT96 commented May 29, 2017

Hey all,

After a long time of trying to make it run, I found the source of my problems. ("cannot open falcon")
The problem was with the permissions, you have to place a proper udev-rules file in the appropriate folder on your system (I'll upload the file and path tomorrow), which will then give you the user proper permissions to use the hardware, without sudo.

Running it as sure gave me a lot of problems since I was trying to create a ROS node that communicates with the falcon, and running the nude with sudo was quite problematic, and very unwanted.

Hope this helps someone,
RisinT96.

EDIT:
Link to my udev ruled file: 99-udev-novint.zip

Need to place it under "/etc/udev/"
If I remember correctly it gives everyone R/W access to the device (666), you can easily change it though.
The main problem was also when the file name was 49-udev-novint, and it was being overridden by some other rules, so updating the name to 99-udev-novint solved all of the problems.

Though I must note that even now, once in a while the device stops responding and I have to restart the rosfalcon ROS node, which is a bummer.

@aline-fidencio
Copy link

Hey !

I know about the udev rules for a while... maybe I didn't configure it right so it will be nice to check with yours..

Funny is that the error also occurs when I run the findfalcons example.

Thanks in advance,

Aline

@RisinT96
Copy link

Updated my previous comment :)

@ben-greenberg
Copy link

ben-greenberg commented Jan 8, 2018

Hi Everybody!

This has been a very helpful thread to read through as I'm working to get my falcon to work. Unfortunately I still am getting the "Could not load firmware" error when I try to test that things are installed correctly with findfalcons. I may have missed it, as much of this thread is a bit over my head, but has someone found a definitive solution to this?

The falcon is plugged directly into my computer (no usb hub), I am running with sudo, I have tried running findfalcons 10+ times and haven't seen any differences, falcon_test_cli has the same issue.

My issue seems to be along the same lines as @RisinT96 's early post. I tried adding the new udev file that he posted, but that didn't fix the issue for me.

Any ideas would be greatly appreciated.

Thank you!
Ben

@henryng375
Copy link

@msadowski Hi, I have the same issue (findfalcons works only after 2nd attempt) Did you solve that issue?

@msadowski
Copy link

@henryng375 I didn't manage to solve it. I only had an access to falcon for couple of weeks for some proof of concept work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants