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

error[E0599]: no function or associated item named new found for struct "test_rosmaster::String" in the current scope #1

Open
lucasw opened this issue Nov 3, 2020 · 12 comments

Comments

@lucasw
Copy link
Owner

lucasw commented Nov 3, 2020

This is coming out of having a fork of ros_comm in the sourced catkin_ws

   Compiling rosrust_msg v0.1.1
error: expected one of `!` or `::`, found `=`
 --> /home/lucasw/own/src/rust/rust_test/ros/rosrstest/target/debug/build/rosrust_msg-99c9329cbe7ef32c/out/messages.rs:3:9
  |
...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |       |
  |       expected one of `!` or `::`
  |       while parsing this item list starting here
  |       the item list ends here
  |
  = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: associated constant in `impl` without body
 --> /home/lucasw/own/src/rust/rust_test/ros/rosrstest/target/debug/build/rosrust_msg-99c9329cbe7ef32c/out/messages.rs:3:9
  |
3 | ...   rosrust::rosmsg_incl
...
                help: provide a definition for the constant: `= <expr>;`
  |
  = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: missing type for `const` item
 --> /home/lucasw/own/src/rust/rust_test/ros/rosrstest/target/debug/build/rosrust_msg-99c9329cbe7ef32c/out/messages.rs:3:9
  |
