I have a project in which I have to move a cube in a Gazebo simulation. I need to do so using the terminal.
I recently had Ubuntu 21.10 with Gazebo 11 and ROS1 Noetic installed and had this working perfectly. I essentially just followed this tutorial: How to Move a Gazebo Model from Terminal
But I had to upgrade to Ubuntu 22.04 and I now have Gazebo 11.10.2 and ROS2 Humble.
I was able to get the current position of the cube thanks to this post:
/gazebo/get_model_state in ROS2 not present
So I modified my world file and used the command: ros2 service call /get_entity_state gazebo_msgs/GetEntityState '{name: cube1, reference_frame: world}' and I was able to get the location of the cube.
I figured the reverse would be something like: ros2 service call /set_entity_state gazebo_msgs/SetEntityState '{name: cube1, Pose:position{x:20, y:0, z:0}, reference_frame: world}' but I get an error saying Failed to populate field: 'SetEntityState_Request' object has no attribute 'name'. However, running ros2 interface show gazebo_msgs/srv/SetEntityState we can see that 'name' absolutely is an attribute:
gazebo_msgs/EntityState state # Entity state to set to.
string name #
# An entity can be a model, link, collision, light, etc.
# Be sure to use gazebo scoped naming notation (e.g. [model_name::link_name])
geometry_msgs/Pose pose #
Point position
float64 x
float64 y
float64 z
Quaternion orientation
float64 x 0
float64 y 0
float64 z 0
float64 w 1
geometry_msgs/Twist twist #
Vector3 linear
float64 x
float64 y
float64 z
Vector3 angular
float64 x
float64 y
float64 z
string reference_frame #
# Leaving empty or "world" defaults to inertial world frame.
# Be sure to fill all fields, values of zero have meaning.
---
bool success # Return true if setting state was successful.
So I am unsure of the syntax and the documentation that I could find does not really help:
ROS 2 Documentation: Humble
ROS 2 Migration: gazebo_ros_api_plugin
ROS 2 Migration: Entity states
Should I use ros2 topic pub as in this tutorial: How to Simulate a Robot Using Gazebo and ROS 2? If so, how? What is the syntax? I've also tried modifying the the output of GetEntityState and pasting into the argument of SetEntityState but get errors relating to the input being a string and not a dictionary, and other various syntax errors.
TL;DR: How do I move an object in Gazebo using ROS2 commands from the terminal, such as in this tutorial: How to Move a Gazebo Model from Terminal?
Thank you.
Related
I have been accustomed to use the base margin parameter in standard xgboost to allow for offset, starting (transformed) prediction (see this SO question SO xgboost exposure question. I wonder if it were possible to perform the same in the h2o implementation of xgboost. In particular I see an offset parameter, but I wonder wether it has been really truly implemented.
Good question -- this is not documented in the parameter description (we use a common definition of offset_column among all algos and there's no note about how its not working in XGBoost). It is not functional and you should get an error if you try to supply it.
R example:
library(h2o)
h2o.init()
fit <- h2o.xgboost(x = 1:3, y = "Species", offset_column = "Petal.Width",
training_frame = as.h2o(iris))
Gives error:
Error: water.exceptions.H2OModelBuilderIllegalArgumentException: Illegal argument(s) for XGBoost model: XGBoost_model_R_1520909592004_2. Details: ERRR on field: _offset_column: Offset is not supported for XGBoost.
i have been doing modification to TraCIDemo11p.cc file and i want to get the position , speed and angle for a certain node" node[8]". i know how to use getCurrentPosition() ,getCurrentSpeed() & getAngleRad() but i don't know how to refer (point) to the node .
i already checked the following question and answer and i could get the position only
How to get RSU coordinate from TraCIDem11p.cc?
i think i don't know how to use getParentModule() and getSubmodule() .
iam using veins 4.4 , sumo 0.25 , omnet 4.5
Using OMNeT++, you can get a cModule* that refers to any named node. As you already know that each of your cars will have a mobility module of a well-known name, this part is straightforward. From there, it's just an issue of casting the returned pointer to the right type (TraCIMobility).
I have a metal 2 shader on macOS 10.12 that I am trying to pass an array of int into, but XCode is giving me a compile-time error Unknown type name 'array'. Here is the code I am using:
kernel void computeMandelbrot(texture2d<float, access::write> output [[texture(0)]], constant int &maxIterations [[buffer(1)]], const array<int, 10> &hist [[buffer(2)]], uint2 gid [[thread_position_in_grid]]) {
// Compute Mandelbrot
}
I have also tried using the keyword constant instead of const but then I also get an error of Parameter may not be qualified with an address space. I had read that arrays of textures were not supported in metal on macOS, but I was not sure if this appled to arrays of other types. Any help would be greatly appriciated, thank you!
A few things:
Metal 2 is not available in macOS 10.12. It is new with 10.13.
array is only usable with textures and samplers.
array is not available on macOS <=10.12. It's available on macOS 10.13+ with Metal 2.
You can declare your parameter as constant int *hist [[buffer(2)]]. It won't have an explicit length, but just limit what elements you reference.
Edit: I was wrong about array only being usable with textures and samplers. The spec suggests that to be the case by introducing it in a section titled "Arrays of Textures and Samplers" and only illustrating its use that way, but the template class itself seems generically useful.
However, until Metal 2, it's not available on macOS. In other words, it's only available on macOS 10.13+.
I am trying to get a set of binary images' eccentricity and solidity values using the regionprops function. I obtain the label matrix using the vision.ConnectedComponentLabeler function.
This is the code I have so far:
files = getFiles('images');
ecc = zeros(length(files)); %eccentricity values
sol = zeros(length(files)); %solidity values
ccl = vision.ConnectedComponentLabeler;
for i=1:length(files)
I = imread(files{i});
[L NUM] = step(ccl, I);
for j=1:NUM
L = changem(L==j, 1, j); %*
end
stats = regionprops(L, 'all');
ecc(i) = stats.Eccentricity;
sol(i) = stats.Solidity;
end
However, when I run this, I get an error says indicating the line marked with *:
Error using ConnectedComponentLabeler/step
Variable-size input signals are not supported when the OutputDataType property is set to 'Automatic'.'
I do not understand what MATLAB is talking about and I do not have any idea about how to get rid of it.
Edit
I have returned back to bwlabel function and have no problems now.
The error is a bit hard to understand, but I can explain what exactly it means. When you use the CVST Connected Components Labeller, it assumes that all of your images that you're going to use with the function are all the same size. That error happens because it looks like the images aren't... hence the notion about "Variable-size input signals".
The "Automatic" property means that the output data type of the images are automatic, meaning that you don't have to worry about whether the data type of the output is uint8, uint16, etc. If you want to remove this error, you need to manually set the output data type of the images produced by this labeller, or the OutputDataType property to be static. Hopefully, the images in the directory you're reading are all the same data type, so override this field to be a data type that this function accepts. The available types are uint8, uint16 and uint32. Therefore, assuming your images were uint8 for example, do this before you run your loop:
ccl = vision.ConnectedComponentLabeler;
ccl.OutputDataType = 'uint8';
Now run your code, and it should work. Bear in mind that the input needs to be logical for this to have any meaningful output.
Minor comment
Why are you using the CVST Connected Component Labeller when the Image Processing Toolbox bwlabel function works exactly the same way? As you are using regionprops, you have access to the Image Processing Toolbox, so this should be available to you. It's much simpler to use and requires no setup: http://www.mathworks.com/help/images/ref/bwlabel.html
I was learning how to do machine learning on mldata.org and I was watching a video on Youtube on how to use the data (https://www.youtube.com/watch?v=zY0UhXPy8fM) (2:50). Using the same data, I tried to follow exactly what he did and create a scatterplot of the dataset. However when he used the scatterplot command, it worked perfectly on his side, but I cannot do it on myside.
Can anyone explain what's wrong and what I should do?
octave:2> load banana_data.octave
octave:3> pkg load communications
octave:4> whos
Variables in the current scope:
Attr Name Size Bytes Class
==== ==== ==== ===== =====
data 2x5300 84800 double
label 1x5300 42400 double
Total is 15900 elements using 127200 bytes
octave:5> scatterplot(data, label)
error: scatterplot: real X must be a vector or a 2-column matrix
error: called from:
error: /home/anthony/octave/communications-1.2.0/scatterplot.m at line 69, column 7
The error message says it all. Your data is a 2-row matrix, and not a 2-column matrix as it should be. Just transpose it with .'.
scatterplot(data.')
I dropped the label argument since it is not compatible with the communications toolbox, either in matlab or in octave.
Update:
According to news('communications'),
The plotting functions eyediagram' andscatterplot' have improved Matlab compatibility
This may be why the behaviour is different. Be ready to find other glitches, as the octave 3.2.4 used in this course is about 5 years old.
In order to use the label, you should rather use the standard octave scatter function.
Colors could be changed by choosing another colormap.
colormap(cool(256))
scatter(data(1,:), data(2,:), 6, label, "filled")