unitreerobotics / unitree_legged_sdk

SDK tools for control robots.
BSD 3-Clause "New" or "Revised" License
283 stars 156 forks source link

empty state variable #42

Closed smileyenot983 closed 2 years ago

smileyenot983 commented 2 years ago

We are currently running on of the examples (example_walk.cpp) via a wired connection, robot does all the actions, defined in the code, but the state variable is filled with zeroes all the time:

By state i mean HighState

HighState state = {0}; udp.GetRecv(state);

smileyenot983 commented 2 years ago

robot firmware 1.19

sdk version 3.3.2

TrivasZhang commented 2 years ago

Can i see the app screecshot with versions?

smileyenot983 commented 2 years ago

Can i see the app screecshot with versions?

What do you mean by app screenshot? I have unitree_legged_sdk, which is compiled and i am running example_walk. My PC is connected to the robot via ethernet cable.

here is the code part, where i am printing the state(printing was just commented and i have uncommented it):

`

void Custom::RobotControl() { motiontime += 2; udp.GetRecv(state);

printf("%f %f %f %f %f\n", state.imu.rpy[1], state.imu.rpy[2], state.position[0], state.position[1], state.velocity[0]);

cmd.mode = 0;
cmd.gaitType = 0;
cmd.speedLevel = 0;
cmd.footRaiseHeight = 0;
cmd.bodyHeight = 0;
cmd.euler[0]  = 0;
cmd.euler[1] = 0;
cmd.euler[2] = 0;
cmd.velocity[0] = 0.0f;
cmd.velocity[1] = 0.0f;
cmd.yawSpeed = 0.0f;

if(motiontime > 0 && motiontime < 1000){
    cmd.mode = 1;
    cmd.euler[0] = -0.3;
    // cmd.velocity[0] = 0.2f;
}

`

TrivasZhang commented 2 years ago

I want the app help me to ensure these verisons, like: https://user-images.githubusercontent.com/97996197/171523833-d9bc08f9-0562-430e-bbae-eb5bafc4680e.jpg

smileyenot983 commented 2 years ago

I want the app help me to ensure these verisons, like: https://user-images.githubusercontent.com/97996197/171523833-d9bc08f9-0562-430e-bbae-eb5bafc4680e.jpg

I forgot to mention that we have unitree a1, we do not have such application as in your screenshot

TrivasZhang commented 2 years ago

My colleague will try this next week.

fLattes commented 2 years ago

I have the same problem with the Go1 EDU, the state values are all 0 but the robot moves. I'm using the WiFi connection.

TrivasZhang commented 2 years ago

If under AP connection, then the IP should change to "192.168.12.1".

fLattes commented 2 years ago

Where do I change the IP address?

TrivasZhang commented 2 years ago

https://github.com/unitreerobotics/unitree_legged_sdk/blob/master/examples/example_walk.cpp#L18 change to

udp(8090, "192.168.12.1", 8082, sizeof(HighCmd), sizeof(HighState))
fLattes commented 2 years ago

Thank you, it works. And using ROS, what can I change to have the IMU data, using WiFi connection?

TrivasZhang commented 2 years ago

What happens to IMU data?

fLattes commented 2 years ago

When I launch the program "state_sub" , after launching "roslaunch unitree_legged_real real.launch ctrl_level:=highlevel" and for example "rosrun unitree_legged_real example_walk", all the data are equal to 0, but the robot moves.

TrivasZhang commented 2 years ago

Then try to modify this line https://github.com/unitreerobotics/unitree_ros_to_real/blob/master/unitree_legged_real/src/exe/ros_udp.cpp#L28

fLattes commented 2 years ago

Thank you, it works well now !

TrivasZhang commented 2 years ago

Feel free to reopen it.