3 | ...   rosrust::rosmsg_include!(tf2_msgs/TF2Error,tf2_msgs/LookupTransformAction,tf2_msgs/LookupTransformActionGoal,tf2_msgs/LookupTransformFeedback,tf2_msgs/LookupTransformGoal,tf2_msgs/LookupTransformActionFeedback,tf2_msgs/LookupTransformActionResult,tf2_msgs/TFMessage,tf2_msgs/LookupTransformResult,tf2_msgs/FrameGraph,theora_image_transport/Packet,smach_msgs/SmachContainerStatus,smach_msgs/SmachContainerInitialStatusCmd,smach_msgs/SmachContainerStr...
...
3 | ...   rosrust::rosmsg_include!(tf2_msgs/TF2Error,tf2_msgs/LookupTransformAction,tf2_msgs/LookupTransformActionGoal,tf2_msgs/LookupTransformFeedback,tf2_msgs/LookupTransformGoal,tf2_msgs/LookupTransformActionFeedback,tf2_msgs/LookupTransformActionResult,tf2_msgs/TFMessa...
error[E0599]: no function or associated item named `new` found for struct "test_rosmaster::String" in the current scope
...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |       |
  |       function or associated item `new` not found for this
  |       function or associated item not found in `test_rosmaster::String`
  |
  = help: items from traits can only be used if the trait is implemented and in scope
  = note: the following traits define an item `new`, perhaps you need to implement one of them:
          candidate #1: `error_chain::ChainedError`
          candidate #2: `gimli::read::lookup::PubStuffEntry`
          candidate #3: `aho_corasick::Transitions`
          candidate #4: `rand::distributions::uniform::UniformSampler`
          candidate #5: `error_chain::ChainedError`
  = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0599`.
error: could not compile `rosrust_msg`.

To learn more, run the command again with --verbose.

Maybe that isn't getting build if tests aren't getting build, but rosrust_msgs scans it anyhow and then fails?

Is adnanademovic/rosrust#134 related?

@lucasw
Copy link
Owner Author

lucasw commented Nov 3, 2020

Put a CATKIN_IGNORE in ros_comm/test.

roscd ros_comm
touch CATKIN_IGNORE

In the catkin workspace:

rm -rf build devel .catkin_tools
source /opt/ros/noetic/setup.bash
catkin build
cargo clean  # deletes target dir
cargo build

It is still finding the test_rosmaster messages.

It's also finding messages completely outside of the sourced catkin ws.
(Because they are sourced in .bashrc? No disabling that source doesn't fix it)

Maybe need to do something more than CATKIN_IGNORE - delete all references to test_rosmaster in the parts that aren't ignored.

vanilla noetic-devel ros_comm also fails, it's not just my fork.

@lucasw
Copy link
Owner Author

lucasw commented Nov 3, 2020

Maybe something is broken with catkin overlays? Try overlaying a much simpler package that is also in apt repos.

Try overlaying with ros-noetic-geometry-msgs

git clone git@github.com:ros/common_msgs

Works fine.

There is something unique about ros_comm then?
Or anything that uses a ros test?

@lucasw
Copy link
Owner Author

lucasw commented Nov 3, 2020

Disable/delete tests

catkin build -DCATKIN_ENABLE_TESTING=0

Still fails with ros_comm the same way.

@lucasw
Copy link
Owner Author

lucasw commented Nov 3, 2020

Try catkin build install - nope.

@lucasw
Copy link
Owner Author

lucasw commented Nov 3, 2020

Reproduce with docker

docker run --rm -it ros:noetic-robot bash -c "\
apt update && \
apt install -y curl git && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
source /root/.cargo/env && \
source /opt/ros/noetic/setup.bash && \
mkdir catkin_ws/src -p && \
cd catkin_ws/src && \
git clone https://github.com/ros/ros_comm.git && \
cd .. && \
catkin build && \
source devel/setup.bash && \
cd .. && \
git clone https://github.com/adnanademovic/rosrust.git && \
cd rosrust && \
cargo build"

This shows the error. Try melodic later.

@lucasw
Copy link
Owner Author

lucasw commented Nov 21, 2020

Deleted all component of ros_comm except for ros_comm/tools and the build works. tools/rosgraph and tools/roslaunch are where I have my changes in a branch, so a rosrust compatible branch of ros_comm could be made to make this work with CI pipelines easily. If I make changes to other packages within ros_comm I can try to bring them in one by one.

Will have to cherry-pick changes back and forth as needed between a regular non rosrust noetic_aggregated and rosrust_compatible_noetic_aggregated.

lucasw added a commit to lucasw/ros_comm that referenced this issue Nov 21, 2020
@lucasw
Copy link
Owner Author

lucasw commented Nov 21, 2020

The rosgraph doesn't appear to be working (and logs out of rust nodes are odd not going through it either:

[ INFO][1605973982.167029391 ${shortfile}:17 /test_pub_sub]: float from rust 0.00136984 0.140187
[INFO @ src/loginfo/main.rs:78]: update 1.3738008
[INFO @ src/loginfo/main.rs:91]: test ros_info

I do see the main.rs logs in rosout_agg though, so why aren't they in stdout properly? Probably something in rosrust is re-implementing the log line output instead of going through the python (so C++ ros nodes go through python to print to stdout?).

---
header: 
  seq: 496
  stamp: 
    secs: 1605974324
    nsecs: 959169912
  frame_id: ''
level: 2
name: "/loginfo"
msg: "test ros_info"
file: "src/loginfo/main.rs"
function: ''
line: 91
topics: 
  - /rosout
  - /float_from_rust

function is blank in the rust node output, so that needs to be fixed (though maybe if it was a closure that isn't well defined?).

@lucasw
Copy link
Owner Author

lucasw commented Nov 21, 2020

I probably need clients/rospy/src/rospy/rosconsole.py to make the rosgraph changes work.

Try leaving in both the C++ and rospy clients - that builds.

Still not proper log message output- do a clean rebuild.

Forgot about git@github.com:lucasw/rosconsole, need that for C++ nodes.

Works, now look at formatting rust log messages adnanademovic/rosrust#152

[INFO @ src/loginfo/main.rs:78]: update 0.13460626
[INFO @ src/loginfo/main.rs:91]: test ros_info
[I][1605975989.124 .../rsc_test/src/test_pub_sub.cpp:17 /test_pub_sub]: float from rust -0.00146927 0.134606

@lucasw
Copy link
Owner Author

lucasw commented Nov 22, 2020

Using a ros_comm fork with test dir deleted good enough for now, could dive into why it fails later.

@lucasw lucasw closed this as completed Nov 22, 2020
@lucasw
Copy link
Owner Author

lucasw commented Mar 7, 2024

Looking at debugging the test_rosmaster and related issue of trying to build messages outside of the ROS_PACKAGE_PATH, first debug all the paths passed into rosrust_msg.

(Also why even build those messages if nothing depends on them? Maybe there could be a test build that builds every message it can find- or is that what this already is?)

This is needed to use println in the rosrust_msg build.rs rust-lang/cargo#985 (comment)

find . -name output | grep rosrust_msg
cmake_paths: ["share", "/home/lucasw/other/install/lib/cmake/share", "/home/lucasw/other/install/share"]
cmake_alt_paths: ["../src", "/home/lucasw/other/install/lib/cmake/../src", "/home/lucasw/other/install/../src"]
ros_package_paths: [""]
extra_paths: [""]

The macro solution to prepend cargo:warning to every println works even better rust-lang/cargo#985 (comment)

macro_rules! build_println {
    ($($tokens: tt)*) => {
        println!("cargo:warning={}", format!($($tokens)*))
    }
}

So probably just disable the cmake and cmake alt paths, only use ros_package_paths (and set it to something in this case)

@lucasw lucasw reopened this Mar 7, 2024
@lucasw
Copy link
Owner Author

lucasw commented Mar 7, 2024

Removed the cmake paths from rosrust_msg, now only paths are passed in through ROS_PACKAGE_PATH and ROSRUST_MSG_PATH

On a vanilla debian ros system there is no ROS_PACKAGE_PATH so

ROS_PACKAGE_PATH=/usr/share cargo build --verbose

Dependencies like diagnostic_msgs need to be on that path, and probably a few others

The only issue is that the process appears to get stuck at

     Running `/home/lucasw/own/src/rust/rosrust/target/debug/build/rosrust_msg-4e0d22fae2e75704/build-script-build`
    Building [=======================> ] 191/198: rosrust_msg(build)                                                                                                                                                             

The process is taking 100% cpu... and then locked up my computer after a few minutes.

But probably even more evidence that it shouldn't build every message, just the ones it needs.

This very narrow build works:

ROS_PACKAGE_PATH=/usr/share/std_msgs:/usr/share/diagnostic_msgs:/usr/share/actionlib_msgs cargo build

Also building on a different computer worked fine with all of /usr/share, and didn't take long at all.

@lucasw
Copy link
Owner Author

lucasw commented Mar 9, 2024

Looks like default debian catkin adds cmake prefix path to the ros package path, which fouls up rosrust compilation:

Extending:          [cached] /home/lucasw/other/install:/home/lucasw/other/install/lib/cmake

so blank it out for the config

CMAKE_PREFIX_PATH="" catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release
---------------------------------------------------------------
Profile:                     default
Extending:                   None
...

It also gets fouled up if catkin is run after that, have to blank out the cmake prefix path for catkin build too- but what if it is needed?

CMAKE_PREFIX_PATH="" ROSRUST_MSG_PATH=/usr/share/sensor_msgs catkin build -j4 -v

Don't necessarily need to set the prefix path to "" though, it just is confusing when it is there

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

1 participant