mitchellspryn / UrdfSim

Other
102 stars 25 forks source link

Using a static camera with URDFSim #26

Closed huckl3b3rry87 closed 4 years ago

huckl3b3rry87 commented 4 years ago

I am trying to make it so that the camera that is used is static. I followed this tutorial

i.e., A

But, similar to this issue, when I change it to AirSimMode, which I need to spawn the URDF bot, then it reverts back to the camera on the URDFBot.

Also, I tried to change the ViewMode to GroundObserver, but nothing seemed to change. Also, this is not ideal for me as I was hoping to use a specific camera that I have set up.

Q1 Is there a way that I can spawn the Urdfbot without having to use AirSimMode?

Q2 Is there another way to deal with this?

Thank you very much

mitchellspryn commented 4 years ago

I have no idea what your blueprint is trying to do. Even if it were logically correct, it probably wouldn't do anything because we don't use blueprints to set up the cameras, we do it in c++.

To concretely answer your questions:

Q1: Realistically, no. Even if you could, you wouldn't have any of the infrastructure to grab sensor information, the rpc server to communicate with it, etc.

Q2: Yes.

Looking in CameraDirector.cpp, there appears to be a CAMERA_MODE_MANUAL. Looks like it's bound to the "M" key. Maybe that would suit your needs?

If that doesn't, as a quick hack you could try is commenting out the attachSpringArm() calls in ACameraDirector::setMode(). That should stop it from being attached to the bot, and leaving it stuck in place.

huckl3b3rry87 commented 4 years ago

@mitchellspryn thank you again for you helpful advice.

For your first suggestion:

Q3 Do I need to have this camera director setup to use the "M" mode? - if the answer to this is no, please skip to Q5

I actually tried to use a BP_CameraDirector after watching this AirSim tutorial, but I ran into a few issues 1: The UrdfBotPawn is not a blueprint, so I could not just drag it into the unreal editor. And when I clicked on it and turned it into a blueprint, then dragging the blueprint in did not spawn a URDF bot. 2: Even if I could drag it in, I am missing the Pawn field in BP_CameraDirector

On the video AA

Mine A

Since I do not have this setup, I assume why when I hit the "M" key, nothing happens.

Q4 If Q3 is yes, do you know what I may be doing wrong?

Q5 if Q3 is no, is there some other thing that I need to do to enable "M" mode?

Thanks!

mitchellspryn commented 4 years ago

You shouldn't have to use blueprints / configure anything. It should all happen through your settings.json. I'm not sure why pressing the M key isn't working for you - the keybindings might be broken.

What happens if you set "ViewMode" for your camera to "Manual" (from here)?

huckl3b3rry87 commented 4 years ago

OK.

Maybe my settings.json is messed up? Do I need to add anything else from here? - I do get this error on startup A

If I change this line to

std::string view_mode_string = "Manual";

and recompile the project in the unreal editor, I am still unable to move the camera using the keyboard - to check that it built I also printed this string A

huckl3b3rry87 commented 4 years ago

If that doesn't, as a quick hack you could try is commenting out the attachSpringArm() calls in ACameraDirector::setMode(). That should stop it from being attached to the bot, and leaving it stuck in place.

This did not work, the camera is still attached to the bot

mitchellspryn commented 4 years ago

Wait. I'm confused. You're using the arm bot, right? Can't you just attach the camera to the base, which shouldn't move at all?

mitchellspryn commented 4 years ago

Just checked the code. Looks like SimModeUrdfBot doesn't use CameraDirector. So, there isn't an easy way to do this via configuration.

As a hack, if you don't also need moving cameras, you can comment out line 154 of PawnSimApi.cpp (the camera->AttachToComponent()). This should prevent the camera from moving once spawned.

huckl3b3rry87 commented 4 years ago

@mitchellspryn thank you very much, your suggestion and modifying the settings.json file to move the camera worked~

        "Arm": {

          "X": -80,

          "Y": 0,

          "Z": -20,

          "Pitch": 0,

          "Roll": 180,

          "Yaw": 0,

          "AttachLink": "manipulator_base"

        }