PaulBouchier / swiftnav_piksi

Source code for the ROS driver for the Swiftnav Pksi RTK GPS receivers
8 stars 19 forks source link

Functions are not accessed in the driver #7

Closed raghad1234 closed 7 years ago

raghad1234 commented 7 years ago

Hi I have a problem in displaying the swift RTK-GPS signal in ROS using this tutorial http://wiki.ros.org/swiftnav_piksi. I always get the following message whenever I run the monitor window using this command rosrun rqt_robot_monitor rqt_robot_monitor

**Full Name: /GPS/piksi_rtk_diag: Piksi Status Component: piksi_rtk_diag: Piksi Status Hardware ID: piksi rtk Level: WARNING Message: RTK Satellite fix invalid: too few satellites in view

io_failure_count: 0 open_failure_count: 0 Heartbeat status (0 = good): 0 Number of satellites used in GPS RTK solution: 0 GPS RTK solution status (1 = good): 0 GPS RTK meters north: 0 GPS RTK meters east: 0 GPS RTK height difference (m): 0 GPS RTK horizontal accuracy (m): 0.04 GPS RTK velocity north: 6.93398e-310 GPS RTK velocity east: 4.94066e-324 GPS RTK velocity up: 6.95299e-310 Number of satellites used for lat/lon: 0 GPS lat/lon solution status: 0 GPS latitude: 0 GPS longitude: 0 GPS altitude: 0 GPS lat/lon horizontal accuracy (m): 0**

I traced the piksi_driver.cpp code and I found that it doesn't get inside these functions at all. PIKSI::~PIKSI( ) bool PIKSI::PIKSIOpen( ) void PIKSI::PIKSIClose( ) void PIKSI::PIKSICloseNoLock( ) void heartbeat_callback(u16 sender_id, u8 len, u8 msg[], void context) void time_callback(u16 sender_id, u8 len, u8 msg[], void context) void pos_llh_callback(u16 sender_id, u8 len, u8 msg[], void context) std::cout << "10" << std::endl << std::flush ; void baseline_ned_callback(u16 sender_id, u8 len, u8 msg[], void context) void vel_ned_callback(u16 sender_id, u8 len, u8 msg[], void *context) void PIKSI::DiagCB( diagnostic_updater::DiagnosticStatusWrapper &stat )

It keeps looping in these two functions void PIKSI::spin( ) void PIKSI::spinOnce( )

I am using Ubuntu 14.04 and the latest version are downloaded for piksi firmware This is very strange since I am following exactly what is written in the tutorial!

Has anybody tested the code in piksi device and worked with him?

Thanks Raghad

PaulBouchier commented 7 years ago

Hi Raghad. I developed/tested it on Ubuntu 14.04/Indigo and believe it works fine in that environment. I suspect the reason you're not seeing PIKSIOpen/Close called is because the piksi_driver launches a thread in the PIKSI::PIKSI constructor initializer. The new thread starts in PIKSI::spin() and loops there forever, as you observed. Then the base thread calls PIKSIOpen() then goes into a permanent spin on ros::spin(), while the launched thread calls PIKSI::spinOnce which calls into the SBP library to process any messages that have arrived from the Piksi, which are processed by callbacks. It's a complicated threading model, but the guys who wrote it that way wanted to support multiple piksi's, each being run by a thread, and assigned a "slot".

I think the problem is indicated by the message: Message: RTK Satellite fix invalid: too few satellites in view Number of satellites used for lat/lon: 0 GPS latitude: 0 GPS longitude: 0 GPS altitude: 0

This indicates no data is being received - regardless of rtk corrections you're not getting any gps data at all.

Your observation that the callbacks that should be called: time/heartbeat/pos_llh_callback are not getting called might be due to you attaching to the wrong thread. If you attached gdb to the base thread instead of the spawned thread, they might be being called but you wouldn't be seeing it. On the other hand, if they aren't being called, it indicates a problem with the SBP library (perhaps swiftnav broke it) or perhaps with access to the serial port.

Have you run piksi_console as instructed in section 4.3 of the wiki page? Did you run it with piksi in simulation mode as instructed in the link in section 5 that should take you to the Piksi User Getting Started Guide? If it doesn't work that indicates a serial port problem. The most common fault is that you aren't a member of the dialout group. Run minicom and see if you're getting data from the serial port on the serial device. Perhaps your serial port isn't at /dev/ttyUSB0 (some USB-serial ports turn up at /dev/ttyACM0. Look at the ROS logfile for errors - perhaps the serial port wasn't opened successfully.

I'm on kinetic now, but I'll try to test the procedure this weekend in case the library got broken. Let me know how you get on.

Paul

ciscorigvc commented 7 years ago

Has this problem been solved? I am still unable to receive date using the swiftnav piksi using ROS. I am getting the same error message. I am running on ubuntu 14.04/indigo. Please let me know if anyone has found a fix for this issue. I have opened the piksi on the console and verified it is publishing data in simulation mode. Also I have checked and successfully opened the USB port through ROS so I don't believe it is a permissions issue.

PaulBouchier commented 7 years ago

Hi. I'm sorry for not solving this sooner - I was working on upgrading my piksis and I bricked both of them so I can't test the latest libsbp to see what broke, but I suspect it may be a libsbp problem.

Can you please do a test for me and report the results. On the ROS wiki page for swiftnav_piksi: http://wiki.ros.org/swiftnav_piksi in section 4.1 where you build libsbp, can you build libsbp from my github repo. It was what was working on 14.04/indigo

Build the old libsbp by making a new directory, checking out the old libsbp from source in my repo, and building and installing it. The first couple of steps in 4.1 should be: mkdir oldlibsbp cd oldlibsbp git clone https://github.com/PaulBouchier/libsbp .... Follow the rest of the instructions in 4.1 that build & install libsbp. Then test whether it works as shown on that page.

Please post the results. Meanwhile I'll try to get my piksi's unbricked.

Thanks

Paul

ciscorigvc commented 7 years ago

Unfortunately that did not work. I built the older version of libsbp and am still not able to publish data from the GPS to ROS. Whenever I launch rqt_robot_monitor I get an error that their is no information publishing.

harritdiwan commented 7 years ago

I am getting the same error and haven't been able to fix it. Paul can you suggest a fix please?

PaulBouchier commented 7 years ago

Can one of you guys please do a test for me and report the results? I need you to edit a couple of the files to print some output at critical points and check what's going on.

Edit swiftnav_piksi/src/piksi.c and insert a blank line after line 151 and add the following code in the blank line: printf("Received %d bytes in read_data function\n", bytes_recvd);

Also, edit swiftnav_piksi/piksi_driver.cpp and insert a blank line after line 191 and add the following code there: std::cerr << "receved llh callback\n";

Rebuild by doing cd ../.. catkin_make

Next, run the launch file: rosluanch swiftnav_piksi swiftnav_piksi.launch and report whether you see the two lines you added print the message from each.

While the launch file is running, run: rostopic list You should see a number of topic names, one of which shoudl be /gps/fix run a command to echo the topic: rostopic echo /gps/fix and let me know if you see anything

Thanks

Paul

harritdiwan commented 7 years ago

Line 191 in piksi_driver.cpp is an if statement. Are you sure to add a line after it?

harritdiwan commented 7 years ago

This is the output I am getting.

screenshot from 2017-02-16 09 36 17

harritdiwan commented 7 years ago

Nothing being echoed in /gps/fix

PaulBouchier commented 7 years ago

Thanks for the reply harritdiwan. Oops - I meant to say insert a blank line BEFORE line 191 (before the if() statement), to tell whether the llh callback was getting called. The output you show is suspicious - my recollection from development is it would receive tens of bytes at a time, not 1 or 2. There's a ton of data comes across from piksi - which is why swiftnav runs it at 1,000 kbaud. It almost looks as if the baud rate is not getting set properly. No idea why, but if the baud rate was wrong it would never get any messages that make sense so that would produce the observed effect. Researching....

PaulBouchier commented 7 years ago

Status update: working with Swiftnav to identify the problem. Stay tuned....

harritdiwan commented 7 years ago

Thank you Paul for the help. Please keep updated.

PaulBouchier commented 7 years ago

SOLVED!!!

The fix is to clone the old version of the libsbp library, then rebuild the swiftnav_piksi package.

Please remove the libsbp and swiftnav_piksi directories as shown below

# removing the libsbp directory
cd mysrc
rm -rf libsbp
# removing swiftnav_piksi
cd ~/catkin_ws/src
rm -rf swiftnav_piksi

Next, do the updated steps in section 4.1 and 4.2 of the ROS [swiftnav_piksi wiki page](http://wiki.ros.org/swiftnav_piksi}

Explanation of the fault and fix

Swiftnav changed the message numbers in libsbp for piksi multi support in a way that was incompatible with v2 piksi. Consequently, v2 piksi would send messages which would be interpreted incorrectly by their latest libsbp library, so the swiftnav_piksi ROS driver never got any valid messages.

I duplicated the problem you guys were seeing by using the new libsbp library, then I fixed it by back-reving the libsbp library and rebuilding the library and swiftnav_piksi driver and it began working.

The fix (for now) is to pull libsbp from my github repo. It has the last version of the library that worked with v2 piksi. It is also necessary to rebuild the swiftnav_piksi ROS driver because the install step of libsbp build puts header files in /usr/local/include which swiftnav_piksi uses. The reason @ciscorigvc test didn't work is I didn't tell him to rebuild swiftnav_piksi, so it was still using messed-up headers, even though the library was working correctly after he reverted to the old library.

I apologize for how long this problem has taken to solve. I had problem after problem updating my piksis to the latest firmware. Thanks to swiftnav for their help unbricking them (solution was to use the windows piksi_console).

I expect to add support for piksi multi to this driver very shortly. piksi multi will achieve RTK lock in 10 - 60 seconds, so will be a big improvement for ground roboticists.

PaulBouchier commented 7 years ago

Will someone please test this fix and report results.

harritdiwan commented 7 years ago

It works now!! Thank you very much Paul for taking out your time and solving this issue.

PaulBouchier commented 7 years ago

Thanks for the followup report @harritdiwan I will add this to the tips & tricks section of the wiki page in case anyone else has this problem.

msz1621 commented 7 years ago

Hello Paul,

I did the suggested fix: install the older version of libsbp (v0.51.1) and then install swiftnav_piksi. I am still having the same problem. I am running on ubuntu 16.04 and ROS Kinetic. It is written in the ROS wiki page that the package works with ROS indigo and jade. Since I am using Kinetic, do you think that this makes some problems? Although no errors while building the libraries. Also, I am working with Piksi Multi 2.4 GHz evaluation kit and I am enabling the simulation from the swiftnav console for this testing. BTW, I receive data normally while using the console.

Thank you.

PaulBouchier commented 7 years ago

Hi. I think you didn't understand the problem or solution properly. If you are using piksi multi, you need to install the NEWEST version of libsbp, then install and build swiftnav_piksi. This issue relates to how to make old piksi's work, and the solution was to use the old version of the library. For Piksi multi's, use the new version of the library, direct from swiftnav. Sorry I haven't written up the instructions yet - I'll try & get them written this weekend. Here are the instructions for piksi multi that I sent another user. He and I have used them successfully on 16.04, so they are good.

Here are instructions for where the procedure on the wiki differs for piksi multi.

In section 4.1, “Build & Install libsbp”, you should clone this repo:

git clone http://github.com/swift-nav/libsbp

Follow the instructions to build it.

In section 4.2 “Build & install the switfnav_piksi driver”, after the git clone step, do the following command:

git checkout piksi_multi

You will have to rebuild the ros SW to get it to use the new libsbp library (catkin_make clean && catkin_make)

These two steps cause the swiftnav_piksi driver to use the new libsbp library which supports piksi multi, and check out a branch with various necessary changes to the driver to get it to work with piksi multi. It is just a quick hack – I need to fix it properly, but hopefully this gets you going.

When you run rqt_robot_monitor you will see a bad status for piksi heartbeat – don’t worry about that – I didn’t make that work yet.

msz1621 commented 7 years ago

Thank you. It is working now. I noticed that the IMU data is not published. Do you have a plan to support that? Thank you

Hothaifa commented 7 years ago

can you please post more info about setting up Piksi Multi with ROS

Hothaifa commented 7 years ago

The Piksi MultI has an Eitherent port, can your ROS driver utlize it rather than serial port?

PaulBouchier commented 7 years ago

@msz1621 I haven't thought about publishing piksi-mulit IMU data. @Hothaifa the driver is not written to use ethernet ports. It's an interesting idea to tie into that.

msz1621 commented 7 years ago

I had a quick look at libsbp c code, it looks like it is still not fully supported. The header file is there but no actual implementation.

JadBatmobile commented 7 years ago

Honestly i am still running into that same error. I tried using two branches for the libsbp library,

https://github.com/PaulBouchier/libsbp.git and http://github.com/swift-nav/libsbp

each time i deleted the ROS workspace completely, recreated it and cloned https://github.com/PaulBouchier/swiftnav_piksi.git

Any further help would be appreciated.

JadBatmobile commented 7 years ago

Update: i cloned https://github.com/swift-nav/swiftnav_ros instead of https://github.com/PaulBouchier/swiftnav_piksi.git

and i got this result when running rqt_robot_monitor:

screenshot from 2017-08-30 15 11 38

any thoughts?

JadBatmobile commented 7 years ago

Hey guys, Finnaly got it to work by using the git branches: libsbp: https://github.com/swift-nav/libsbp swiftnav_ros: https://github.com/swift-nav/swiftnav_ros

cheers

PaulBouchier commented 7 years ago

Thanks for the update. Glad it's working. Those are the correct repos to use. I've updated my repos by marking them as obsolete. Swiftnav has taken over maintenance of this driver. @jkretzmer